##- # Author: Brian Tiffin # Dedicated to the public domain # # Date: September 2016 # Modified: 2016-10-23/05:11-0400 ##+ # # literate.icn, Unit testing, in source # $ifndef UNITTEST ## # unit testing experiment procedure main() write("compile with unicon -DUNITTEST for the real show") end $else link unittest ## # unit test trial procedure main() ##- # # # ##+ speaktest := 1 looplimit := -1 test("1 + 2") test("return 1 + 2", 3) test("return 1 + 2", 0) test("return write(1 + 2)", 3, "3\n") tests("suspend 1 to 3", [1,2,3]) tests("syntaxerror 1 to 3", [1,2,3]) looplimit := 4 tests("suspend seq()\\5", [1,2,3,4,5]) tests("suspend seq()\\4", [1,2,3,4]) end $endif $ifdef DOC =================== Unicon unit testing =================== - test(code, result, output, errorout) - singleton - tests(code, result, output, errorout) - generators Set ``speaktest`` to non-null for verbose reporting Set ``looplimit`` to a reasonable value for infinite loop break. $endif