Add no_function feature to disable script-defined functions.

This commit is contained in:
Stephen Chung
2020-03-11 13:28:12 +08:00
parent 047f064cd1
commit 7c4d22d98a
10 changed files with 140 additions and 86 deletions

View File

@@ -39,10 +39,9 @@ fn test_bool_op_short_circuit() -> Result<(), EvalAltResult> {
assert_eq!(
engine.eval::<bool>(
r"
fn this() { true }
fn that() { 9/0 }
let this = true;
this() || that();
this || { throw; };
"
)?,
true
@@ -51,10 +50,9 @@ fn test_bool_op_short_circuit() -> Result<(), EvalAltResult> {
assert_eq!(
engine.eval::<bool>(
r"
fn this() { false }
fn that() { 9/0 }
let this = false;
this() && that();
this && { throw; };
"
)?,
false
@@ -72,10 +70,9 @@ fn test_bool_op_no_short_circuit1() {
engine
.eval::<bool>(
r"
fn this() { false }
fn that() { 9/0 }
let this = true;
this() | that();
this | { throw; }
"
)
.unwrap(),
@@ -92,10 +89,9 @@ fn test_bool_op_no_short_circuit2() {
engine
.eval::<bool>(
r"
fn this() { false }
fn that() { 9/0 }
let this = false;
this() & that();
this & { throw; }
"
)
.unwrap(),