Disallow overriding keywords.
This commit is contained in:
@@ -102,6 +102,14 @@ fn test_closures() -> Result<(), Box<EvalAltResult>> {
|
||||
"#
|
||||
)?);
|
||||
|
||||
assert!(engine.eval::<bool>(
|
||||
r#"
|
||||
let a = 41;
|
||||
let foo = |x| { a += x };
|
||||
is_shared(a)
|
||||
"#
|
||||
)?);
|
||||
|
||||
engine.register_fn("plus_one", |x: INT| x + 1);
|
||||
|
||||
assert_eq!(
|
||||
|
@@ -37,32 +37,6 @@ fn test_constant_scope() -> Result<(), Box<EvalAltResult>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_var_is_def() -> Result<(), Box<EvalAltResult>> {
|
||||
let engine = Engine::new();
|
||||
|
||||
assert!(engine.eval::<bool>(
|
||||
r#"
|
||||
let x = 42;
|
||||
is_def_var("x")
|
||||
"#
|
||||
)?);
|
||||
assert!(!engine.eval::<bool>(
|
||||
r#"
|
||||
let x = 42;
|
||||
is_def_var("y")
|
||||
"#
|
||||
)?);
|
||||
assert!(engine.eval::<bool>(
|
||||
r#"
|
||||
const x = 42;
|
||||
is_def_var("x")
|
||||
"#
|
||||
)?);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
#[test]
|
||||
fn test_constant_mut() -> Result<(), Box<EvalAltResult>> {
|
||||
|
@@ -46,6 +46,9 @@ fn test_type_of() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
assert_eq!(engine.eval::<String>(r#"type_of("hello")"#)?, "string");
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
assert_eq!(engine.eval::<String>(r#""hello".type_of()"#)?, "string");
|
||||
|
||||
#[cfg(not(feature = "only_i32"))]
|
||||
assert_eq!(engine.eval::<String>("let x = 123; type_of(x)")?, "i64");
|
||||
|
||||
|
@@ -19,6 +19,32 @@ fn test_var_scope() -> Result<(), Box<EvalAltResult>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_var_is_def() -> Result<(), Box<EvalAltResult>> {
|
||||
let engine = Engine::new();
|
||||
|
||||
assert!(engine.eval::<bool>(
|
||||
r#"
|
||||
let x = 42;
|
||||
is_def_var("x")
|
||||
"#
|
||||
)?);
|
||||
assert!(!engine.eval::<bool>(
|
||||
r#"
|
||||
let x = 42;
|
||||
is_def_var("y")
|
||||
"#
|
||||
)?);
|
||||
assert!(engine.eval::<bool>(
|
||||
r#"
|
||||
const x = 42;
|
||||
is_def_var("x")
|
||||
"#
|
||||
)?);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_scope_eval() -> Result<(), Box<EvalAltResult>> {
|
||||
let engine = Engine::new();
|
||||
|
Reference in New Issue
Block a user