Add test for literal operations.
This commit is contained in:
parent
d15470fd4b
commit
efd57c600b
@ -29,6 +29,38 @@ fn test_max_operations() -> Result<(), Box<EvalAltResult>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_max_operations_literal() -> Result<(), Box<EvalAltResult>> {
|
||||
let mut engine = Engine::new();
|
||||
#[cfg(not(feature = "no_optimize"))]
|
||||
engine.set_optimization_level(rhai::OptimizationLevel::None);
|
||||
engine.set_max_operations(10);
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
engine.run("[1, 2, 3, 4, 5, 6, 7]")?;
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
assert!(matches!(
|
||||
*engine
|
||||
.run("[1, 2, 3, 4, 5, 6, 7, 8, 9]")
|
||||
.expect_err("should error"),
|
||||
EvalAltResult::ErrorTooManyOperations(_)
|
||||
));
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
engine.run("#{a:1, b:2, c:3, d:4, e:5, f:6, g:7}")?;
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
assert!(matches!(
|
||||
*engine
|
||||
.run("#{a:1, b:2, c:3, d:4, e:5, f:6, g:7, h:8, i:9}")
|
||||
.expect_err("should error"),
|
||||
EvalAltResult::ErrorTooManyOperations(_)
|
||||
));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_max_operations_functions() -> Result<(), Box<EvalAltResult>> {
|
||||
let mut engine = Engine::new();
|
||||
|
Loading…
Reference in New Issue
Block a user