chore: add acceptance tests for if/is
This commit is contained in:
parent
579abb7d3d
commit
7da35d5d73
|
@ -0,0 +1,7 @@
|
|||
# This file was generated by Aiken
|
||||
# You typically do not need to edit this file
|
||||
|
||||
requirements = []
|
||||
packages = []
|
||||
|
||||
[etags]
|
|
@ -0,0 +1,9 @@
|
|||
name = "aiken-lang/105"
|
||||
version = "0.0.0"
|
||||
license = "Apache-2.0"
|
||||
description = "Aiken contracts for project 'aiken-lang/102'"
|
||||
|
||||
[repository]
|
||||
user = "aiken-lang"
|
||||
project = "105"
|
||||
platform = "github"
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue