lily/docs/spec/tests.md
2025-02-03 19:26:16 +00:00

1.2 KiB

tests

tests are written in src/test

  1. tests that test the language will be in the lang subdirectory
  2. tests that test lily will be in the lily subdirectory
  3. all tests should return any integer or boolean value.

    follow standard practices for exit code.
    0 for success, 1 for error, etc

  4. all tests should contain the test specification (preferably at the top of the file)
    • strings & arrays may be multiline
    • argument order does not matter
    • all test arguments are optional

      tests with no arguments will always pas

    • timeout is the max length a test can run before failing
    • args are given to the application executable
    • exit is the exit status of the program (return code)
  5. if test compilation fails, the test will be considered failed
  6. tests for lily should try to limit the number of unrelated structures/functions tested.
  7. tests for lang should be headless (not rely on lily at all)

a trivial example test:

expected := .{
	exit: 0,
    timeout: 0.5,
    stdout: "",
    args: .[]
}

main := fn(): u8 {
    // test will fail after 0.5s
    loop {}
}