diff --git a/crates/aiken-lang/src/tipo.rs b/crates/aiken-lang/src/tipo.rs index 3ea349e1..fc3e2e0c 100644 --- a/crates/aiken-lang/src/tipo.rs +++ b/crates/aiken-lang/src/tipo.rs @@ -1101,13 +1101,11 @@ impl TypeVar { Self::Link { tipo } => tipo.get_inner_types(), Self::Unbound { .. } => vec![], var => { - vec![ - Type::Var { - tipo: RefCell::new(var.clone()).into(), - alias: None, - } - .into(), - ] + vec![Type::Var { + tipo: RefCell::new(var.clone()).into(), + alias: None, + } + .into()] } } } diff --git a/crates/aiken-project/src/test_framework.rs b/crates/aiken-project/src/test_framework.rs index c3ca0303..6c86e651 100644 --- a/crates/aiken-project/src/test_framework.rs +++ b/crates/aiken-project/src/test_framework.rs @@ -242,14 +242,13 @@ mod test { } "#}); - assert!( - prop.run::<()>( + assert!(prop + .run::<()>( 42, PropertyTest::DEFAULT_MAX_SUCCESS, &PlutusVersion::default() ) - .is_success() - ); + .is_success()); } #[test] diff --git a/crates/aiken-project/src/tests/gen_uplc.rs b/crates/aiken-project/src/tests/gen_uplc.rs index cc8dae7c..352e398d 100644 --- a/crates/aiken-project/src/tests/gen_uplc.rs +++ b/crates/aiken-project/src/tests/gen_uplc.rs @@ -3099,9 +3099,7 @@ fn acceptance_test_29_union_pair() { inner: Pairs, } - pub fn new() -> AssocList { - AssocList { inner: [] } - } + const empty_list: AssocList = AssocList { inner: [] } pub fn from_list(xs: Pairs) -> AssocList { AssocList { inner: do_from_list(xs) } @@ -3156,14 +3154,14 @@ fn acceptance_test_29_union_pair() { } } - fn fixture_1() { - new() + const fixture_1 = { + empty_list |> insert("foo", 42) |> insert("bar", 14) } test union_1() { - union(fixture_1(), new()) == fixture_1() + union(fixture_1, empty_list) == fixture_1 } "#; @@ -3250,16 +3248,39 @@ fn acceptance_test_29_union_pair() { .lambda("k") .lambda("m"); - let fixture = Term::var("insert") - .apply( - Term::var("insert") - .apply(Term::var("new").force()) - .apply(Term::byte_string("foo".as_bytes().to_vec())) - .apply(Term::integer(42.into())), + let empty_list = Term::empty_map(); + + let fixture = Term::data(Data::map(vec![ + ( + Data::bytestring(vec![0x66, 0x6f, 0x6f]), + Data::integer(42.into()), + ), + ( + Data::bytestring(vec![0x62, 0x61, 0x72]), + Data::integer(14.into()), + ), + ])); + + let fixture_unwrapped = Term::Constant( + Constant::ProtoList( + Type::Pair(Type::Data.into(), Type::Data.into()), + vec![ + Constant::ProtoPair( + Type::Data, + Type::Data, + Constant::Data(Data::bytestring(vec![0x66, 0x6f, 0x6f])).into(), + Constant::Data(Data::integer(42.into())).into(), + ), + Constant::ProtoPair( + Type::Data, + Type::Data, + Constant::Data(Data::bytestring(vec![0x62, 0x61, 0x72])).into(), + Constant::Data(Data::integer(14.into())).into(), + ), + ], ) - .apply(Term::byte_string("bar".as_bytes().to_vec())) - .apply(Term::integer(14.into())) - .delay(); + .into(), + ); let do_union = Term::var("left") .delayed_choose_list( @@ -3295,17 +3316,13 @@ fn acceptance_test_29_union_pair() { Term::map_data().apply(do_union.as_var("do_union", |do_union| { Term::Var(do_union.clone()) .apply(Term::Var(do_union)) - .apply(Term::var("fixture").force()) - .apply(Term::var("new").force()) + .apply(fixture_unwrapped) + .apply(empty_list) })), ) - .apply(Term::map_data().apply(Term::var("fixture").force())) - .lambda("fixture") .apply(fixture) .lambda("insert") .apply(insert) - .lambda("new") - .apply(Term::empty_map().delay()) .lambda("do_insert") .apply(do_insert_recurse), false, @@ -3319,9 +3336,7 @@ fn acceptance_test_29_union_tuple() { inner: List<(key, value)>, } - pub fn new() -> AssocList { - AssocList { inner: [] } - } + const empty_list = AssocList { inner: [] } pub fn from_list(xs: List<(key, value)>) -> AssocList { AssocList { inner: do_from_list(xs) } @@ -3376,14 +3391,14 @@ fn acceptance_test_29_union_tuple() { } } - fn fixture_1() { - new() + const fixture_1 = { + empty_list |> insert("foo", 42) |> insert("bar", 14) } test union_1() { - union(fixture_1(), new()) == fixture_1() + union(fixture_1, empty_list) == fixture_1 } "#; @@ -5511,6 +5526,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> } @@ -5524,18 +5547,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