Testing
Arden includes a built-in test framework based on attributes and assertion helpers.
The goal is to keep normal test workflows inside the same compiler CLI instead of forcing a separate external runner.
Minimal Test
@Test
function testAddition(): None {
assert_eq(2 + 2, 4);
}
Run it with:
arden test --path test_math.arden
Test Attributes
@Test
Marks a function as a test case.
@Ignore
Skips a test.
@Test
@Ignore("waiting for feature")
function skipped(): None {
fail("should not run");
}
@Before / @After
Run before and after each test.
Use these for per-test setup/cleanup.
@BeforeAll / @AfterAll
Run once per suite.
Use these when repeated setup would be wasteful.
Assertion Helpers
Common built-ins:
assert(condition)assert_true(condition)assert_false(condition)assert_eq(a, b)assert_ne(a, b)fail()fail("message")
Assertion helpers can also be stored as typed function values.
How to read them:
assert(condition)passes whenconditionistrueassert_true(condition)is the explicit version ofassert(condition)assert_false(condition)passes whenconditionisfalseassert_eq(a, b)passes whena == bassert_ne(a, b)passes whena != bfail("message")always aborts the current test immediately
Typical usage:
@Test
function testFlags(): None {
ready: Boolean = true;
assert(ready);
assert_true(ready);
assert_false(!ready);
}
@Test
function testValues(): None {
result: Integer = 3 * 7;
assert_eq(result, 21);
assert_ne(result, 20);
}
Tests do not need an explicit return None; if the body already ends naturally.
CLI
arden test
arden test --list
arden test --filter math
arden test --path tests/
arden test --path tests/math_test.arden
Options:
-p, --path <file-or-dir>-l, --list-f, --filter <pattern>
Typical Workflows
Run The Current Project's Tests
arden test
List Tests Without Executing
arden test --list
Run A Focused Subset
arden test --filter math
Point At A Specific Directory Or File
arden test --path tests/
arden test --path tests/math_test.arden
Behavior Notes
- without
--path, project mode uses the current project's configured files - directory discovery walks nested folders
- generated runner files are isolated from the source tree
- ignored tests are reported but not executed
--listshows discovered tests without running them
Complete Example
@BeforeAll
function initSuite(): None {
println("starting tests");
}
@Test
function testNumbers(): None {
assert_eq(3 * 7, 21);
}
@Test
@Ignore("example")
function skipped(): None {
fail("should not run");
}
When To Prefer arden test
Use the built-in test runner when:
- you want attribute-driven unit-style coverage
- you are already in project mode
- you want test discovery integrated with the compiler
Use the repository example sweep scripts when:
- you changed compiler behavior broadly
- you want to validate the public example corpus
- you need a regression pass beyond one project's tests
Reference example: