chore: add acceptance tests for if/is
This commit is contained in:
45
examples/acceptance_tests/105/lib/tests.ak
Normal file
45
examples/acceptance_tests/105/lib/tests.ak
Normal file
@@ -0,0 +1,45 @@
|
||||
pub type Foo {
|
||||
a: Int,
|
||||
}
|
||||
|
||||
pub type Bar {
|
||||
Bazz(Int)
|
||||
Buzz(Int)
|
||||
}
|
||||
|
||||
test if_soft_cast() {
|
||||
let d: Data = Foo { a: 1 }
|
||||
|
||||
if d is Foo {
|
||||
d.a == 1
|
||||
} else {
|
||||
False
|
||||
}
|
||||
}
|
||||
|
||||
test if_soft_cast_2() {
|
||||
let d: Data = Bazz(1)
|
||||
|
||||
if d is Foo {
|
||||
d.a == 1
|
||||
} else if d is Bazz(y): Bar {
|
||||
y == 1
|
||||
} else {
|
||||
False
|
||||
}
|
||||
}
|
||||
|
||||
test if_soft_cast_3() {
|
||||
let d: Data = Bazz(1)
|
||||
let x: Data = Buzz(2)
|
||||
|
||||
if d is Foo {
|
||||
d.a == 1
|
||||
} else if d is Bazz(y): Bar {
|
||||
y == 1
|
||||
} else if x is Buzz(y): Bar {
|
||||
y == 2
|
||||
} else {
|
||||
False
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user