From: Judah Caruso Date: Fri, 8 Dec 2023 01:22:51 +0000 (-0700) Subject: Small test X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=94c96d199edc89f7303299bf6c28d9a37a0c7fc3;p=onyx.git Small test --- diff --git a/tests/where_clauses b/tests/where_clauses new file mode 100644 index 00000000..3425f5c4 --- /dev/null +++ b/tests/where_clauses @@ -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 index 00000000..2d8f56c9 --- /dev/null +++ b/tests/where_clauses.onyx @@ -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; +} + +