mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
test: change sumtype var shadow and as test
This commit is contained in:
parent
3533335804
commit
198fdcf1c6
@ -3,12 +3,13 @@ struct Dog{name string}
|
|||||||
|
|
||||||
type Animal = Cat | Dog
|
type Animal = Cat | Dog
|
||||||
|
|
||||||
fn main() {
|
const (
|
||||||
cat := Cat{name: 'cat'}
|
cat = Cat{name: 'cat'}
|
||||||
dog := Cat{name: 'dog'}
|
dog = Cat{name: 'dog'}
|
||||||
|
)
|
||||||
|
|
||||||
|
fn test_shadow() {
|
||||||
mut animal := Animal{}
|
mut animal := Animal{}
|
||||||
|
|
||||||
// test shaddow
|
|
||||||
animal = cat
|
animal = cat
|
||||||
match animal {
|
match animal {
|
||||||
Cat {
|
Cat {
|
||||||
@ -18,7 +19,10 @@ fn main() {
|
|||||||
assert false
|
assert false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// test as
|
}
|
||||||
|
|
||||||
|
fn test_as() {
|
||||||
|
mut animal := Animal{}
|
||||||
animal = dog
|
animal = dog
|
||||||
match animal as animal_kind {
|
match animal as animal_kind {
|
||||||
Dog {
|
Dog {
|
||||||
@ -28,4 +32,4 @@ fn main() {
|
|||||||
assert false
|
assert false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user