diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-03-09 19:46:01 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-03-09 19:50:24 +0100 |
| commit | 98f77e4a9aaff56e4a24919932076a4cee2a5598 (patch) | |
| tree | 9adb84aa069a6d8994e106ced7a8b83217f6a971 /progs/tests/tuple | |
| parent | 44170a579266501143af63960fda8706df809c09 (diff) | |
| download | sylt-98f77e4a9aaff56e4a24919932076a4cee2a5598.tar.gz | |
move some tests
Diffstat (limited to 'progs/tests/tuple')
| -rw-r--r-- | progs/tests/tuple/add.sy | 3 | ||||
| -rw-r--r-- | progs/tests/tuple/basic.sy | 24 | ||||
| -rw-r--r-- | progs/tests/tuple/fail_invalid_singleton.sy | 7 | ||||
| -rw-r--r-- | progs/tests/tuple/fail_out_of_bounds.sy | 6 | ||||
| -rw-r--r-- | progs/tests/tuple/mul.sy | 3 | ||||
| -rw-r--r-- | progs/tests/tuple/multiple_types.sy | 4 | ||||
| -rw-r--r-- | progs/tests/tuple/sub.sy | 3 | ||||
| -rw-r--r-- | progs/tests/tuple/types.sy | 4 |
8 files changed, 54 insertions, 0 deletions
diff --git a/progs/tests/tuple/add.sy b/progs/tests/tuple/add.sy new file mode 100644 index 0000000..3fadd86 --- /dev/null +++ b/progs/tests/tuple/add.sy @@ -0,0 +1,3 @@ +start :: fn { + (1, 2, 3, 4) + (4, 3, 2, 1) <=> (5, 5, 5, 5) +} diff --git a/progs/tests/tuple/basic.sy b/progs/tests/tuple/basic.sy new file mode 100644 index 0000000..642e381 --- /dev/null +++ b/progs/tests/tuple/basic.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/tuple/fail_invalid_singleton.sy b/progs/tests/tuple/fail_invalid_singleton.sy new file mode 100644 index 0000000..a8fafaa --- /dev/null +++ b/progs/tests/tuple/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/tuple/fail_out_of_bounds.sy b/progs/tests/tuple/fail_out_of_bounds.sy new file mode 100644 index 0000000..cb0764a --- /dev/null +++ b/progs/tests/tuple/fail_out_of_bounds.sy @@ -0,0 +1,6 @@ +start :: fn { + a := (1, 2) + a[2] +} + +// errors: [ErrorKind::IndexOutOfBounds(_, 2, 2)] diff --git a/progs/tests/tuple/mul.sy b/progs/tests/tuple/mul.sy new file mode 100644 index 0000000..4b33314 --- /dev/null +++ b/progs/tests/tuple/mul.sy @@ -0,0 +1,3 @@ +start :: fn { + (0, 1, 2) * (2, 3, 4) <=> (0, 3, 8) +} diff --git a/progs/tests/tuple/multiple_types.sy b/progs/tests/tuple/multiple_types.sy new file mode 100644 index 0000000..c85403a --- /dev/null +++ b/progs/tests/tuple/multiple_types.sy @@ -0,0 +1,4 @@ +start :: fn { + a: (str, bool, int) = ("abc", true, 1) + a +} diff --git a/progs/tests/tuple/sub.sy b/progs/tests/tuple/sub.sy new file mode 100644 index 0000000..e5d60f2 --- /dev/null +++ b/progs/tests/tuple/sub.sy @@ -0,0 +1,3 @@ +start :: fn { + (1, -2, 3, -4) - (4, 3, -2, -1) <=> (-3, 1, 1, -5) +} diff --git a/progs/tests/tuple/types.sy b/progs/tests/tuple/types.sy new file mode 100644 index 0000000..bdcdfa4 --- /dev/null +++ b/progs/tests/tuple/types.sy @@ -0,0 +1,4 @@ +start :: fn { + a: (int, float, int) = (1, 1., 1) + a +} |
