Use const instead of zero-arg functions in few code-gen tests.
This commit is contained in:
parent
ef89691331
commit
a06383d333
|
@ -1101,13 +1101,11 @@ impl TypeVar {
|
||||||
Self::Link { tipo } => tipo.get_inner_types(),
|
Self::Link { tipo } => tipo.get_inner_types(),
|
||||||
Self::Unbound { .. } => vec![],
|
Self::Unbound { .. } => vec![],
|
||||||
var => {
|
var => {
|
||||||
vec![
|
vec![Type::Var {
|
||||||
Type::Var {
|
|
||||||
tipo: RefCell::new(var.clone()).into(),
|
tipo: RefCell::new(var.clone()).into(),
|
||||||
alias: None,
|
alias: None,
|
||||||
}
|
}
|
||||||
.into(),
|
.into()]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,14 +242,13 @@ mod test {
|
||||||
}
|
}
|
||||||
"#});
|
"#});
|
||||||
|
|
||||||
assert!(
|
assert!(prop
|
||||||
prop.run::<()>(
|
.run::<()>(
|
||||||
42,
|
42,
|
||||||
PropertyTest::DEFAULT_MAX_SUCCESS,
|
PropertyTest::DEFAULT_MAX_SUCCESS,
|
||||||
&PlutusVersion::default()
|
&PlutusVersion::default()
|
||||||
)
|
)
|
||||||
.is_success()
|
.is_success());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -3099,9 +3099,7 @@ fn acceptance_test_29_union_pair() {
|
||||||
inner: Pairs<key, value>,
|
inner: Pairs<key, value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new() -> AssocList<key, value> {
|
const empty_list: AssocList<key, value> = AssocList { inner: [] }
|
||||||
AssocList { inner: [] }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_list(xs: Pairs<key, value>) -> AssocList<key, value> {
|
pub fn from_list(xs: Pairs<key, value>) -> AssocList<key, value> {
|
||||||
AssocList { inner: do_from_list(xs) }
|
AssocList { inner: do_from_list(xs) }
|
||||||
|
@ -3156,14 +3154,14 @@ fn acceptance_test_29_union_pair() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fixture_1() {
|
const fixture_1 = {
|
||||||
new()
|
empty_list
|
||||||
|> insert("foo", 42)
|
|> insert("foo", 42)
|
||||||
|> insert("bar", 14)
|
|> insert("bar", 14)
|
||||||
}
|
}
|
||||||
|
|
||||||
test union_1() {
|
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("k")
|
||||||
.lambda("m");
|
.lambda("m");
|
||||||
|
|
||||||
let fixture = Term::var("insert")
|
let empty_list = Term::empty_map();
|
||||||
.apply(
|
|
||||||
Term::var("insert")
|
let fixture = Term::data(Data::map(vec![
|
||||||
.apply(Term::var("new").force())
|
(
|
||||||
.apply(Term::byte_string("foo".as_bytes().to_vec()))
|
Data::bytestring(vec![0x66, 0x6f, 0x6f]),
|
||||||
.apply(Term::integer(42.into())),
|
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()))
|
.into(),
|
||||||
.apply(Term::integer(14.into()))
|
);
|
||||||
.delay();
|
|
||||||
|
|
||||||
let do_union = Term::var("left")
|
let do_union = Term::var("left")
|
||||||
.delayed_choose_list(
|
.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::map_data().apply(do_union.as_var("do_union", |do_union| {
|
||||||
Term::Var(do_union.clone())
|
Term::Var(do_union.clone())
|
||||||
.apply(Term::Var(do_union))
|
.apply(Term::Var(do_union))
|
||||||
.apply(Term::var("fixture").force())
|
.apply(fixture_unwrapped)
|
||||||
.apply(Term::var("new").force())
|
.apply(empty_list)
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.apply(Term::map_data().apply(Term::var("fixture").force()))
|
|
||||||
.lambda("fixture")
|
|
||||||
.apply(fixture)
|
.apply(fixture)
|
||||||
.lambda("insert")
|
.lambda("insert")
|
||||||
.apply(insert)
|
.apply(insert)
|
||||||
.lambda("new")
|
|
||||||
.apply(Term::empty_map().delay())
|
|
||||||
.lambda("do_insert")
|
.lambda("do_insert")
|
||||||
.apply(do_insert_recurse),
|
.apply(do_insert_recurse),
|
||||||
false,
|
false,
|
||||||
|
@ -3319,9 +3336,7 @@ fn acceptance_test_29_union_tuple() {
|
||||||
inner: List<(key, value)>,
|
inner: List<(key, value)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new() -> AssocList<key, value> {
|
const empty_list = AssocList { inner: [] }
|
||||||
AssocList { inner: [] }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_list(xs: List<(key, value)>) -> AssocList<key, value> {
|
pub fn from_list(xs: List<(key, value)>) -> AssocList<key, value> {
|
||||||
AssocList { inner: do_from_list(xs) }
|
AssocList { inner: do_from_list(xs) }
|
||||||
|
@ -3376,14 +3391,14 @@ fn acceptance_test_29_union_tuple() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fixture_1() {
|
const fixture_1 = {
|
||||||
new()
|
empty_list
|
||||||
|> insert("foo", 42)
|
|> insert("foo", 42)
|
||||||
|> insert("bar", 14)
|
|> insert("bar", 14)
|
||||||
}
|
}
|
||||||
|
|
||||||
test union_1() {
|
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]
|
#[test]
|
||||||
fn opaque_value_in_test() {
|
fn opaque_value_in_test() {
|
||||||
let src = r#"
|
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 {
|
pub opaque type Value {
|
||||||
inner: Dict<Dict<Int>>
|
inner: Dict<Dict<Int>>
|
||||||
}
|
}
|
||||||
|
@ -5524,18 +5547,7 @@ fn opaque_value_in_test() {
|
||||||
a: Value
|
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() {
|
test spend() {
|
||||||
let dat = dat_new()
|
|
||||||
|
|
||||||
let val = dat.a
|
let val = dat.a
|
||||||
|
|
||||||
expect [Pair(_, amount)] = val.inner.inner
|
expect [Pair(_, amount)] = val.inner.inner
|
||||||
|
|
Loading…
Reference in New Issue