aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/cabi.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/programs/cabi.zc')
-rw-r--r--tests/programs/cabi.zc33
1 files changed, 18 insertions, 15 deletions
diff --git a/tests/programs/cabi.zc b/tests/programs/cabi.zc
index 6a608ab..da9518b 100644
--- a/tests/programs/cabi.zc
+++ b/tests/programs/cabi.zc
@@ -1,3 +1,6 @@
+namespace;
+include rt;
+
// native calls: extern declares a c function, cfunc hands a zc function to c
extern double sqrt(double);
extern double pow(double x, double y);
@@ -10,7 +13,7 @@ extern int snprintf2(word *buf, long cap, str fmt, long a, double b) = "snprintf
extern double hypot(double, double);
fn put_f(x) { asm { x @ #1220 } return 0; }
-fn sp() { put_c(32); return 0; }
+fn sp() { rt.put_c(32); return 0; }
int cmp(int* a, int* b) { return *a - *b; }
// a callback that makes a native call of its own, and an o3 one
@@ -23,24 +26,24 @@ fn main() {
put_f(sqrt(2.0)); sp();
put_f(pow(2.0, 10.0)); sp();
put_f(sqrtf(16.0)); sp();
- put_n(c_strlen(b"hello, world")); sp();
- put_n(c_abs(0 - 42)); sp();
- put_n(c_atoi(b"1234xyz")); sp();
+ rt.put_n(c_strlen(b"hello, world")); sp();
+ rt.put_n(c_abs(0 - 42)); sp();
+ rt.put_n(c_atoi(b"1234xyz")); sp();
a[0] = 5; a[1] = 3; a[2] = 9; a[3] = 1; a[4] = 7; a[5] = 2;
qsort(a, 6, 8, cfunc(cmp));
- while (i < 6) { put_n(a[i]); sp(); i++; }
- put_c(10);
+ while (i < 6) { rt.put_n(a[i]); sp(); i++; }
+ rt.put_c(10);
qsort(a, 6, 8, cfunc(cmpdesc));
- i = 0; while (i < 6) { put_n(a[i]); sp(); i++; }
- put_c(10);
+ i = 0; while (i < 6) { rt.put_n(a[i]); sp(); i++; }
+ rt.put_c(10);
qsort(a, 6, 8, cfunc(cmp));
- i = 0; while (i < 6) { put_n(a[i]); sp(); i++; }
+ i = 0; while (i < 6) { rt.put_n(a[i]); sp(); i++; }
qsort(a, 6, 8, cfunc(cmpo3));
- i = 0; while (i < 6) { put_n(a[i]); sp(); i++; }
- put_c(10);
- put_n(snprintf2(a, 48, b"%ld:%.2f", 7, 2.5)); sp();
- i = 0; while (i < 6) { put_c(ld8(addr_b(a) + i)); i++; }
- put_c(10);
- put_f(hypot(3.0, 4.0)); put_c(10);
+ i = 0; while (i < 6) { rt.put_n(a[i]); sp(); i++; }
+ rt.put_c(10);
+ rt.put_n(snprintf2(a, 48, b"%ld:%.2f", 7, 2.5)); sp();
+ i = 0; while (i < 6) { rt.put_c(rt.ld8(rt.addr_b(a) + i)); i++; }
+ rt.put_c(10);
+ put_f(hypot(3.0, 4.0)); rt.put_c(10);
return 0;
}