summaryrefslogtreecommitdiff
path: root/tests/params
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-01-24 22:50:50 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-01-24 22:50:50 -0500
commita8e52c1e13a6cea5cf4197393002c0da206a99d4 (patch)
treeea2f0d314e6d92dd71649de99020cb24bef9bc73 /tests/params
parent56464a272cac9e3dfa7d4c702faa23155b3d0134 (diff)
fixed return declarations
Diffstat (limited to 'tests/params')
-rw-r--r--tests/params/expected15
-rw-r--r--tests/params/got15
-rw-r--r--tests/params/params.toc37
-rwxr-xr-xtests/params/test.sh3
4 files changed, 70 insertions, 0 deletions
diff --git a/tests/params/expected b/tests/params/expected
new file mode 100644
index 0000000..082b847
--- /dev/null
+++ b/tests/params/expected
@@ -0,0 +1,15 @@
+0
+0
+10
+21
+5
+0
+17
+0
+0
+0
+10
+21
+39
+-13
+-13
diff --git a/tests/params/got b/tests/params/got
new file mode 100644
index 0000000..082b847
--- /dev/null
+++ b/tests/params/got
@@ -0,0 +1,15 @@
+0
+0
+10
+21
+5
+0
+17
+0
+0
+0
+10
+21
+39
+-13
+-13
diff --git a/tests/params/params.toc b/tests/params/params.toc
new file mode 100644
index 0000000..3d8800d
--- /dev/null
+++ b/tests/params/params.toc
@@ -0,0 +1,37 @@
+addmul ::= fn (x:=0, y:=0) add := x+y, mul := x*y {
+};
+
+do_foo ::= fn (x := 3) y := x {
+ y *= 12;
+ y += x;
+};
+
+puti ::= fn(x: int) {
+ #C("extern int printf(const char *fmt, ...)");
+ #C("printf(\"%ld\\n\", x)");
+};
+
+
+main ::= fn() {
+ a, m := addmul();
+ puti(a); puti(m);
+ a, m = addmul(7,3);
+ puti(a); puti(m);
+ a, m = addmul(5);
+ puti(a); puti(m);
+ a, m = addmul(y = 17);
+ puti(a); puti(m);
+
+ c, d ::= addmul();
+ puti(c); puti(d);
+ e, f ::= addmul(y = 3, x = 7);
+ puti(e); puti(f);
+
+
+ z := do_foo();
+ puti(z);
+ z = do_foo(-1);
+ puti(z);
+ z = do_foo(x = -1);
+ puti(z);
+}; \ No newline at end of file
diff --git a/tests/params/test.sh b/tests/params/test.sh
new file mode 100755
index 0000000..582bdec
--- /dev/null
+++ b/tests/params/test.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+./params.bin > got || exit 1
+diff got expected || exit 1