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:
50
examples/basic/0016-basic-while.sx
Normal file
50
examples/basic/0016-basic-while.sx
Normal file
@@ -0,0 +1,50 @@
|
||||
#import "modules/std.sx";
|
||||
|
||||
sumOf10 :: () -> i32 {
|
||||
i:= 1;
|
||||
s:=0;
|
||||
while i <= 10 {
|
||||
s+=i;
|
||||
i+=1;
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
someSum :: #run sumOf10();
|
||||
|
||||
main :: () {
|
||||
// Basic while loop: count to 5
|
||||
i := 0;
|
||||
while i < 5 {
|
||||
i += 1;
|
||||
}
|
||||
print("count: {}\n", i);
|
||||
|
||||
// While with break
|
||||
x := 1;
|
||||
while x < 100 {
|
||||
if x == 12 {
|
||||
break;
|
||||
}
|
||||
x += 1;
|
||||
}
|
||||
print("break at: {}\n", x);
|
||||
|
||||
// While with continue: sum odd numbers 1-9
|
||||
sum := 0;
|
||||
j := 0;
|
||||
while j < 10 {
|
||||
j += 1;
|
||||
// Skip even numbers
|
||||
if j == 2 { continue; }
|
||||
if j == 4 { continue; }
|
||||
if j == 6 { continue; }
|
||||
if j == 8 { continue; }
|
||||
if j == 10 { continue; }
|
||||
sum += j;
|
||||
}
|
||||
print("sum of odd 1-9: {}\n", sum);
|
||||
|
||||
print("sum {}", someSum);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user