Add only_i32
and only_i64
features.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
use rhai::{Engine, EvalAltResult, RegisterFn};
|
||||
use rhai::{Engine, EvalAltResult, RegisterFn, INT};
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "no_stdlib"))]
|
||||
fn test_mismatched_op() {
|
||||
let mut engine = Engine::new();
|
||||
|
||||
let r = engine.eval::<i64>("60 + \"hello\"");
|
||||
let r = engine.eval::<INT>("60 + \"hello\"");
|
||||
|
||||
match r {
|
||||
Err(EvalAltResult::ErrorMismatchOutputType(err, _)) if err == "string" => (),
|
||||
@@ -17,7 +17,7 @@ fn test_mismatched_op() {
|
||||
fn test_mismatched_op_custom_type() {
|
||||
#[derive(Clone)]
|
||||
struct TestStruct {
|
||||
x: i64,
|
||||
x: INT,
|
||||
}
|
||||
|
||||
impl TestStruct {
|
||||
@@ -30,10 +30,15 @@ fn test_mismatched_op_custom_type() {
|
||||
engine.register_type_with_name::<TestStruct>("TestStruct");
|
||||
engine.register_fn("new_ts", TestStruct::new);
|
||||
|
||||
let r = engine.eval::<i64>("60 + new_ts()");
|
||||
let r = engine.eval::<INT>("60 + new_ts()");
|
||||
|
||||
match r {
|
||||
#[cfg(feature = "only_i32")]
|
||||
Err(EvalAltResult::ErrorFunctionNotFound(err, _)) if err == "+ (i32, TestStruct)" => (),
|
||||
|
||||
#[cfg(not(feature = "only_i32"))]
|
||||
Err(EvalAltResult::ErrorFunctionNotFound(err, _)) if err == "+ (i64, TestStruct)" => (),
|
||||
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user