test: change sumtype var shadow and as test

pull/5416/head
joe-conigliaro 2020-06-19 01:10:16 +10:00
parent 3533335804
commit 198fdcf1c6
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1
1 changed files with 11 additions and 7 deletions

View File

@ -3,12 +3,13 @@ struct Dog{name string}
type Animal = Cat | Dog
fn main() {
cat := Cat{name: 'cat'}
dog := Cat{name: 'dog'}
const (
cat = Cat{name: 'cat'}
dog = Cat{name: 'dog'}
)
fn test_shadow() {
mut animal := Animal{}
// test shaddow
animal = cat
match animal {
Cat {
@ -18,7 +19,10 @@ fn main() {
assert false
}
}
// test as
}
fn test_as() {
mut animal := Animal{}
animal = dog
match animal as animal_kind {
Dog {
@ -28,4 +32,4 @@ fn main() {
assert false
}
}
}
}