Tests
Tests are package items. They are compiled only by lt test, never by lt build.
package money {
test "formats with currency" {
let p = Price(amount: 1250, currency: "IDR")
expect.eq(format_price(p), "12.50 IDR")
}
}
- A title is a string literal, unique within its package.
- A test body is a normal statement block. It may call private declarations in the same package.
- Assertions use the pseudo-package
expect:expect.eq(a, b),expect.not_equal(a, b),expect.true(x),expect.false(x). - There is no mocking, setup, teardown, or parallel execution. Tests must be deterministic and pure.
Run the tests
lt test -t ts src/money.lt --out out/test --run
lt test -t py src/money.lt --out out/test --run
lt test -t go src/money.lt --out out/test --run
--run uses the native runner: vitest, pytest, or go test. Without it, lt test only emits the test files. The generated test project includes the target runtime and a manifest, so a single command is enough.
A target is considered conformant only when its entire test suite passes. The repository’s conformance flow runs the same .lt tests against all three targets.
Complete example
package generic_fn {
export fn identity<T>(value: T) -> T {
value
}
export fn first<T>(items: List<T>) -> Option<T> {
items.get(0)
}
test "infers from a scalar" {
expect.eq(identity(7), 7)
}
test "infers from a list" {
expect.eq(first(["a", "b"]), Some("a"))
}
}