feat(tests): implement a way to express that tests can fail
This commit is contained in:
@@ -670,7 +670,12 @@ where
|
||||
let mut programs = Vec::new();
|
||||
|
||||
for (input_path, module_name, func_def) in scripts {
|
||||
let Function { name, body, .. } = func_def;
|
||||
let Function {
|
||||
name,
|
||||
body,
|
||||
can_error,
|
||||
..
|
||||
} = func_def;
|
||||
|
||||
if verbose {
|
||||
self.event_listener.handle_event(Event::GeneratingUPLCFor {
|
||||
@@ -711,6 +716,7 @@ where
|
||||
input_path,
|
||||
module_name,
|
||||
name.to_string(),
|
||||
*can_error,
|
||||
program.try_into().unwrap(),
|
||||
evaluation_hint,
|
||||
);
|
||||
@@ -737,7 +743,7 @@ where
|
||||
let mut eval_result = script.program.clone().eval(initial_budget);
|
||||
|
||||
EvalInfo {
|
||||
success: !eval_result.failed(),
|
||||
success: !eval_result.failed(script.can_error),
|
||||
script,
|
||||
spent_budget: eval_result.cost(),
|
||||
logs: eval_result.logs(),
|
||||
|
||||
@@ -8,6 +8,7 @@ pub struct Script {
|
||||
pub input_path: PathBuf,
|
||||
pub module: String,
|
||||
pub name: String,
|
||||
pub can_error: bool,
|
||||
pub program: Program<NamedDeBruijn>,
|
||||
pub evaluation_hint: Option<EvalHint>,
|
||||
}
|
||||
@@ -19,6 +20,7 @@ impl Script {
|
||||
input_path: PathBuf,
|
||||
module: String,
|
||||
name: String,
|
||||
can_error: bool,
|
||||
program: Program<NamedDeBruijn>,
|
||||
evaluation_hint: Option<EvalHint>,
|
||||
) -> Script {
|
||||
@@ -27,6 +29,7 @@ impl Script {
|
||||
module,
|
||||
name,
|
||||
program,
|
||||
can_error,
|
||||
evaluation_hint,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ fn assert_uplc(source_code: &str, expected: Term<Name>, should_fail: bool) {
|
||||
let mut eval = debruijn_program.eval(ExBudget::default());
|
||||
|
||||
assert_eq!(
|
||||
eval.failed(),
|
||||
eval.failed(false),
|
||||
should_fail,
|
||||
"logs - {}\n",
|
||||
format!("{:#?}", eval.logs())
|
||||
|
||||
Reference in New Issue
Block a user