chore: convert acceptance test 4
This commit is contained in:
parent
7da3ac2c99
commit
022d557906
|
@ -703,6 +703,107 @@ mod test {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn acceptance_test_4_concat_no_anon_func() {
|
||||
let src = r#"
|
||||
pub fn foldr(xs: List<a>, f: fn(a, b) -> b, zero: b) -> b {
|
||||
when xs is {
|
||||
[] ->
|
||||
zero
|
||||
[x, ..rest] ->
|
||||
f(x, foldr(rest, f, zero))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn prepend(x: a, xs: List<a>) -> List<a> {
|
||||
[x, ..xs]
|
||||
}
|
||||
|
||||
pub fn concat(left: List<a>, right: List<a>) -> List<a> {
|
||||
foldr(left, prepend, right)
|
||||
}
|
||||
|
||||
test concat_1() {
|
||||
concat([1, 2, 3], [4, 5, 6]) == [1, 2, 3, 4, 5, 6]
|
||||
}
|
||||
"#;
|
||||
|
||||
assert_uplc(
|
||||
src,
|
||||
Term::equals_data()
|
||||
.apply(
|
||||
Term::list_data().apply(
|
||||
Term::var("concat")
|
||||
.lambda("concat")
|
||||
.apply(
|
||||
Term::var("foldr")
|
||||
.apply(Term::var("left"))
|
||||
.apply(Term::var("prepend"))
|
||||
.apply(Term::var("right"))
|
||||
.lambda("right")
|
||||
.lambda("left"),
|
||||
)
|
||||
.lambda("prepend")
|
||||
.apply(
|
||||
Term::mk_cons()
|
||||
.apply(Term::i_data().apply(Term::var("x")))
|
||||
.apply(Term::var("xs"))
|
||||
.lambda("xs")
|
||||
.lambda("x"),
|
||||
)
|
||||
.lambda("foldr")
|
||||
.apply(Term::var("foldr").apply(Term::var("foldr")))
|
||||
.lambda("foldr")
|
||||
.apply(
|
||||
Term::var("xs")
|
||||
.delayed_choose_list(
|
||||
Term::var("zero"),
|
||||
Term::var("f")
|
||||
.apply(Term::var("x"))
|
||||
.apply(
|
||||
Term::var("foldr")
|
||||
.apply(Term::var("foldr"))
|
||||
.apply(Term::var("rest"))
|
||||
.apply(Term::var("f"))
|
||||
.apply(Term::var("zero")),
|
||||
)
|
||||
.lambda("rest")
|
||||
.apply(Term::tail_list().apply(Term::var("xs")))
|
||||
.lambda("x")
|
||||
.apply(
|
||||
Term::un_i_data().apply(
|
||||
Term::head_list().apply(Term::var("xs")),
|
||||
),
|
||||
),
|
||||
)
|
||||
.lambda("zero")
|
||||
.lambda("f")
|
||||
.lambda("xs")
|
||||
.lambda("foldr"),
|
||||
)
|
||||
.apply(Term::list_values(vec![
|
||||
Constant::Data(PlutusData::BigInt(BigInt::Int(1.into()))),
|
||||
Constant::Data(PlutusData::BigInt(BigInt::Int(2.into()))),
|
||||
Constant::Data(PlutusData::BigInt(BigInt::Int(3.into()))),
|
||||
]))
|
||||
.apply(Term::list_values(vec![
|
||||
Constant::Data(PlutusData::BigInt(BigInt::Int(4.into()))),
|
||||
Constant::Data(PlutusData::BigInt(BigInt::Int(5.into()))),
|
||||
Constant::Data(PlutusData::BigInt(BigInt::Int(6.into()))),
|
||||
])),
|
||||
),
|
||||
)
|
||||
.apply(Term::list_data().apply(Term::list_values(vec![
|
||||
Constant::Data(PlutusData::BigInt(BigInt::Int(1.into()))),
|
||||
Constant::Data(PlutusData::BigInt(BigInt::Int(2.into()))),
|
||||
Constant::Data(PlutusData::BigInt(BigInt::Int(3.into()))),
|
||||
Constant::Data(PlutusData::BigInt(BigInt::Int(4.into()))),
|
||||
Constant::Data(PlutusData::BigInt(BigInt::Int(5.into()))),
|
||||
Constant::Data(PlutusData::BigInt(BigInt::Int(6.into()))),
|
||||
]))),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mint_parameterized() {
|
||||
assert_validator(
|
||||
|
|
Loading…
Reference in New Issue