added auto_poly test
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sun, 13 Mar 2022 02:44:57 +0000 (20:44 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sun, 13 Mar 2022 02:44:57 +0000 (20:44 -0600)
tests/auto_poly [new file with mode: 0644]
tests/auto_poly.onyx [new file with mode: 0644]

diff --git a/tests/auto_poly b/tests/auto_poly
new file mode 100644 (file)
index 0000000..71f55b2
--- /dev/null
@@ -0,0 +1,15 @@
+i32
+i32
+Map(i32, [] u8)
+Vector2(i32) { x = 1, y = 1 }
+i32 to [] u8
+1234
+WOOT WOOT!!!
+type of thing is ^Thing(f32)
+thing is Thing(f32) { value = 0.0000 }
+0
+2
+4
+6
+8
+10
diff --git a/tests/auto_poly.onyx b/tests/auto_poly.onyx
new file mode 100644 (file)
index 0000000..84de9c4
--- /dev/null
@@ -0,0 +1,49 @@
+#load "core/std"
+
+use package core
+
+dumb :: (it: Iterator, m: ^Map) {
+    println(it.Iter_Type);
+    println(__autopoly_var_0);
+    println(typeof *m);
+}
+
+Vector2 :: struct (T: type_expr) {
+    x, y: T;
+}
+
+vec_add :: (v1: Vector2, v2: typeof v1) => (typeof v1).{ v1.x + v2.x, v1.y + v2.y };
+
+mappable :: (k: m.Key_Type, m: ^Map, x: $T) {
+    printf("{} to {}\n", m.Key_Type, m.Value_Type);
+    println(k);
+    println(x);
+}
+
+Thing :: struct (type: type_expr) {
+    value: type;
+}
+
+f :: (thing: ^Thing, other: typeof thing) {
+    printf("type of thing is {}\n", typeof thing);
+    printf("thing is {}\n", *thing);
+}
+
+main :: (args) => {
+    m: Map(i32, str);
+    dumb(iter.as_iterator(1 .. 10), ^m);
+
+    V :: Vector2(i32)
+    v1 := V.{ 1, 0 };
+    v2 := V.{ 0, 1 };
+    println(vec_add(v1, v2));
+
+    mappable(1234, ^m, "WOOT WOOT!!!");
+
+    t: Thing(f32);
+    f(^t, ^t);
+
+    for iter.as_iterator(0 .. 100) |> iter.map(x => x * 2) |> iter.filter(x => x <= 10) {
+        println(it);
+    }
+}