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:
agra
2026-06-21 14:41:34 +03:00
parent 6d1409bc1f
commit 66bdc70bf1
3357 changed files with 456 additions and 363 deletions

View File

@@ -0,0 +1 @@
25

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
error-set result: 25

View File

@@ -0,0 +1 @@
1

View 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
| ^

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
8

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
raise result: 8

View File

@@ -0,0 +1 @@
1

View 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
| ^^^^^^^^^^^^^^^^^^^^^

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
5

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
try result: 5

View File

@@ -0,0 +1 @@
1

View 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
| ^^^^^^^^

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
7

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
inferred result: 7

View File

@@ -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
| ^^^^^^^^^

View File

@@ -0,0 +1 @@
134

View File

@@ -0,0 +1 @@
match result: 134

View File

@@ -0,0 +1 @@
18

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
catch result: 18

View File

@@ -0,0 +1 @@
1

View File

@@ -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)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
60

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
value-failable result: 60

View File

@@ -0,0 +1 @@
32

View File

@@ -0,0 +1 @@
consume result: 32

View File

@@ -0,0 +1 @@
1

View File

@@ -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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -0,0 +1 @@
116

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
or result: 116

View File

@@ -0,0 +1 @@
1

View File

@@ -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
| ^^^^^^^^

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,10 @@
[fail]
defer C
onfail B
defer A
[ok]
defer C
defer A
[bound]
cleanup: bad
[done]

View File

@@ -0,0 +1 @@
1

View File

@@ -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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
170

View File

@@ -0,0 +1 @@
multi-value result: 170

View File

@@ -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 `_`
| ^^^^^^^^

View File

@@ -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
| ^^^^^^

View File

@@ -0,0 +1 @@
81

View File

@@ -0,0 +1 @@
returning 1105 -> exit 81

View File

@@ -0,0 +1 @@
1

View File

@@ -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 `!`
| ^^^^^^

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,2 @@
a=BadDigit b=Overflow
parse failed with Empty

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,3 @@
in catch: len=2
after catch: len=0
after success: len=0

View File

@@ -0,0 +1 @@
0

View 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
^

View File

@@ -0,0 +1,2 @@
[stdout] caught BadInput
[stdout] recovered; trace buffer now empty (len 0)

View File

@@ -0,0 +1 @@
1

View File

@@ -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
^

View File

@@ -0,0 +1 @@
v = 10

View File

@@ -0,0 +1 @@
64

View File

@@ -0,0 +1 @@
v = 64

View File

@@ -0,0 +1 @@
120

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@

View File

@@ -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
^

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1,4 @@
WARN: disk 91% full
INFO: user alice connected
ERROR: bad fd 7
DEBUG: trace x=42

View File

@@ -0,0 +1 @@
[stdout] is_comptime runtime=2 comptime=1

View File

@@ -0,0 +1 @@
42

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
starting

View File

@@ -0,0 +1 @@
1

Some files were not shown because too many files have changed in this diff Show More