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:
46
examples/comptime/0609-comptime-inline-if.sx
Normal file
46
examples/comptime/0609-comptime-inline-if.sx
Normal file
@@ -0,0 +1,46 @@
|
||||
#import "modules/std.sx";
|
||||
#import "modules/math";
|
||||
#import "modules/build.sx";
|
||||
#import "modules/std/test.sx";
|
||||
pkg :: #import "tests/fixtures/testpkg";
|
||||
|
||||
main :: () {
|
||||
|
||||
// --- inline if (compile-time conditionals) ---
|
||||
print("=== inline if ===\n");
|
||||
{
|
||||
// POINTER_SIZE is 8 on desktop (64-bit)
|
||||
inline if POINTER_SIZE == 8 {
|
||||
print("64-bit\n");
|
||||
} else {
|
||||
print("32-bit\n");
|
||||
}
|
||||
|
||||
// OS enum comparison
|
||||
inline if OS == .wasm {
|
||||
print("wasm\n");
|
||||
} else {
|
||||
print("not wasm\n");
|
||||
}
|
||||
|
||||
// != comparison
|
||||
inline if OS != .unknown {
|
||||
print("known os\n");
|
||||
} else {
|
||||
print("unknown os\n");
|
||||
}
|
||||
|
||||
// nested inline if
|
||||
inline if POINTER_SIZE != 4 {
|
||||
inline if OS != .wasm {
|
||||
print("desktop 64-bit\n");
|
||||
} else {
|
||||
print("wasm 64-bit??\n");
|
||||
}
|
||||
}
|
||||
|
||||
// POINTER_SIZE in regular (non-inline) if expression
|
||||
ps := if POINTER_SIZE == 8 then "8" else "4";
|
||||
print("pointer size via if: {}\n", ps);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user