refactor(tvix/eval): remove code and location from struct
Instead, it's passed in the evaluate/compile_only functions, which feels more naturally. It lets us set up the Evaluation struct long before we actually feed it with data to evaluate. Now that Evaluation::new() would be accepting an empty list of arguments, we can simply implement Default, making things a bit more idiomatic. Change-Id: I4369658634909a0c504fdffa18242a130daa0239 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10475 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
parent
a5c5f1a29e
commit
4fba57c2c9
10 changed files with 72 additions and 69 deletions
|
|
@ -53,11 +53,11 @@ fn eval_test(code_path: &str, expect_success: bool) {
|
|||
return;
|
||||
}
|
||||
|
||||
let mut eval = crate::Evaluation::new_impure(&code, Some(code_path.into()));
|
||||
let mut eval = crate::Evaluation::new_impure();
|
||||
eval.strict = true;
|
||||
eval.builtins.extend(mock_builtins::builtins());
|
||||
|
||||
let result = eval.evaluate();
|
||||
let result = eval.evaluate(&code, Some(code_path.into()));
|
||||
let failed = match result.value {
|
||||
Some(Value::Catchable(_)) => true,
|
||||
_ => !result.errors.is_empty(),
|
||||
|
|
@ -106,11 +106,13 @@ fn eval_test(code_path: &str, expect_success: bool) {
|
|||
fn identity(code_path: &str) {
|
||||
let code = std::fs::read_to_string(code_path).expect("should be able to read test code");
|
||||
|
||||
let mut eval = crate::Evaluation::new(&code, None);
|
||||
eval.strict = true;
|
||||
eval.io_handle = Box::new(crate::StdIO);
|
||||
let eval = crate::Evaluation {
|
||||
strict: true,
|
||||
io_handle: Box::new(crate::StdIO),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let result = eval.evaluate();
|
||||
let result = eval.evaluate(&code, None);
|
||||
assert!(
|
||||
result.errors.is_empty(),
|
||||
"evaluation of identity test failed: {:?}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue