Add Dynamic::from(&str)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use rhai::{Engine, EvalAltResult, ImmutableString, RegisterFn, INT};
|
||||
use rhai::{Dynamic, Engine, EvalAltResult, ImmutableString, RegisterFn, Scope, INT};
|
||||
|
||||
#[test]
|
||||
fn test_string() -> Result<(), Box<EvalAltResult>> {
|
||||
@@ -49,6 +49,21 @@ fn test_string() -> Result<(), Box<EvalAltResult>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_string_dynamic() -> Result<(), Box<EvalAltResult>> {
|
||||
let engine = Engine::new();
|
||||
let mut scope = Scope::new();
|
||||
scope.push("x", Dynamic::from("foo"));
|
||||
scope.push("y", String::from("foo"));
|
||||
scope.push("z", "foo");
|
||||
|
||||
assert!(engine.eval_with_scope::<bool>(&mut scope, r#"x == "foo""#)?);
|
||||
assert!(engine.eval_with_scope::<bool>(&mut scope, r#"y == "foo""#)?);
|
||||
assert!(engine.eval_with_scope::<bool>(&mut scope, r#"z == "foo""#)?);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
#[test]
|
||||
fn test_string_substring() -> Result<(), Box<EvalAltResult>> {
|
||||
|
Reference in New Issue
Block a user