Use const instead of zero-arg functions in few code-gen tests.

This commit is contained in:
KtorZ 2024-08-29 16:57:20 +02:00
parent ef89691331
commit a06383d333
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
3 changed files with 58 additions and 49 deletions

View File

@ -1101,13 +1101,11 @@ impl TypeVar {
Self::Link { tipo } => tipo.get_inner_types(),
Self::Unbound { .. } => vec![],
var => {
vec![
Type::Var {
vec![Type::Var {
tipo: RefCell::new(var.clone()).into(),
alias: None,
}
.into(),
]
.into()]
}
}
}

View File

@ -242,14 +242,13 @@ mod test {
}
"#});
assert!(
prop.run::<()>(
assert!(prop
.run::<()>(
42,
PropertyTest::DEFAULT_MAX_SUCCESS,
&PlutusVersion::default()
)
.is_success()
);
.is_success());
}
#[test]

View File

@ -3099,9 +3099,7 @@ fn acceptance_test_29_union_pair() {
inner: Pairs<key, value>,
}
pub fn new() -> AssocList<key, value> {
AssocList { inner: [] }
}
const empty_list: AssocList<key, value> = AssocList { inner: [] }
pub fn from_list(xs: Pairs<key, value>) -> AssocList<key, value> {
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<key, value> {
AssocList { inner: [] }
}
const empty_list = AssocList { inner: [] }
pub fn from_list(xs: List<(key, value)>) -> AssocList<key, value> {
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<Dict<Int>>
}
@ -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