docs: update documentation to match current implementation
- SKILLS.md: Update roadmap phases with actual completion status - Phase 0-1 complete, Phase 2-5 partial, resolved design decisions - OVERVIEW.md: Add HttpServer, Test effect, JIT to completed features - ROADMAP.md: Add HttpServer, Process, Test effects to done list - VISION.md: Update Phase 2-3 tables with current status - guide/05-effects.md: Add Time, HttpServer, Test to effects table - guide/09-stdlib.md: Add HttpServer, Time, Test effect docs - reference/syntax.md: Fix interpolation syntax, remove unsupported literals - testing.md: Add native Test effect documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,50 @@
|
||||
|
||||
This guide explains how to write and run tests for Lux programs.
|
||||
|
||||
## Native Test Effect
|
||||
|
||||
Lux provides a built-in `Test` effect for writing tests:
|
||||
|
||||
```lux
|
||||
fn runTests(): Unit with {Test, Console} = {
|
||||
// Basic assertions
|
||||
Test.assert(1 + 1 == 2, "basic math")
|
||||
|
||||
// Equality checks
|
||||
Test.assertEqual(List.length([1, 2, 3]), 3, "list length")
|
||||
|
||||
// Boolean assertions
|
||||
Test.assertTrue(String.contains("hello", "ell"), "contains check")
|
||||
Test.assertFalse(List.isEmpty([1]), "non-empty list")
|
||||
}
|
||||
|
||||
// Run with the test handler
|
||||
fn main(): Unit with {Console} = {
|
||||
run runTests() with { Test = testReporter }
|
||||
}
|
||||
|
||||
let result = run main() with {}
|
||||
```
|
||||
|
||||
### Test Effect Operations
|
||||
|
||||
| Operation | Purpose |
|
||||
|-----------|---------|
|
||||
| `Test.assert(condition, message)` | Assert condition is true |
|
||||
| `Test.assertEqual(expected, actual, message)` | Assert values are equal |
|
||||
| `Test.assertTrue(condition, message)` | Assert condition is true (alias) |
|
||||
| `Test.assertFalse(condition, message)` | Assert condition is false |
|
||||
|
||||
### Running Tests
|
||||
|
||||
```bash
|
||||
# Run a test file
|
||||
lux tests/my_tests.lux
|
||||
|
||||
# Run with the test runner
|
||||
lux test tests/
|
||||
```
|
||||
|
||||
## Test File Structure
|
||||
|
||||
Lux uses a simple test framework based on comparing program output against expected results. Tests are organized in the `tests/` directory.
|
||||
|
||||
Reference in New Issue
Block a user