Avoid hard-coding variable type for shared.
This commit is contained in:
@@ -11,11 +11,23 @@ fn test_shared() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
assert_eq!(engine.eval::<bool>("shared(true)")?, true);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<String>("let x = shared(true); type_of(x)")?,
|
||||
"bool"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<String>("let x = shared(true); x = (); type_of(x)")?,
|
||||
"()"
|
||||
);
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
assert_eq!(engine.eval::<f64>("shared(4.2)")?, 4.2);
|
||||
|
||||
assert_eq!(engine.eval::<String>(r#"shared("test")"#)?, "test");
|
||||
|
||||
assert_eq!(engine.eval::<String>(r#"shared("test")"#)?, "test");
|
||||
|
||||
assert_eq!(engine.eval::<char>("shared('x')")?, 'x');
|
||||
|
||||
assert!(engine.eval::<bool>("is_shared(shared(42))")?);
|
||||
|
Reference in New Issue
Block a user