Fix: Change type map length assert to check for greater than equals instead of equals to argument length

This commit is contained in:
microproofs 2023-08-29 21:59:15 -04:00
parent d01766d735
commit baa6917af5
2 changed files with 32 additions and 1 deletions

View File

@ -951,7 +951,7 @@ impl<'a> CodeGenerator<'a> {
type_map.insert(index, field_type); type_map.insert(index, field_type);
} }
assert!(type_map.len() == arguments.len()); assert!(type_map.len() >= arguments.len());
let fields = arguments let fields = arguments
.iter() .iter()

View File

@ -5342,3 +5342,34 @@ fn opaque_value_in_test() {
false, false,
); );
} }
#[test]
fn expect_none() {
let src = r#"
test exp_none() {
let x = None
expect None = x
True
}
"#;
assert_uplc(
src,
Term::equals_integer()
.apply(Term::integer(1.into()))
.apply(Term::var(CONSTR_INDEX_EXPOSER).apply(Term::var("x")))
.delayed_if_else(
Term::bool(true),
Term::Error.trace(Term::string("Expected on incorrect constructor variant.")),
)
.lambda("x")
.apply(Term::Constant(
Constant::Data(Data::constr(1, vec![])).into(),
))
.constr_get_field()
.constr_index_exposer()
.constr_fields_exposer(),
false,
);
}