aboutsummaryrefslogtreecommitdiffstats
path: root/progs/tests
diff options
context:
space:
mode:
Diffstat (limited to 'progs/tests')
-rw-r--r--progs/tests/tuples.sy24
-rw-r--r--progs/tests/tuples_fail_invalid_singleton.sy7
-rw-r--r--progs/tests/tuples_fail_out_of_bounds.sy6
3 files changed, 37 insertions, 0 deletions
diff --git a/progs/tests/tuples.sy b/progs/tests/tuples.sy
new file mode 100644
index 0000000..642e381
--- /dev/null
+++ b/progs/tests/tuples.sy
@@ -0,0 +1,24 @@
+start :: fn {
+ a := (1,2)
+ a[0] <=> 1
+ a[1] <=> 2
+
+ b := (1,)
+ b[0] <=> 1
+
+ empty := ()
+ c := (empty,)
+ c[0] <=> ()
+
+ d := (1,2)
+ d[0] <=> d[0]
+
+ {
+ q := d[2-2]
+ d[d[(5 + 3) * 0]] <=> d[d[(5 + 3) * 0]]
+ w := d[0]
+ q + w
+ q - w
+ q * w
+ }
+}
diff --git a/progs/tests/tuples_fail_invalid_singleton.sy b/progs/tests/tuples_fail_invalid_singleton.sy
new file mode 100644
index 0000000..a8fafaa
--- /dev/null
+++ b/progs/tests/tuples_fail_invalid_singleton.sy
@@ -0,0 +1,7 @@
+start :: fn {
+ a := (,)
+ a
+}
+
+//TODO(gu) See #100
+// errors: [ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _), ErrorKind::SyntaxError(_, _)]
diff --git a/progs/tests/tuples_fail_out_of_bounds.sy b/progs/tests/tuples_fail_out_of_bounds.sy
new file mode 100644
index 0000000..cb0764a
--- /dev/null
+++ b/progs/tests/tuples_fail_out_of_bounds.sy
@@ -0,0 +1,6 @@
+start :: fn {
+ a := (1, 2)
+ a[2]
+}
+
+// errors: [ErrorKind::IndexOutOfBounds(_, 2, 2)]