test(ffi-linkage): xfail example for extern fn binding (Phase 1.0b)
Add examples/1223-ffi-extern-fn.sx — binds libc 'abs' via bare 'extern'
(sx name = C symbol, no rename). Hand-authored expected/ captures the
SUCCESS output (abs(-7)=7 / abs(42)=42, exit 0).
RED: 1223 is the sole corpus failure (634 ran, 1 failed) — it parses
then errors at sema ('body produces no value') because lowering does
not yet route extern fns through declareExtern. Phase 1.1 wires the
lowering and turns this green.
xfail commit per the cadence rule (no commit both adds a test and makes
it pass).
This commit is contained in:
14
examples/1223-ffi-extern-fn.sx
Normal file
14
examples/1223-ffi-extern-fn.sx
Normal file
@@ -0,0 +1,14 @@
|
||||
// extern function binding (FFI-linkage stream, Phase 1): bind libc's `abs`
|
||||
// directly via the bare `extern` linkage modifier — no `#foreign`, no
|
||||
// `#library`. `extern` ⇒ external linkage + C ABI + no sx ctx; the symbol
|
||||
// resolves against the default-linked libc at link time. The sx name `abs`
|
||||
// IS the C symbol (no rename — the `extern LIB "csym"` forms land in 1.2).
|
||||
#import "modules/std.sx";
|
||||
|
||||
abs :: (n: i32) -> i32 extern;
|
||||
|
||||
main :: () -> i32 {
|
||||
print("abs(-7) = {}\n", abs(xx -7));
|
||||
print("abs(42) = {}\n", abs(xx 42));
|
||||
0
|
||||
}
|
||||
1
examples/expected/1223-ffi-extern-fn.exit
Normal file
1
examples/expected/1223-ffi-extern-fn.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
1
examples/expected/1223-ffi-extern-fn.stderr
Normal file
1
examples/expected/1223-ffi-extern-fn.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
2
examples/expected/1223-ffi-extern-fn.stdout
Normal file
2
examples/expected/1223-ffi-extern-fn.stdout
Normal file
@@ -0,0 +1,2 @@
|
||||
abs(-7) = 7
|
||||
abs(42) = 42
|
||||
Reference in New Issue
Block a user