diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-01-24 22:50:50 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-01-24 22:50:50 -0500 |
commit | a8e52c1e13a6cea5cf4197393002c0da206a99d4 (patch) | |
tree | ea2f0d314e6d92dd71649de99020cb24bef9bc73 /tests/foreign | |
parent | 56464a272cac9e3dfa7d4c702faa23155b3d0134 (diff) |
fixed return declarations
Diffstat (limited to 'tests/foreign')
-rw-r--r-- | tests/foreign/expected | 1 | ||||
-rw-r--r-- | tests/foreign/foreign.toc | 32 | ||||
-rw-r--r-- | tests/foreign/got | 1 | ||||
-rwxr-xr-x | tests/foreign/test.sh | 3 |
4 files changed, 37 insertions, 0 deletions
diff --git a/tests/foreign/expected b/tests/foreign/expected new file mode 100644 index 0000000..af5626b --- /dev/null +++ b/tests/foreign/expected @@ -0,0 +1 @@ +Hello, world! diff --git a/tests/foreign/foreign.toc b/tests/foreign/foreign.toc new file mode 100644 index 0000000..beaa822 --- /dev/null +++ b/tests/foreign/foreign.toc @@ -0,0 +1,32 @@ +voidptr ::= &u8; + +getstdout ::= fn() voidptr { + #builtin("stdout") +}; + + +fwrite :: fn(voidptr, u64, u64, voidptr) u64 = #foreign "fwrite", "libc.so.6"; +fputc :: fn(i32, voidptr) i32 = #foreign "fputc", "libc.so.6"; + +writes ::= fn(x : []char) { + fwrite(&x[0] as voidptr, 1, x.len as u64, getstdout()); +}; + +puts ::= fn(x : []char) { + writes(x); + fputc('\n' as i32, getstdout()); +}; + +hw ::= fn() int { + writes("Hello,"); + if #builtin("compiling") { + writes(" compiling"); + } + puts(" world!"); + 3 +}; + +main ::= fn() { + hw(); + x ::= hw(); +};
\ No newline at end of file diff --git a/tests/foreign/got b/tests/foreign/got new file mode 100644 index 0000000..af5626b --- /dev/null +++ b/tests/foreign/got @@ -0,0 +1 @@ +Hello, world! diff --git a/tests/foreign/test.sh b/tests/foreign/test.sh new file mode 100755 index 0000000..1d6eb8f --- /dev/null +++ b/tests/foreign/test.sh @@ -0,0 +1,3 @@ +#!/bin/sh +./foreign.bin > got || exit 1 +diff got expected || exit 1 |