Add new acceptance scenario: 065
-> The provided Plutus code called 'error'. This scenario _could_ work if `choose_data` was lazy in its arguments. Which is a reasonable thing to expect from `choose_data`. Since we don't have any way to introduce on-demand lazyness in the language (and we are not looking for ways), we need to make a special case for `choose_data` which is a perfect (and singular) use case for it.
This commit is contained in:
49
examples/acceptance_tests/065/lib/tests.ak
Normal file
49
examples/acceptance_tests/065/lib/tests.ak
Normal file
@@ -0,0 +1,49 @@
|
||||
use aiken/builtin
|
||||
|
||||
type MyData {
|
||||
Integer(Int)
|
||||
Bytes(ByteArray)
|
||||
}
|
||||
|
||||
test foo() {
|
||||
inspect(42) == Integer(42) && inspect(#"ff") == Bytes(#"ff")
|
||||
}
|
||||
|
||||
fn inspect(data: Data) -> MyData {
|
||||
expect result: MyData =
|
||||
builtin.choose_data(
|
||||
data,
|
||||
inspect_constr(data),
|
||||
inspect_map(data),
|
||||
inspect_list(data),
|
||||
inspect_integer(data),
|
||||
inspect_bytearray(data),
|
||||
)
|
||||
result
|
||||
}
|
||||
|
||||
fn inspect_constr(_data: Data) -> Data {
|
||||
todo
|
||||
}
|
||||
|
||||
fn inspect_map(_data: Data) -> Data {
|
||||
todo
|
||||
}
|
||||
|
||||
fn inspect_list(_data: Data) -> Data {
|
||||
todo
|
||||
}
|
||||
|
||||
fn inspect_integer(data: Data) -> Data {
|
||||
let result: Data =
|
||||
builtin.un_i_data(data)
|
||||
|> Integer
|
||||
result
|
||||
}
|
||||
|
||||
fn inspect_bytearray(data: Data) -> Data {
|
||||
let result: Data =
|
||||
builtin.un_b_data(data)
|
||||
|> Bytes
|
||||
result
|
||||
}
|
||||
Reference in New Issue
Block a user