native test framework
This commit is contained in:
@@ -73,6 +73,27 @@ linker inputs) and, like those flags, their paths are relative to the invocation
|
||||
directory. Lists take the address of an array literal; empty lists are written
|
||||
`&[]`. See `examples/build/` for runnable projects.
|
||||
|
||||
Projects can declare tests directly and run them with `brolang test [root]`.
|
||||
The command reads the same `build.bro`, writes `build/<name>-test`, and reuses
|
||||
its C link inputs, libraries, include paths, and defines.
|
||||
|
||||
```bro
|
||||
math :: import "../math"
|
||||
testing :: import "@std/testing"
|
||||
|
||||
test import "../math"
|
||||
|
||||
addition test {
|
||||
try testing.expect(math.add(20, 22) == 42)
|
||||
try testing.expect_equal(42, math.add(20, 22))
|
||||
}
|
||||
```
|
||||
|
||||
`test import` discovers tests transitively without creating a namespace;
|
||||
calling package code still requires an ordinary import. Ordinary imports do
|
||||
not discover dependency tests. Assertions report their source location, a
|
||||
failure ends only the current test, and the runner continues with the suite.
|
||||
|
||||
Relative `.h` imports create synthetic package namespaces backed by libclang:
|
||||
|
||||
```bro
|
||||
|
||||
Reference in New Issue
Block a user