test: migrate examples to XXXX-category-name layout + split expected streams
Rename all example tests/companions to the XXXX-category-test-name scheme (per-category 100-blocks: basic 0010, types 0100, ... errors 1000, diagnostics 1100, ffi 1200, ffi-objc 1300, ffi-jni 1400, vectors 1500, platform 1600). Companions and dir/C fixtures move in lockstep with their parent test; #import/#source/#include paths rewritten to match. Expected output now lives in examples/expected/ (a sibling dir of the tests) split into three streams per the new convention: <name>.exit / <name>.stdout / <name>.stderr (+ optional <name>.ir) run_examples.sh rewritten: scans examples/ and issues/ for an expected/<name>.exit marker, captures stdout and stderr separately (no more 2>&1), compares each stream + exit + optional IR snapshot. Behavior validated unchanged: every renamed test reproduces its prior merged output + exit (diffs limited to file paths/basenames embedded in diagnostics + traces, which correctly reflect the new names). Suite: 292 passed, 0 failed. 50-smoke.sx split + issue relocation + docs follow in subsequent commits.
This commit is contained in:
43
examples/1345-ffi-objc-dsl-05-static.sx
Normal file
43
examples/1345-ffi-objc-dsl-05-static.sx
Normal file
@@ -0,0 +1,43 @@
|
||||
// Phase 3 step 3.1 (PLAN-FFI.md): static call `Cls.class_method(args)`
|
||||
// on an `#objc_class` alias lowers to `objc_msg_send` against the class
|
||||
// object (loaded once per module via `objc_getClass` and cached). The
|
||||
// selector is derived by the same default mangling as Phase 3.0
|
||||
// (`stringWithUTF8String_(s)` → "stringWithUTF8String:").
|
||||
//
|
||||
// Mirrors JNI's static-dispatch surface (`Alias.new(...)` etc.); the
|
||||
// lowering disambiguates static vs instance by looking at
|
||||
// `method.is_static` on the foreign-class member.
|
||||
//
|
||||
// Uses NSObject because the cached class slot is populated by a
|
||||
// constructor at module-load — runtime-created test classes wouldn't
|
||||
// exist yet when `objc_getClass` runs. NSObject is always available
|
||||
// on macOS via libobjc.
|
||||
#import "modules/std.sx";
|
||||
#import "modules/compiler.sx";
|
||||
|
||||
NSObject :: #foreign #objc_class("NSObject") {
|
||||
// `+(Class)class` — niladic, name verbatim, selector = "class".
|
||||
// Returns the class object itself. No `self: *Self` first param ⇒
|
||||
// class method (sx parser keys on the param TYPE).
|
||||
class :: () -> *void;
|
||||
// `+(NSString *)description` on the class returns a description
|
||||
// string. Niladic, selector = "description".
|
||||
description :: () -> *void;
|
||||
}
|
||||
|
||||
main :: () -> s32 {
|
||||
inline if OS == .macos {
|
||||
c := NSObject.class();
|
||||
if c != null {
|
||||
print("class non-null\n");
|
||||
}
|
||||
d := NSObject.description();
|
||||
if d != null {
|
||||
print("description non-null\n");
|
||||
}
|
||||
}
|
||||
inline if OS != .macos {
|
||||
print("skipped (not macos)\n");
|
||||
}
|
||||
0;
|
||||
}
|
||||
Reference in New Issue
Block a user