Skip to content

Commit

Permalink
Conformance tests should be using NamedDebruijn comparisons not name.…
Browse files Browse the repository at this point in the history
… Also no inline remover needs to run separately from other uplc transformations
  • Loading branch information
MicroProofs committed Jan 10, 2025
1 parent 011ec1b commit 199ec56
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
24 changes: 16 additions & 8 deletions crates/uplc/src/optimize/shrinker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2168,19 +2168,27 @@ impl Program<Name> {
inline_lambda: bool,
with: &mut impl FnMut(Option<usize>, &mut Term<Name>, Vec<Args>, &Scope, &mut Context),
) -> Self {
self.traverse_uplc_with(inline_lambda, &mut |id, term, arg_stack, scope, context| {
with(id, term, arg_stack, scope, context);
term.flip_constants(id, vec![], scope, context);
let (mut program, context) =
self.traverse_uplc_with(inline_lambda, &mut |id, term, arg_stack, scope, context| {
with(id, term, arg_stack, scope, context);
term.flip_constants(id, vec![], scope, context);
term.remove_inlined_ids(id, vec![], scope, context);
});

term.remove_inlined_ids(id, vec![], scope, context);
})
.0
if context.write_bits_convert {
program.term = program.term.data_list_to_integer_list();
}

program
}

pub fn clean_up(self, case: bool) -> Self {
let (mut program, context) =
self.traverse_uplc_with(true, &mut |id, term, arg_stack, scope, context| {
let (mut program, context) = self
.traverse_uplc_with(true, &mut |id, term, _arg_stack, scope, context| {
term.remove_no_inlines(id, vec![], scope, context);
})
.0
.traverse_uplc_with(true, &mut |id, term, arg_stack, scope, context| {
term.write_bits_convert_arg(id, arg_stack, scope, context);

if case {
Expand Down
7 changes: 4 additions & 3 deletions crates/uplc/tests/conformance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ peg::parser! {
fn actual_evaluation_result(
file: &Path,
language: &Language,
) -> Result<(Program<Name>, ExBudget), String> {
) -> Result<(Program<NamedDeBruijn>, ExBudget), String> {
let code = fs::read_to_string(file).expect("Failed to read .uplc file");

let program = parser::program(&code).map_err(|_| PARSE_ERROR.to_string())?;
Expand All @@ -68,7 +68,7 @@ fn actual_evaluation_result(

let program = Program { version, term };

Ok((program.try_into().unwrap(), cost))
Ok((program, cost))
}

fn plutus_conformance_tests(language: Language) {
Expand All @@ -89,7 +89,8 @@ fn plutus_conformance_tests(language: Language) {
let expected_budget_file = path.with_extension("uplc.budget.expected");

let eval = actual_evaluation_result(path, &language);
let expected = expected_to_program(&expected_file);
let expected = expected_to_program(&expected_file)
.map(|program| Program::<NamedDeBruijn>::try_from(program).unwrap());

match eval {
Ok((actual, cost)) => {
Expand Down

0 comments on commit 199ec56

Please sign in to comment.