Add 'eval' command to evaluate target aiken function

Pretty useful for debbugging. Though, on second-thoughts, this is
  something we may want to review later and maybe have that done by
  default for tests.

  At the moment, we expects tests to unify to `bool`, and treat `false`
  values as failing tests. Yet, on failures, this gives little
  information about what's wrong with the test.

  It'd be nice to either have better way to assert in tests, or, to
  simply accept non-bool tests, and show whatever the test evaluates
  to as a debug output.
This commit is contained in:
KtorZ
2022-12-14 00:31:14 +01:00
parent 95df5f9137
commit b6962ba9d3
8 changed files with 176 additions and 70 deletions

View File

@@ -96,7 +96,12 @@ impl<'a> CodeGenerator<'a> {
}
}
pub fn generate(&mut self, body: TypedExpr, arguments: Vec<TypedArg>) -> Program<Name> {
pub fn generate(
&mut self,
body: TypedExpr,
arguments: Vec<TypedArg>,
wrap_as_validator: bool,
) -> Program<Name> {
let mut ir_stack = vec![];
let scope = vec![self.id_gen.next()];
@@ -113,7 +118,11 @@ impl<'a> CodeGenerator<'a> {
}
// Wrap the validator body if ifThenElse term unit error
term = builder::final_wrapper(term);
term = if wrap_as_validator {
builder::final_wrapper(term)
} else {
term
};
for arg in arguments.iter().rev() {
term = Term::Lambda {