summaryrefslogtreecommitdiff
path: root/tests/nms
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-03-03 17:05:28 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-03-03 17:05:28 -0500
commit2bf840925ba7781d16406ac28438f8bdc5f7d08c (patch)
treee70ca149eafd8eb4366a6ecf1edb1d4bed9e5aee /tests/nms
parent0a3bb0c9ce4a2e96c7be3d0519aa0f5fa458c1af (diff)
new, better test system
Diffstat (limited to 'tests/nms')
-rw-r--r--tests/nms/expected4
-rw-r--r--tests/nms/io.toc57
-rw-r--r--tests/nms/nms.toc20
-rwxr-xr-xtests/nms/test.sh3
4 files changed, 0 insertions, 84 deletions
diff --git a/tests/nms/expected b/tests/nms/expected
deleted file mode 100644
index d26c123..0000000
--- a/tests/nms/expected
+++ /dev/null
@@ -1,4 +0,0 @@
-Hello!
-2
-3
-5
diff --git a/tests/nms/io.toc b/tests/nms/io.toc
deleted file mode 100644
index 5a69269..0000000
--- a/tests/nms/io.toc
+++ /dev/null
@@ -1,57 +0,0 @@
-get_type_with_size ::= fn(size :: i64) Type {
- if size == 1 { i8 }
- elif size == 2 { i16 }
- elif size == 4 { i32 }
- elif size == 8 { i64 }
- else { f32 }
-};
-
-get_utype_with_size ::= fn(size :: i64) Type {
- if size == 1 { u8 }
- elif size == 2 { u16 }
- elif size == 4 { u32 }
- elif size == 8 { u64 }
- else { f32 }
-};
-
-c_int ::= get_type_with_size(#builtin("sizeof int"));
-c_size_t ::= get_utype_with_size(#builtin("sizeof size_t"));
-
-c_putchar ::= #foreign("putchar", "libc.so.6") fn(#C int) #C int;
-toc_putchar ::= fn(x: char) {
- c_putchar(x as c_int);
-};
-
-c_fwrite ::= #foreign("fwrite", "libc.so.6") fn(&u8, #C size_t, #C size_t, &u8) #C size_t;
-
-stdout_fwrite ::= fn(data: &u8, size: u64, nmemb: u64) {
- c_fwrite(data, size as c_size_t, nmemb as c_size_t, #builtin("stdout"));
-};
-
-puts ::= fn(x: []char) {
- stdout_fwrite(&x[0] as &u8, 1, x.len as u64);
- toc_putchar('\n');
-};
-
-puti ::= fn(x: int) {
- if x < 0 {
- toc_putchar('-');
- // NOTE: don't do x = -x; here to make sure I64_MIN works
- }
- if x == 0 {
- toc_putchar('0');
- } else {
- abs ::= fn(x: int) int { if x < 0 { -x } else { x } };
- scan_digit := 1000000000000000000;
- started := false;
- while scan_digit > 0 {
- digit := abs((x / scan_digit) % 10);
- if digit > 0 { started = true; }
- if started {
- toc_putchar((('0' as int) + digit) as char);
- }
- scan_digit /= 10;
- }
- }
- toc_putchar('\n');
-};
diff --git a/tests/nms/nms.toc b/tests/nms/nms.toc
deleted file mode 100644
index 413da8d..0000000
--- a/tests/nms/nms.toc
+++ /dev/null
@@ -1,20 +0,0 @@
-io ::= nms {
- #include "io.toc";
-};
-
-n ::= nms {
- x := 1;
- counter ::= fn() int { x += 1; x };
-};
-
-
-main ::= fn() {
- a := n.counter();
- b := n.counter();
- n.counter();
- c := n.counter();
- io.puts("Hello!");
- io.puti(a);
- io.puti(b);
- io.puti(c);
-};
diff --git a/tests/nms/test.sh b/tests/nms/test.sh
deleted file mode 100755
index 8f1a481..0000000
--- a/tests/nms/test.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-./nms.bin > got || exit 1
-diff got expected || exit 1