summaryrefslogtreecommitdiff
path: root/tests/foreign.toc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/foreign.toc')
-rw-r--r--tests/foreign.toc25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/foreign.toc b/tests/foreign.toc
new file mode 100644
index 0000000..d88a223
--- /dev/null
+++ b/tests/foreign.toc
@@ -0,0 +1,25 @@
+fwrite ::= #foreign("fwrite", "libc.so.6") fn (#C &"void const", #C size_t, #C size_t, &u8) #C size_t;
+fputc ::= #foreign("fputc", "libc.so.6") fn (#C int, &u8) #C int;
+
+writes ::= fn(x : []char) {
+ fwrite(&x[0], 1, x.len as u64, #builtin("stdout"));
+};
+
+puts ::= fn(x : []char) {
+ writes(x);
+ fputc('\n' as i32, #builtin("stdout"));
+};
+
+hw ::= fn() int {
+ writes("Hello,");
+ if #builtin("compiling") {
+ writes(" compiling");
+ }
+ puts(" world!");
+ 3
+};
+
+main ::= fn() {
+ hw();
+ x ::= hw();
+}; \ No newline at end of file