`Evaluation::new_impure()` would require the test to be impure, but there's nothing in this test specifically requiring us to make use of impure features. Change-Id: Idb24981195d1a94f51053ae04403eb5f0e27f3d9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11725 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: Connor Brewster <cbrewster@hey.com>
36 lines
890 B
Rust
36 lines
890 B
Rust
use crate::*;
|
|
|
|
#[test]
|
|
fn test_source_builtin() {
|
|
// Test an evaluation with a source-only builtin. The test ensures
|
|
// that the artificially constructed thunking is correct.
|
|
|
|
let mut eval = Evaluation::new_pure();
|
|
eval.src_builtins.push(("testSourceBuiltin", "42"));
|
|
|
|
let result = eval.evaluate("builtins.testSourceBuiltin", None);
|
|
assert!(
|
|
result.errors.is_empty(),
|
|
"evaluation failed: {:?}",
|
|
result.errors
|
|
);
|
|
|
|
let value = result.value.unwrap();
|
|
assert!(
|
|
matches!(value, Value::Integer(42)),
|
|
"expected the integer 42, but got {}",
|
|
value,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn skip_broken_bytecode() {
|
|
let result = Evaluation::new_pure().evaluate(/* code = */ "x", None);
|
|
|
|
assert_eq!(result.errors.len(), 1);
|
|
|
|
assert!(matches!(
|
|
result.errors[0].kind,
|
|
ErrorKind::UnknownStaticVariable
|
|
));
|
|
}
|