test: move sumtype int cast test into fn & test var

pull/5703/head
joe-conigliaro 2020-07-06 23:39:51 +10:00
parent 659aa8db3c
commit 9a4d989188
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1
1 changed files with 17 additions and 2 deletions

View File

@ -133,7 +133,6 @@ type Abc = int | string
fn test_string_cast_to_sumtype() {
a := Abc('test')
b := Abc(111)
match a {
int {
assert false
@ -142,6 +141,22 @@ fn test_string_cast_to_sumtype() {
assert true
}
}
}
fn test_int_cast_to_sumtype() {
// literal
a := Abc(111)
match a {
int {
assert true
}
string {
assert false
}
}
// var
i := 111
b := Abc(i)
match b {
int {
assert true