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:
parent
553eb88d3d
commit
dbef4474fa
|
@ -0,0 +1,5 @@
|
||||||
|
# This file was generated by Aiken
|
||||||
|
# You typically do not need to edit this file
|
||||||
|
|
||||||
|
requirements = []
|
||||||
|
packages = []
|
|
@ -0,0 +1,3 @@
|
||||||
|
name = 'aiken-lang/acceptance_test_065'
|
||||||
|
version = '0.0.0'
|
||||||
|
description = ''
|
|
@ -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
|
||||||
|
}
|
Loading…
Reference in New Issue