Keyword can no longer be overloaded.

This commit is contained in:
Stephen Chung
2021-03-01 17:17:13 +08:00
parent b7e864bb78
commit fc10df7d63
6 changed files with 79 additions and 183 deletions

View File

@@ -1,4 +1,4 @@
use rhai::{Engine, EvalAltResult, LexError, ParseErrorType, RegisterFn, Scope, INT};
use rhai::{Engine, EvalAltResult, LexError, ParseErrorType, Scope, INT};
#[test]
fn test_eval() -> Result<(), Box<EvalAltResult>> {
@@ -80,32 +80,6 @@ fn test_eval_function() -> Result<(), Box<EvalAltResult>> {
Ok(())
}
#[test]
#[cfg(not(feature = "no_function"))]
fn test_eval_override() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
assert_eq!(
engine.eval::<String>(
r#"
fn eval(x) { x } // reflect the script back
eval("40 + 2")
"#
)?,
"40 + 2"
);
let mut engine = Engine::new();
// Reflect the script back
engine.register_fn("eval", |script: &str| script.to_string());
assert_eq!(engine.eval::<String>(r#"eval("40 + 2")"#)?, "40 + 2");
Ok(())
}
#[test]
fn test_eval_disabled() -> Result<(), Box<EvalAltResult>> {
let mut engine = Engine::new();