Rename all example tests/companions to the XXXX-category-test-name scheme (per-category 100-blocks: basic 0010, types 0100, ... errors 1000, diagnostics 1100, ffi 1200, ffi-objc 1300, ffi-jni 1400, vectors 1500, platform 1600). Companions and dir/C fixtures move in lockstep with their parent test; #import/#source/#include paths rewritten to match. Expected output now lives in examples/expected/ (a sibling dir of the tests) split into three streams per the new convention: <name>.exit / <name>.stdout / <name>.stderr (+ optional <name>.ir) run_examples.sh rewritten: scans examples/ and issues/ for an expected/<name>.exit marker, captures stdout and stderr separately (no more 2>&1), compares each stream + exit + optional IR snapshot. Behavior validated unchanged: every renamed test reproduces its prior merged output + exit (diffs limited to file paths/basenames embedded in diagnostics + traces, which correctly reflect the new names). Suite: 292 passed, 0 failed. 50-smoke.sx split + issue relocation + docs follow in subsequent commits.
37 lines
1.3 KiB
Plaintext
37 lines
1.3 KiB
Plaintext
// Error return-trace formatting (ERR step E3.3). `library/modules/trace.sx`
|
|
// reads the trace buffer (E3.1, populated by E3.2's raise/try push wiring) and
|
|
// renders it. `trace.print_current()` writes the trace to stderr; the catch
|
|
// handler sees the full chain because the absorption clear fires at handler
|
|
// EXIT, not entry. Frame locations are placeholders until DWARF (ERR E3.0)
|
|
// resolves PCs to file:line; the count + ordering are already meaningful.
|
|
//
|
|
// Note: the trace goes to stderr. The test runner merges stderr+stdout, so the
|
|
// snapshot shows the trace lines interleaved with the `print` (stdout) lines.
|
|
|
|
#import "modules/std.sx";
|
|
trace :: #import "modules/trace.sx";
|
|
|
|
// Buffer length probe (the runtime symbol; public read API is the trace module).
|
|
sx_trace_len :: () -> u32 #foreign;
|
|
|
|
E :: error { BadInput, Overflow }
|
|
|
|
leaf :: (n: s32) -> !E {
|
|
if n < 0 { raise error.BadInput; } // pushes frame 0
|
|
return;
|
|
}
|
|
|
|
mid :: (n: s32) -> !E {
|
|
try leaf(n); // propagation pushes frame 1
|
|
return;
|
|
}
|
|
|
|
main :: () -> s32 {
|
|
mid(-1) catch e {
|
|
print("[stdout] caught {}\n", e); // tag name via the always-linked table
|
|
trace.print_current(); // [stderr] the 2-frame trace
|
|
};
|
|
print("[stdout] recovered; trace buffer now empty (len {})\n", sx_trace_len());
|
|
return 0;
|
|
}
|