Add no_object feature to disable objects.

This commit is contained in:
Stephen Chung
2020-03-29 17:15:12 +08:00
parent a8a4ed2967
commit ef6c6ea6d2
16 changed files with 71 additions and 15 deletions

View File

@@ -16,6 +16,7 @@ fn test_arrays() -> Result<(), EvalAltResult> {
}
#[test]
#[cfg(not(feature = "no_object"))]
fn test_array_with_structs() -> Result<(), EvalAltResult> {
#[derive(Clone)]
struct TestStruct {

View File

@@ -27,6 +27,7 @@ fn test_expressions() -> Result<(), EvalAltResult> {
/// This example taken from https://github.com/jonathandturner/rhai/issues/115
#[test]
#[cfg(not(feature = "no_object"))]
fn test_expressions_eval() -> Result<(), EvalAltResult> {
#[derive(Debug, Clone)]
struct AGENT {

View File

@@ -21,6 +21,7 @@ fn test_float() -> Result<(), EvalAltResult> {
}
#[test]
#[cfg(not(feature = "no_object"))]
fn struct_with_float() -> Result<(), EvalAltResult> {
#[derive(Clone)]
struct TestStruct {

View File

@@ -1,3 +1,5 @@
#![cfg(not(feature = "no_object"))]
use rhai::{Engine, EvalAltResult, RegisterFn, INT};
#[test]

View File

@@ -12,12 +12,12 @@ fn test_math() -> Result<(), EvalAltResult> {
#[cfg(not(feature = "only_i32"))]
assert_eq!(
engine.eval::<INT>("(-9223372036854775807).abs()")?,
engine.eval::<INT>("abs(-9223372036854775807)")?,
9_223_372_036_854_775_807
);
#[cfg(feature = "only_i32")]
assert_eq!(engine.eval::<INT>("(-2147483647).abs()")?, 2147483647);
assert_eq!(engine.eval::<INT>("abs(-2147483647)")?, 2147483647);
// Overflow/underflow/division-by-zero errors
#[cfg(not(feature = "unchecked"))]
@@ -26,7 +26,7 @@ fn test_math() -> Result<(), EvalAltResult> {
{
assert!(matches!(
engine
.eval::<INT>("(-9223372036854775808).abs()")
.eval::<INT>("abs(-9223372036854775808)")
.expect_err("expects negation overflow"),
EvalAltResult::ErrorArithmetic(_, _)
));

View File

@@ -1,3 +1,5 @@
#![cfg(not(feature = "no_object"))]
use rhai::{Engine, EvalAltResult, RegisterFn, INT};
#[test]

View File

@@ -12,6 +12,7 @@ fn test_mismatched_op() {
}
#[test]
#[cfg(not(feature = "no_object"))]
fn test_mismatched_op_custom_type() {
#[derive(Clone)]
struct TestStruct {

View File

@@ -1,3 +1,5 @@
#![cfg(not(feature = "no_object"))]
///! This test simulates an external command object that is driven by a script.
use rhai::{Engine, EvalAltResult, RegisterFn, Scope, INT};
use std::cell::RefCell;