```
(:distance) module Distance { function toMiles(dist) { var mi = dist.toDouble() * 0.6213711922d; return mi.toDouble(); } }
I have the following Test:
// t.is() == test.assertEqualmessage // t.ok() == test.assertMessage() // t.pass() == test.assertMessage(true, msg) // t.fail() == test.assertMessage(false, msg) (:test) function testDistance(logger) { t.is(dist.toMiles(1), 0.6213711922d, "1km is 0.6213711922 miles"); var mi = dist.toMiles(21.0975); Sys.println(mi); // prints 13.109379 var mile = 13.109379d; Sys.println(mile); // print 13.109379 if (mile == mi) { t.pass("A mile is a mile"); } else { t.fail("A mile isn't a mile"); } t.is(dist.toMiles(21.0975), 13.109378728d, "Half marathon distance"); t.ok(dist.toMiles(21.0975) == 13.109379d, "Half marathon distance"); return true; }
This fails on Exception: ASSERTION FAILED: A mile isn't a mile File: UnitTests
I'm kinda expecting it all to work.
The problem is because I cannot see what the test sees (as described here https://forums.garmin.com/developer/connect-iq/i/bug-reports/test-assertequalmessage-and-friends-to-show-incorrectness), so from there I'm sitting the values should be correct. Working around it by adding a toString() doesn't work, it still thinks it isn't the same value.