Break the monolithic examples/50-smoke.sx into 30 focused per-section examples,
filed into their category blocks (basic/types/comptime/memory/protocols/ffi),
each carrying only the top-level decls its section references (the protocols
section keeps the full preamble — its deps flow through UFCS method calls that
name-based extraction can't see). Outputs verified identical to the original
section blocks.
Add examples/1036-errors-failable-smoke.sx — an end-to-end error-handling example
(the E5.4 work): named + inferred error sets consumed via destructure, try (in
helpers), catch (bare-expr / match-body / diverging / no-binding), or
value-terminator, onfail+defer interleave, and error.X value + {} tag
interpolation.
Remove examples/50-smoke.sx. Suite: 324 passed, 0 failed.
43 lines
1.4 KiB
Plaintext
43 lines
1.4 KiB
Plaintext
#import "modules/std.sx";
|
|
#import "modules/math/math.sx";
|
|
#import "modules/compiler.sx";
|
|
#import "modules/test.sx";
|
|
pkg :: #import "modules/testpkg";
|
|
|
|
main :: () {
|
|
|
|
// --- UFCS Aliases & Pipe ---
|
|
{
|
|
print("=== UFCS Aliases ===\n");
|
|
|
|
num_sum :: (a: s64, b: s64) -> s64 { a + b; }
|
|
sum :: ufcs num_sum;
|
|
|
|
print("{}\n", num_sum(40, 2)); // 42 — direct call
|
|
print("{}\n", sum(40, 2)); // 42 — alias direct call
|
|
print("{}\n", 40 |> sum(2)); // 42 — pipe UFCS via alias
|
|
|
|
print("{}\n", num_sum(40, 2)); // 42 — direct (was tuple full-splat)
|
|
print("{}\n", 40 |> sum(2)); // 42 — pipe (was tuple partial-splat)
|
|
|
|
compute :: (a: s64, b: s64, c: s64, d: s64) -> s64 { a + b * c - d; }
|
|
calc :: ufcs compute;
|
|
|
|
print("{}\n", compute(1, 2, 3, 4)); // 1+2*3-4 = 3 (was tuple full-splat)
|
|
print("{}\n", compute(1, 2, 3, 4)); // same = 3 (was tuple partial-splat)
|
|
print("{}\n", 1 |> calc(2, 3, 4)); // same = 3 — pipe UFCS
|
|
|
|
// Tuple return type
|
|
swap :: (a: s64, b: s64) -> (s64, s64) { (b, a); }
|
|
s := swap(1, 2);
|
|
a := s.0;
|
|
b := s.1;
|
|
print("{}\n", a); // 2
|
|
print("{}\n", b); // 1
|
|
|
|
wrap :: (x: s64) -> (s64) { (x,); }
|
|
t := wrap(99);
|
|
print("{}\n", t.0); // 99
|
|
}
|
|
}
|