- Add registry README with API documentation - Add initial packages: json, http-client, testing - Add package index.json for registry server Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1.5 KiB
1.5 KiB
testing
Testing utilities and assertions for Lux.
Installation
lux pkg add testing 0.1.0
Usage
import testing
fn testMyFunction(): Unit with {Console, Test} = {
testing.describe("MyFunction", fn() => {
testing.it("should return correct value", fn() => {
let result = myFunction(5)
testing.assertEqual(result, 10, "5 * 2 should be 10")
})
testing.it("should handle edge cases", fn() => {
let result = myFunction(0)
testing.assertEqual(result, 0, "0 * 2 should be 0")
})
})
}
Assertions
| Function | Description |
|---|---|
assert(cond, msg) |
Assert condition is true |
assertEqual(a, b, msg) |
Assert two values are equal |
assertSome(opt, msg) |
Assert Option is Some |
assertNone(opt, msg) |
Assert Option is None |
assertOk(result, msg) |
Assert Result is Ok |
assertErr(result, msg) |
Assert Result is Err |
assertEmpty(list, msg) |
Assert list is empty |
assertLength(list, n, msg) |
Assert list has length n |
assertContains(s, sub, msg) |
Assert string contains substring |
assertStartsWith(s, pre, msg) |
Assert string starts with prefix |
assertEndsWith(s, suf, msg) |
Assert string ends with suffix |
Test Structure
| Function | Description |
|---|---|
describe(name, tests) |
Group related tests |
it(desc, test) |
Define individual test |
License
MIT