update docs for compile chain
This commit is contained in:
@@ -192,6 +192,36 @@ Failures saved to tests/fuzz_failures/
|
||||
|
||||
Saved failure files are valid `.cm` modules that can be run directly or added to the test suite.
|
||||
|
||||
## Compile-Time Diagnostics Tests
|
||||
|
||||
The `tests/compile.cm` test suite verifies that the type checker catches provably wrong operations at compile time. It works by compiling source snippets through the pipeline with `_warn` enabled and checking that the expected diagnostics are emitted.
|
||||
|
||||
```javascript
|
||||
var shop = use('internal/shop')
|
||||
var streamline = use('streamline')
|
||||
|
||||
function get_diagnostics(src) {
|
||||
fd.slurpwrite(tmpfile, stone(blob(src)))
|
||||
var compiled = shop.mcode_file(tmpfile)
|
||||
compiled._warn = true
|
||||
var optimized = streamline(compiled)
|
||||
if (optimized._diagnostics == null) return []
|
||||
return optimized._diagnostics
|
||||
}
|
||||
```
|
||||
|
||||
The suite covers:
|
||||
- **Store errors**: storing named property on array, numeric index on record, property/index on text, push on text/record
|
||||
- **Invoke errors**: invoking null, number, text
|
||||
- **Warnings**: named property access on array/text, record key on record
|
||||
- **Clean code**: valid operations produce no diagnostics
|
||||
|
||||
Run the compile diagnostics tests with:
|
||||
|
||||
```bash
|
||||
pit test compile
|
||||
```
|
||||
|
||||
## Test File Organization
|
||||
|
||||
Tests live in the `tests/` directory of a package:
|
||||
|
||||
Reference in New Issue
Block a user