Mwexim / skript-parser

A standalone and improved implementation of the Skript language for use outside of Minecraft servers.
MIT License
49 stars 15 forks source link

Test of expression "Today at" fail #125

Closed WeeskyBDW closed 2 years ago

WeeskyBDW commented 3 years ago

👋 i was working on #119 (yes the PR isn't dead lol) and a new test error was throw to me by skript-parser. Test who throw the error is ExprDateTodayAt. After a bit of tests, it appear that it do this only between 0:00 and 1:00 (12am and 1am)

How to reproduct: set your computer hour to 0:35 for example run unit tests (gradlew test)

skript-parser version: from master branch Java version: 11.8.0 Error:

SyntaxParserTest > syntaxTest() > expressions > io.github.syst3ms.skriptparser.parsing.SyntaxParserTest.syntaxTest()[2][26] FAILED
    java.lang.AssertionError: Days of {now} and {today} are not equal: 24 != 25 (respectively) (ExprDateTodayAt.txt)
        at io.github.syst3ms.skriptparser.syntax.EffAssert.lambda$execute$1(EffAssert.java:71)
        at java.base/java.util.Optional.ifPresent(Optional.java:183)
        at io.github.syst3ms.skriptparser.syntax.EffAssert.execute(EffAssert.java:71)
        at io.github.syst3ms.skriptparser.lang.Effect.run(Effect.java:14)
        at io.github.syst3ms.skriptparser.lang.Statement.walk(Statement.java:72)
        at io.github.syst3ms.skriptparser.lang.Statement.lambda$runAll$0(Statement.java:92)
        at java.base/java.util.Optional.flatMap(Optional.java:294)
        at io.github.syst3ms.skriptparser.lang.Statement.runAll(Statement.java:92)
        at io.github.syst3ms.skriptparser.TestAddon.finishedLoading(TestAddon.java:31)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at io.github.syst3ms.skriptparser.parsing.SyntaxParserTest.lambda$syntaxTest$4(SyntaxParserTest.java:62)

Edit: this seem to be a know bug, according to the test code. No way to fix that ?

Mwexim commented 3 years ago

This is caused by the SkriptParser class. For the today() method, it takes the ZONE_ID static field into account (which is Greenwich Mean Time for all tests). For the now() method though, the system time zone is used.

I assume you live in the GMT+1 region somewhere, which is the reason this fails for you between 12PM and 1AM.

WeeskyBDW commented 3 years ago

I live in France so yes. No way to fix this ?

Mwexim commented 3 years ago

I live in France so yes. No way to fix this ?

There is an easy fix, working on it as we speak.