Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Oct 12, 2024
1 parent ff3b50e commit 4c4e209
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions vlib/v/tests/options/option_unwrap_ifexpr_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
type TestSmart = ?string | int

fn test_simple_case() {
o := ?string('abc')
dump(o)
a := if o == none {
'none'
} else {
'${o} exists'
}
dump(a)
assert a == 'abc exists'
}

fn test_comptime_smartcast() {
t := TestSmart(?string('foobar'))
$for v in TestSmart.variants {
if t is v {
$if t is ?string {
if t == none {
panic('error')
} else {
assert t == 'foobar'
}
}
}
}
}

0 comments on commit 4c4e209

Please sign in to comment.