OPN Barrel - BSD license

Source code / Documentation

Current version: 0.0.5 / Upcoming release: 0.0.6


Original post

This barrel provides some helper functions to convert time, weight, distance and temperatures from the ISO world to the imperial world.

It also provides a couple of testing functions that I prefer over the current testing functions that Toybox provides, it is in fact because I'm waiting on:

https://forums.garmin.com/developer/connect-iq/i/bug-reports/test-methods-is-isnt-and-ok?CommentId=dee92ccb-2fd0-4e21-8f3a-2f03c4ca6b6e

and because Garmin has said in all their wisdom that printing out an got/expected is too much work for them. So I had to implement new test functions either way:

https://forums.garmin.com/developer/connect-iq/i/bug-reports/test-assertequalmessage-and-friends-to-show-incorrectness?CommentId=07f2d5ec-3daa-4c61-8166-700b61f3a055

And we also test Doubles a bit different and we can test for nulls with the is/isnt functions.

The test methods make the tests much nicer to read imo, as it is just plain english.

  t.is(1, 1, "One is one");
  t.isnt(1, 2, "One isn't two");

// versus

  t.assertEqualMessage(1, 1, "One is one");
  t.assertNotEqualMessage(1, 2, "One isn't two");

And you can actually see what went wrong:

Got: 1
Expect: 2


Error: Unhandled Exception
Exception: ASSERTION FAILED: Nope
Stack:
  - assertMessage() at e6eec51.mb:186 0x300057f6
  - assertEqualMessage() at e6eec51.mb:243 0x3000584b
  - is() at /tmp/OPN.barrel8573689546243066108/content/source/Test/More.mc:47 0x1000825e
  - testMatchLogic() at /home/ciq/src/source/t/TestMatch.mc:73 0x10001249
  - evaluate_test_entries_0_to_29() at UnitTests:78 0x100003ef
  - runTest() at UnitTests:165 0x10000839
ERROR