chore: add acceptance tests for if/is
This commit is contained in:
7
examples/acceptance_tests/105/aiken.lock
Normal file
7
examples/acceptance_tests/105/aiken.lock
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file was generated by Aiken
|
||||
# You typically do not need to edit this file
|
||||
|
||||
requirements = []
|
||||
packages = []
|
||||
|
||||
[etags]
|
||||
9
examples/acceptance_tests/105/aiken.toml
Normal file
9
examples/acceptance_tests/105/aiken.toml
Normal file
@@ -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"
|
||||
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