From ffea8f6aa9bafd2af6751c3cf16a974b6be491a2 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sat, 28 Dec 2024 23:23:57 -0300 Subject: [PATCH] test --- .../v/tests/generics/generic_as_cast_on_map_test.v | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 vlib/v/tests/generics/generic_as_cast_on_map_test.v diff --git a/vlib/v/tests/generics/generic_as_cast_on_map_test.v b/vlib/v/tests/generics/generic_as_cast_on_map_test.v new file mode 100644 index 00000000000000..15393be045f806 --- /dev/null +++ b/vlib/v/tests/generics/generic_as_cast_on_map_test.v @@ -0,0 +1,14 @@ +type Sumtype = string | int + +fn generic_fn[T](x Sumtype) bool { + y := [x].map(it as T) + mut arr := []T{} + arr << x as T + dump(arr) + return arr.contains(y[0]) +} + +fn test_main() { + assert generic_fn[string]('hello') + assert generic_fn[int](123) +}