test: group examples into per-category folders
Move examples/*.sx and their expected/ snapshots into per-category subfolders (examples/<category>/...). Folder = leading filename token, with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus runner and LSP sweep now discover each category's expected/ dir, while issues/ stays flat. Example 1058's repo-root-relative companion import is made file-relative. Path strings embedded in 164 snapshots were regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
This commit is contained in:
1
examples/errors/expected/1000-errors-sets.exit
Normal file
1
examples/errors/expected/1000-errors-sets.exit
Normal file
@@ -0,0 +1 @@
|
||||
25
|
||||
1
examples/errors/expected/1000-errors-sets.stderr
Normal file
1
examples/errors/expected/1000-errors-sets.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/errors/expected/1000-errors-sets.stdout
Normal file
1
examples/errors/expected/1000-errors-sets.stdout
Normal file
@@ -0,0 +1 @@
|
||||
error-set result: 25
|
||||
1
examples/errors/expected/1001-errors-set-typing.exit
Normal file
1
examples/errors/expected/1001-errors-set-typing.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
11
examples/errors/expected/1001-errors-set-typing.stderr
Normal file
11
examples/errors/expected/1001-errors-set-typing.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: error tag 'error.NotInSet' is not in error set 'ParseErr'
|
||||
--> examples/errors/1001-errors-set-typing.sx:13:20
|
||||
|
|
||||
13 | c : ParseErr = error.NotInSet; // error: NotInSet not in ParseErr
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: an error-set value compares only with an `error.X` tag or another error-set value; coerce with `xx` to compare the raw id
|
||||
--> examples/errors/1001-errors-set-typing.sx:14:8
|
||||
|
|
||||
14 | if c == 42 { return 1; } // error: error-set value vs raw integer
|
||||
| ^
|
||||
1
examples/errors/expected/1001-errors-set-typing.stdout
Normal file
1
examples/errors/expected/1001-errors-set-typing.stdout
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/errors/expected/1002-errors-raise.exit
Normal file
1
examples/errors/expected/1002-errors-raise.exit
Normal file
@@ -0,0 +1 @@
|
||||
8
|
||||
1
examples/errors/expected/1002-errors-raise.stderr
Normal file
1
examples/errors/expected/1002-errors-raise.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/errors/expected/1002-errors-raise.stdout
Normal file
1
examples/errors/expected/1002-errors-raise.stdout
Normal file
@@ -0,0 +1 @@
|
||||
raise result: 8
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
17
examples/errors/expected/1003-errors-raise-rejections.stderr
Normal file
17
examples/errors/expected/1003-errors-raise-rejections.stderr
Normal file
@@ -0,0 +1,17 @@
|
||||
error: error tag 'error.NotInSet' is not in error set 'ParseErr'
|
||||
--> examples/errors/1003-errors-raise-rejections.sx:17:11
|
||||
|
|
||||
17 | raise error.NotInSet; // error: NotInSet not in ParseErr
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: error tag 'error.Weird' is not in caller's error set 'ParseErr'
|
||||
--> examples/errors/1003-errors-raise-rejections.sx:24:5
|
||||
|
|
||||
24 | raise e; // error: OtherErr not subset of ParseErr
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `raise` is only valid inside a failable function (a return type with `!` or `!Named`)
|
||||
--> examples/errors/1003-errors-raise-rejections.sx:30:5
|
||||
|
|
||||
30 | raise error.BadDigit; // error: main (-> i32) is not failable
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/errors/expected/1004-errors-try.exit
Normal file
1
examples/errors/expected/1004-errors-try.exit
Normal file
@@ -0,0 +1 @@
|
||||
5
|
||||
16037
examples/errors/expected/1004-errors-try.ir
Normal file
16037
examples/errors/expected/1004-errors-try.ir
Normal file
File diff suppressed because one or more lines are too long
1
examples/errors/expected/1004-errors-try.stderr
Normal file
1
examples/errors/expected/1004-errors-try.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/errors/expected/1004-errors-try.stdout
Normal file
1
examples/errors/expected/1004-errors-try.stdout
Normal file
@@ -0,0 +1 @@
|
||||
try result: 5
|
||||
1
examples/errors/expected/1005-errors-try-rejections.exit
Normal file
1
examples/errors/expected/1005-errors-try-rejections.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
17
examples/errors/expected/1005-errors-try-rejections.stderr
Normal file
17
examples/errors/expected/1005-errors-try-rejections.stderr
Normal file
@@ -0,0 +1,17 @@
|
||||
error: `try` is only valid inside a failable function (a return type with `!` or `!Named`)
|
||||
--> examples/errors/1005-errors-try-rejections.sx:20:5
|
||||
|
|
||||
20 | try ga(); // error: `try` outside a failable function
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `try` requires a failable expression; operand has type 'i32'
|
||||
--> examples/errors/1005-errors-try-rejections.sx:26:5
|
||||
|
|
||||
26 | try plain(); // error: operand has type i32 (not failable)
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: error tag 'error.Yb' is not in caller's error set 'A'
|
||||
--> examples/errors/1005-errors-try-rejections.sx:32:5
|
||||
|
|
||||
32 | try gb(); // error: Yb not in caller's error set A
|
||||
| ^^^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
7
|
||||
16054
examples/errors/expected/1006-errors-inferred-error-sets.ir
Normal file
16054
examples/errors/expected/1006-errors-inferred-error-sets.ir
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
inferred result: 7
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
error: error tag 'error.Foo' is not in caller's error set 'A'
|
||||
--> examples/errors/1007-errors-inferred-widening-reject.sx:23:5
|
||||
|
|
||||
23 | try via(); // error: Foo (via's converged set) not in A
|
||||
| ^^^^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
134
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
match result: 134
|
||||
1
examples/errors/expected/1009-errors-catch.exit
Normal file
1
examples/errors/expected/1009-errors-catch.exit
Normal file
@@ -0,0 +1 @@
|
||||
18
|
||||
16148
examples/errors/expected/1009-errors-catch.ir
Normal file
16148
examples/errors/expected/1009-errors-catch.ir
Normal file
File diff suppressed because one or more lines are too long
1
examples/errors/expected/1009-errors-catch.stderr
Normal file
1
examples/errors/expected/1009-errors-catch.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/errors/expected/1009-errors-catch.stdout
Normal file
1
examples/errors/expected/1009-errors-catch.stdout
Normal file
@@ -0,0 +1 @@
|
||||
catch result: 18
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
error: `catch` requires a failable expression; operand has type 'i32'
|
||||
--> examples/errors/1010-errors-catch-rejections.sx:11:5
|
||||
|
|
||||
11 | plain() catch (e) { return 1; }; // error: operand has type i32 (not failable)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/errors/expected/1011-errors-value-failable.exit
Normal file
1
examples/errors/expected/1011-errors-value-failable.exit
Normal file
@@ -0,0 +1 @@
|
||||
60
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
value-failable result: 60
|
||||
@@ -0,0 +1 @@
|
||||
32
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
consume result: 32
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
error: `catch` body must produce a value of type 'i32' (or diverge with `return` / `raise`)
|
||||
--> examples/errors/1013-errors-value-failable-reject.sx:17:10
|
||||
|
|
||||
17 | x := parse(-1) catch (e) { print("oops\n") }; // error: body yields no value
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/errors/expected/1014-errors-failable-or.exit
Normal file
1
examples/errors/expected/1014-errors-failable-or.exit
Normal file
@@ -0,0 +1 @@
|
||||
116
|
||||
1
examples/errors/expected/1014-errors-failable-or.stderr
Normal file
1
examples/errors/expected/1014-errors-failable-or.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/errors/expected/1014-errors-failable-or.stdout
Normal file
1
examples/errors/expected/1014-errors-failable-or.stdout
Normal file
@@ -0,0 +1 @@
|
||||
or result: 116
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
error: `or value` requires a value-carrying failable (`-> (T, !)`) — a `-> !` has no success value to fall back to; use `catch` to absorb the error
|
||||
--> examples/errors/1015-errors-failable-or-reject.sx:17:10
|
||||
|
|
||||
17 | x := must(-1) or 0; // error: `-> !` has no success value to fall back to
|
||||
| ^^^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/errors/expected/1016-errors-onfail.exit
Normal file
1
examples/errors/expected/1016-errors-onfail.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
1
examples/errors/expected/1016-errors-onfail.stderr
Normal file
1
examples/errors/expected/1016-errors-onfail.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
10
examples/errors/expected/1016-errors-onfail.stdout
Normal file
10
examples/errors/expected/1016-errors-onfail.stdout
Normal file
@@ -0,0 +1,10 @@
|
||||
[fail]
|
||||
defer C
|
||||
onfail B
|
||||
defer A
|
||||
[ok]
|
||||
defer C
|
||||
defer A
|
||||
[bound]
|
||||
cleanup: bad
|
||||
[done]
|
||||
1
examples/errors/expected/1017-errors-onfail-reject.exit
Normal file
1
examples/errors/expected/1017-errors-onfail-reject.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
error: `onfail` is only valid inside a failable function (a return type with `!` or `!Named`) — use `defer` for unconditional cleanup
|
||||
--> examples/errors/1017-errors-onfail-reject.sx:9:5
|
||||
|
|
||||
9 | onfail print("never fires\n"); // error: onfail outside a failable function
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
170
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
multi-value result: 170
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,11 @@
|
||||
error: the error slot of a failable cannot be dropped — bind it (`v, err := …`) and handle it, or use `try` / `catch`
|
||||
--> examples/errors/1019-errors-failable-discard-reject.sx:27:13
|
||||
|
|
||||
27 | a, b := pair(5); // ERROR: error slot omitted (3 slots, 2 names)
|
||||
| ^^^^^^^
|
||||
|
||||
error: the error slot of a failable cannot be dropped — bind it (`v, err := …`) and handle it, or use `try` / `catch`
|
||||
--> examples/errors/1019-errors-failable-discard-reject.sx:28:13
|
||||
|
|
||||
28 | v, _ := parse(5); // ERROR: error slot discarded with `_`
|
||||
| ^^^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
error: `return` is not allowed inside a `defer` body — cleanup runs while the function is already exiting, so there is nothing to transfer control to
|
||||
--> examples/errors/1020-errors-cleanup-body-restrictions.sx:18:14
|
||||
|
|
||||
18 | defer { return; } // ERROR: return in defer body
|
||||
| ^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
81
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
returning 1105 -> exit 81
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
error: main: return type must be void, an integer, or `!`; got 'string'
|
||||
--> examples/errors/1022-errors-main-signature-reject.sx:13:15
|
||||
|
|
||||
13 | main :: () -> string { // ERROR: return type must be void, an integer, or `!`
|
||||
| ^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
a=BadDigit b=Overflow
|
||||
parse failed with Empty
|
||||
1
examples/errors/expected/1024-errors-trace-buffer.exit
Normal file
1
examples/errors/expected/1024-errors-trace-buffer.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
1
examples/errors/expected/1024-errors-trace-buffer.stderr
Normal file
1
examples/errors/expected/1024-errors-trace-buffer.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
3
examples/errors/expected/1024-errors-trace-buffer.stdout
Normal file
3
examples/errors/expected/1024-errors-trace-buffer.stdout
Normal file
@@ -0,0 +1,3 @@
|
||||
in catch: len=2
|
||||
after catch: len=0
|
||||
after success: len=0
|
||||
1
examples/errors/expected/1025-errors-trace-format.exit
Normal file
1
examples/errors/expected/1025-errors-trace-format.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
7
examples/errors/expected/1025-errors-trace-format.stderr
Normal file
7
examples/errors/expected/1025-errors-trace-format.stderr
Normal file
@@ -0,0 +1,7 @@
|
||||
error return trace (most recent call last):
|
||||
leaf at 1025-errors-trace-format.sx:20:16
|
||||
if n < 0 { raise error.BadInput; } // pushes frame 0
|
||||
^
|
||||
mid at 1025-errors-trace-format.sx:25:5
|
||||
try leaf(n); // propagation pushes frame 1
|
||||
^
|
||||
2
examples/errors/expected/1025-errors-trace-format.stdout
Normal file
2
examples/errors/expected/1025-errors-trace-format.stdout
Normal file
@@ -0,0 +1,2 @@
|
||||
[stdout] caught BadInput
|
||||
[stdout] recovered; trace buffer now empty (len 0)
|
||||
1
examples/errors/expected/1026-errors-failable-main.exit
Normal file
1
examples/errors/expected/1026-errors-failable-main.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,8 @@
|
||||
error: unhandled error reached main: error.Empty
|
||||
error return trace (most recent call last):
|
||||
inner at 1026-errors-failable-main.sx:18:17
|
||||
if n == 0 { raise error.Empty; } // pushes a frame
|
||||
^
|
||||
main at 1026-errors-failable-main.sx:26:10
|
||||
w := try inner(0); // raises Empty → propagates to main
|
||||
^
|
||||
@@ -0,0 +1 @@
|
||||
v = 10
|
||||
@@ -0,0 +1 @@
|
||||
64
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
v = 64
|
||||
@@ -0,0 +1 @@
|
||||
120
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,20 @@
|
||||
error: unhandled error reached main: error.A
|
||||
error return trace (most recent call last):
|
||||
fa at 1029-errors-failable-or-chain-propagate.sx:14:17
|
||||
if n == 0 { raise error.A; }
|
||||
^
|
||||
main at 1029-errors-failable-or-chain-propagate.sx:19:10
|
||||
v := try fa(0) or try fa(0) or try fa(0); // all fail → propagate to main
|
||||
^
|
||||
fa at 1029-errors-failable-or-chain-propagate.sx:14:17
|
||||
if n == 0 { raise error.A; }
|
||||
^
|
||||
main at 1029-errors-failable-or-chain-propagate.sx:19:10
|
||||
v := try fa(0) or try fa(0) or try fa(0); // all fail → propagate to main
|
||||
^
|
||||
fa at 1029-errors-failable-or-chain-propagate.sx:14:17
|
||||
if n == 0 { raise error.A; }
|
||||
^
|
||||
main at 1029-errors-failable-or-chain-propagate.sx:19:10
|
||||
v := try fa(0) or try fa(0) or try fa(0); // all fail → propagate to main
|
||||
^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1,4 @@
|
||||
WARN: disk 91% full
|
||||
INFO: user alice connected
|
||||
ERROR: bad fd 7
|
||||
DEBUG: trace x=42
|
||||
@@ -0,0 +1 @@
|
||||
[stdout] is_comptime runtime=2 comptime=1
|
||||
1
examples/errors/expected/1031-errors-process-exit.exit
Normal file
1
examples/errors/expected/1031-errors-process-exit.exit
Normal file
@@ -0,0 +1 @@
|
||||
42
|
||||
1
examples/errors/expected/1031-errors-process-exit.stderr
Normal file
1
examples/errors/expected/1031-errors-process-exit.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/errors/expected/1031-errors-process-exit.stdout
Normal file
1
examples/errors/expected/1031-errors-process-exit.stdout
Normal file
@@ -0,0 +1 @@
|
||||
starting
|
||||
1
examples/errors/expected/1032-errors-assert.exit
Normal file
1
examples/errors/expected/1032-errors-assert.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user