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:
31
examples/memory/0801-memory-slices.sx
Normal file
31
examples/memory/0801-memory-slices.sx
Normal file
@@ -0,0 +1,31 @@
|
||||
#import "modules/std.sx";
|
||||
|
||||
main :: () {
|
||||
arr : [5]i32 = .[3, 1, 4, 1, 5];
|
||||
print("arr.len = {}\n", arr.len);
|
||||
|
||||
// subslice array
|
||||
sub := arr[1..4];
|
||||
print("arr[1..4] = {}\n", sub);
|
||||
print("sub.len = {}\n", sub.len);
|
||||
|
||||
// open-ended
|
||||
head := arr[..3];
|
||||
tail := arr[2..];
|
||||
print("arr[..3] = {}\n", head);
|
||||
print("arr[2..] = {}\n", tail);
|
||||
|
||||
// slice of slice
|
||||
sl : []i32 = .[10, 20, 30, 40, 50];
|
||||
mid := sl[1..4];
|
||||
print("sl[1..4] = {}\n", mid);
|
||||
rest := mid[1..];
|
||||
print("mid[1..] = {}\n", rest);
|
||||
|
||||
// string subslicing
|
||||
msg := "hello world";
|
||||
word := msg[6..11];
|
||||
print("msg[6..11] = {}\n", word);
|
||||
prefix := msg[..5];
|
||||
print("msg[..5] = {}\n", prefix);
|
||||
}
|
||||
Reference in New Issue
Block a user