1 2 3# fgcommand("nasal-test", props.Node.new({"path":"test_math.nut"})); 4 5 6# note you can omit this if not needed 7var setUp = func { 8 print("Did set-up"); 9}; 10 11# same, cab be ommitted 12var tearDown = func { 13 print("Did tear-down"); 14}; 15 16 17# all test macros take an option 'message' argument 18var test_abc = func { 19 print("Ran test ABC"); 20 21# fails if first argument is zero 22 unitTest.assert(1 == 1, "Math equality"); 23 unitTest.assert(1 < 2, "Math less than"); 24 25 # always fails the test 26 # unitTest.fail("broken"); 27 28 print("Fofofo"); 29 unitTest.assert(4 != 1, "Math inequality"); 30 31 var c = "ap" ~ "ples"; 32 unitTest.assert_equal("apples", c); 33}; 34 35var test_def = func { 36 print("Ran test DEF"); 37 38 var a = 1.0 + 2.0; 39 var b = 99.0; 40 41 unitTest.assert_equal(a, 3, "addition"); 42 43# compare with a tolerance, this will fail 44 unitTest.assert_doubles_equal(3.141, 3, 0.1, "Pi-ish"); 45} 46 47 48