Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Dec 29, 2024
1 parent a4c2a38 commit ffea8f6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions vlib/v/tests/generics/generic_as_cast_on_map_test.v
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit ffea8f6

Please sign in to comment.