Small test
authorJudah Caruso <judah@tuta.io>
Fri, 8 Dec 2023 01:22:51 +0000 (18:22 -0700)
committerJudah Caruso <judah@tuta.io>
Fri, 8 Dec 2023 01:22:51 +0000 (18:22 -0700)
tests/where_clauses [new file with mode: 0644]
tests/where_clauses.onyx [new file with mode: 0644]

diff --git a/tests/where_clauses b/tests/where_clauses
new file mode 100644 (file)
index 0000000..3425f5c
--- /dev/null
@@ -0,0 +1 @@
+[ 2.0000, 4.0000, 6.0000, 8.0000 ]
diff --git a/tests/where_clauses.onyx b/tests/where_clauses.onyx
new file mode 100644 (file)
index 0000000..2d8f56c
--- /dev/null
@@ -0,0 +1,33 @@
+#load "core/module"
+
+use core {*};
+
+main :: () {
+   a := f32.[ 1, 2, 3, 4 ];
+   b := f32.[ 1, 2, 3, 4 ];
+   c := add(a, b);
+   println(c);
+
+   d: Foo(typeof c);
+   d.values = c;
+}
+
+Adder :: interface(t: $T) {
+   { t + t } -> T;
+}
+
+add :: (a, b: [$N]$T) -> [N]T
+   where Adder(T), N > 0, N <= 4
+{
+   return a + b;
+}
+
+CanBeIndexed :: interface(t: $T) {
+   t[0];
+}
+
+Foo :: struct (T: type_expr) where CanBeIndexed(T) {
+   values: T;
+}
+
+