1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/v/tests/if_expr_with_sumtype_map_test.v

23 lines
400 B
V

type ConfigValue = bool | int | string
type ConfigMap = map[string]ConfigValue
fn foo(conf ConfigMap) bool {
mut bar := false
// Check type
bar = if conf['baz'] or { false } is bool {
conf['baz'] or { false } as bool
} else {
false
} // Default value
return bar
}
fn test_if_expr_with_sumtype_map() {
conf := {
'baz': ConfigValue(123)
}
ret := foo(conf)
println(ret)
assert !ret
}