test.jamo (built in)

test: 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

structTests

struct Tests
    passed: int
    failed: int
end

funcnew_tests

func new_tests(): Tests

funcTests.pass_or_fail

func Tests.pass_or_fail(name: string, ok: bool, problem: string)

funcTests.check

func Tests.check(name: string, ok: bool)

funcTests.equal_int

func Tests.equal_int(name: string, got: int, want: int)

funcTests.equal_text

func Tests.equal_text(name: string, got: string, want: string)

funcTests.equal_bool

func Tests.equal_bool(name: string, got: bool, want: bool)

funcTests.equal_float

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

funcTests.finish

func Tests.finish()

Shows the summary. When any check failed, the program ends with exit code 1

funcexpect

func expect(ok: bool)

funcexpect_equal

func expect_equal(got: int, want: int)

funcexpect_text

func expect_text(got: string, want: string)

funcexpect_near

func expect_near(got: float, want: float, close: float)

Floats rarely come out exactly, so this passes when got is within close of want