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:
28
examples/generics/0205-generics-generic-method-dot-call.sx
Normal file
28
examples/generics/0205-generics-generic-method-dot-call.sx
Normal file
@@ -0,0 +1,28 @@
|
||||
// Dot-call dispatch for generic struct methods.
|
||||
//
|
||||
// Covers three shapes:
|
||||
// 1. non-generic method: h.plain()
|
||||
// 2. generic method, explicit type arg: h.sized(i32)
|
||||
// 3. generic method, inferred from val: h.taking(99)
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
Holder :: struct {
|
||||
n: i64;
|
||||
|
||||
plain :: (self: *Holder) -> i64 { self.n }
|
||||
sized :: (self: *Holder, $T: Type) -> i64 { size_of(T) }
|
||||
taking :: (self: *Holder, $T: Type, v: T) -> T { v }
|
||||
}
|
||||
|
||||
main :: () -> i32 {
|
||||
h : *Holder = xx libc_malloc(size_of(Holder));
|
||||
h.n = 7;
|
||||
|
||||
print("plain: {}\n", h.plain());
|
||||
print("sized i32: {}\n", h.sized(i32));
|
||||
print("sized i64: {}\n", h.sized(i64));
|
||||
print("taking explicit: {}\n", h.taking(i32, 42));
|
||||
print("taking inferred: {}\n", h.taking(99));
|
||||
0
|
||||
}
|
||||
Reference in New Issue
Block a user