From 5c44bd05e80b5ce8d570bfafbf2c46335fda272c Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sat, 12 Mar 2022 20:44:57 -0600 Subject: [PATCH] added auto_poly test --- tests/auto_poly | 15 ++++++++++++++ tests/auto_poly.onyx | 49 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 tests/auto_poly create mode 100644 tests/auto_poly.onyx diff --git a/tests/auto_poly b/tests/auto_poly new file mode 100644 index 00000000..71f55b28 --- /dev/null +++ b/tests/auto_poly @@ -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 index 00000000..84de9c4e --- /dev/null +++ b/tests/auto_poly.onyx @@ -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); + } +} -- 2.25.1