#929 Precision issue with testSys::DateTimeTest

katox Sun 24 Jan 2010

I get random failures in DateTimeTest.testNow verify statement because of rounding, for instance:

-- Run:  testSys::DateTimeTest.testNow...
dt1=2010-01-24T12:36:23.629Z UTC, time=12:36:23.63, dt2=2010-01-24T12:36:23.629Z UTC

I added echo statement before verify in the original sources the problem would be on line 173.

TEST FAILED
sys::TestErr: Test failed
  fan.sys.Test.err (Test.java:179)
  fan.sys.Test.fail (Test.java:173)
  fan.sys.Test.verify (Test.java:57)
  fan.sys.Test.verify (Test.java:54)
  testSys::DateTimeTest.testNow (DateTimeTest.fan:174)

SideNote: a "coredump" of local variables in test method would be handy in case of a failure. I had to run the test in a long cycle after adding an echo to reproduce this issue.

brian Mon 25 Jan 2010

I pushed a fix - let me know if you still see it after the next build.

katox Mon 25 Jan 2010

It helps thank you. Pretty tricky patch - I wouldn't guess that Time.now and DateTime.nowUtc do use caching but Time.now(timezone) always creates a new instance.

Login or Signup to reply.