Add new acceptance test scenario: 064
- Type mismatch expected 'data' got 'integer' - Type mismatch expected 'data' got 'list data'
This commit is contained in:
30
examples/acceptance_tests/064/lib/tests.ak
Normal file
30
examples/acceptance_tests/064/lib/tests.ak
Normal file
@@ -0,0 +1,30 @@
|
||||
use aiken/builtin
|
||||
|
||||
type Foo {
|
||||
A(Int)
|
||||
B(Int, Int)
|
||||
}
|
||||
|
||||
fn get_constr(data: Data) -> Int {
|
||||
builtin.un_constr_data(data).1st
|
||||
}
|
||||
|
||||
test foo() {
|
||||
get_constr(A(42)) == 0 && get_constr(B(14, 42)) == 1
|
||||
}
|
||||
|
||||
fn map(list: List<a>, f: fn(a) -> b) -> List<b> {
|
||||
when list is {
|
||||
[] -> []
|
||||
[x, ..xs] -> [f(x), ..map(xs, f)]
|
||||
}
|
||||
}
|
||||
|
||||
fn get_fields(data: Data) -> List<Int> {
|
||||
builtin.un_constr_data(data).2nd
|
||||
|> map(builtin.un_i_data)
|
||||
}
|
||||
|
||||
test bar() {
|
||||
get_fields(A(42)) == [42] && get_fields(B(14, 42)) == [14, 42]
|
||||
}
|
||||
Reference in New Issue
Block a user