Skip to content

Commit

Permalink
Fix few UPLC tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Aug 27, 2024
1 parent ce36474 commit 549df5f
Showing 1 changed file with 39 additions and 21 deletions.
60 changes: 39 additions & 21 deletions crates/aiken-project/src/tests/gen_uplc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ fn assert_uplc(source_code: &str, expected: Term<Name>, should_fail: bool) {
term: expected,
};

let expected = optimize::aiken_optimize_and_intern(expected);

let pretty_expected = expected.to_pretty();

let expected = optimize::aiken_optimize_and_intern(expected);

let expected: Program<DeBruijn> = expected.try_into().unwrap();

assert!(
Expand Down Expand Up @@ -1598,7 +1598,7 @@ fn acceptance_test_15_zero_arg() {
inner: List<Pair<key, value>>,
}
pub fn new() {
fn new() {
Pairs { inner: [] }
}
Expand All @@ -1607,6 +1607,29 @@ fn acceptance_test_15_zero_arg() {
}
"#;

assert_uplc(
src,
Term::equals_data()
.apply(Term::map_data().apply(Term::empty_map()))
.apply(Term::Constant(Constant::Data(Data::map(vec![])).into())),
false,
);
}

#[test]
fn acceptance_test_15_zero_arg_as_const() {
let src = r#"
pub opaque type Pairs<key, value> {
inner: List<Pair<key, value>>,
}
const new = Pairs { inner: [] }
test new_1() {
new == Pairs { inner: [] }
}
"#;

assert_uplc(
src,
Term::equals_data()
Expand Down Expand Up @@ -4518,15 +4541,13 @@ fn list_fields_unwrap() {
b: Int,
}
fn data_fields(){
[
Fields{a: #"", b: 14},
Fields{a: #"AA", b: 0}
]
}
const data_fields = [
Fields{a: #"", b: 14},
Fields{a: #"AA", b: 0}
]
test list_fields_unwr_0() {
when data_fields() is {
when data_fields is {
[Fields { b, .. }, ..] ->
b > 0
_ ->
Expand Down Expand Up @@ -5442,6 +5463,14 @@ fn list_clause_with_assign() {
#[test]
fn opaque_value_in_test() {
let src = r#"
const dat: Dat = {
let v = Value { inner: Dict { inner: [Pair("", [Pair(#"aa", 4)] |> Dict)] } }
Dat {
c: 0,
a: v
}
}
pub opaque type Value {
inner: Dict<Dict<Int>>
}
Expand All @@ -5455,18 +5484,7 @@ fn opaque_value_in_test() {
a: Value
}
pub fn dat_new() -> Dat {
let v = Value { inner: Dict { inner: [Pair("", [Pair(#"aa", 4)] |> Dict)] } }
Dat {
c: 0,
a: v
}
}
test spend() {
let dat = dat_new()
let val = dat.a
expect [Pair(_, amount)] = val.inner.inner
Expand Down

0 comments on commit 549df5f

Please sign in to comment.