structTests
struct Tests
passed: int
failed: int
endtest: checks for your own code, with a summary at the end. use "test.jamo"
var t = new_tests()
t.equal_int("adding", add(2, 3), 5)
t.check("is alive", enemy.is_alive())
t.finish()
finish shows how many passed, and ends the program with exit code 1 when any failed, so other tools can tell.
For jamo test, which runs each test_ function in a file whose name ends in _test.jamo, there are expect checks. Each one stops the test with a run error when it's wrong, and the line after the error says where in the test:
func test_adding()
expect_equal(add(2, 3), 5)
expect(enemy.is_alive())
end
struct Tests
passed: int
failed: int
endfunc new_tests(): Tests
func Tests.pass_or_fail(name: string, ok: bool, problem: string)
func Tests.check(name: string, ok: bool)
func Tests.equal_int(name: string, got: int, want: int)
func Tests.equal_text(name: string, got: string, want: string)
func Tests.equal_bool(name: string, got: bool, want: bool)
func Tests.equal_float(name: string, got: float, want: float, close: float)
Floats rarely come out exactly, so this passes when got is within close of want
func Tests.finish()
Shows the summary. When any check failed, the program ends with exit code 1
func expect(ok: bool)
func expect_equal(got: int, want: int)
func expect_text(got: string, want: string)
func expect_near(got: float, want: float, close: float)
Floats rarely come out exactly, so this passes when got is within close of want