blob: 49ed713fc96cd1b91c7d9a9fad309371633407d2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
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 eval = Evaluation::builder_pure()
.add_src_builtin("testSourceBuiltin", "42")
.build();
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::builder_pure()
.build()
.evaluate(/* code = */ "x", None);
assert_eq!(result.errors.len(), 1);
assert!(matches!(
result.errors[0].kind,
ErrorKind::UnknownStaticVariable
));
}
|