Fix tests.
This commit is contained in:
parent
1004bca5b5
commit
4c4a209609
@ -1672,7 +1672,7 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("set$squared", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64", "y: u64", "()"]),
|
||||
m.set_fn("set$squared", FnNamespace::Global, FnAccess::Public, Some(&["x: &mut u64", "y: u64", "()"]),
|
||||
&[core::any::TypeId::of::<u64>(), core::any::TypeId::of::<u64>()],
|
||||
int_foo_token().into());
|
||||
if flatten {} else {}
|
||||
@ -1752,7 +1752,7 @@ mod generate_tests {
|
||||
m.set_fn("set_sq", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64", "y: u64", "()"]),
|
||||
&[core::any::TypeId::of::<u64>(), core::any::TypeId::of::<u64>()],
|
||||
int_foo_token().into());
|
||||
m.set_fn("set$squared", FnNamespace::Internal, FnAccess::Public, Some(&["x: &mut u64", "y: u64", "()"]),
|
||||
m.set_fn("set$squared", FnNamespace::Global, FnAccess::Public, Some(&["x: &mut u64", "y: u64", "()"]),
|
||||
&[core::any::TypeId::of::<u64>(), core::any::TypeId::of::<u64>()],
|
||||
int_foo_token().into());
|
||||
if flatten {} else {}
|
||||
@ -1829,7 +1829,7 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("index$get$", FnNamespace::Internal, FnAccess::Public,
|
||||
m.set_fn("index$get$", FnNamespace::Global, FnAccess::Public,
|
||||
Some(&["x: &mut MyCollection", "i: u64", "FLOAT"]),
|
||||
&[core::any::TypeId::of::<MyCollection>(),
|
||||
core::any::TypeId::of::<u64>()],
|
||||
@ -1914,7 +1914,7 @@ mod generate_tests {
|
||||
&[core::any::TypeId::of::<MyCollection>(),
|
||||
core::any::TypeId::of::<u64>()],
|
||||
get_by_index_token().into());
|
||||
m.set_fn("index$get$", FnNamespace::Internal, FnAccess::Public,
|
||||
m.set_fn("index$get$", FnNamespace::Global, FnAccess::Public,
|
||||
Some(&["x: &mut MyCollection", "i: u64", "FLOAT"]),
|
||||
&[core::any::TypeId::of::<MyCollection>(),
|
||||
core::any::TypeId::of::<u64>()],
|
||||
@ -1994,7 +1994,7 @@ mod generate_tests {
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
m.set_fn("index$set$", FnNamespace::Internal, FnAccess::Public,
|
||||
m.set_fn("index$set$", FnNamespace::Global, FnAccess::Public,
|
||||
Some(&["x: &mut MyCollection", "i: u64", "item: FLOAT", "()"]),
|
||||
&[core::any::TypeId::of::<MyCollection>(),
|
||||
core::any::TypeId::of::<u64>(),
|
||||
@ -2083,7 +2083,7 @@ mod generate_tests {
|
||||
core::any::TypeId::of::<u64>(),
|
||||
core::any::TypeId::of::<FLOAT>()],
|
||||
set_by_index_token().into());
|
||||
m.set_fn("index$set$", FnNamespace::Internal, FnAccess::Public,
|
||||
m.set_fn("index$set$", FnNamespace::Global, FnAccess::Public,
|
||||
Some(&["x: &mut MyCollection", "i: u64", "item: FLOAT", "()"]),
|
||||
&[core::any::TypeId::of::<MyCollection>(),
|
||||
core::any::TypeId::of::<u64>(),
|
||||
|
@ -109,7 +109,7 @@ gen_functions!(debug_float => to_debug(f32, f64));
|
||||
|
||||
// Register print and debug
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
#[cfg(any(not(feature = "no_index"), not(feature = "no_object")))]
|
||||
#[inline(always)]
|
||||
fn print_with_func(fn_name: &str, ctx: &NativeCallContext, value: &mut Dynamic) -> ImmutableString {
|
||||
match ctx.call_fn_dynamic_raw(fn_name, true, false, &mut [value], None) {
|
||||
@ -144,7 +144,7 @@ mod print_debug_functions {
|
||||
|
||||
#[rhai_fn(name = "print", name = "to_string", name = "to_debug", name = "debug")]
|
||||
pub fn format_array(ctx: NativeCallContext, arr: &mut Array) -> ImmutableString {
|
||||
let mut result = String::with_capacity(16);
|
||||
let mut result = crate::stdlib::string::String::with_capacity(16);
|
||||
result.push_str("[");
|
||||
|
||||
let len = arr.len();
|
||||
@ -166,7 +166,7 @@ mod print_debug_functions {
|
||||
|
||||
#[rhai_fn(name = "print", name = "to_string", name = "to_debug", name = "debug")]
|
||||
pub fn format_map(ctx: NativeCallContext, map: &mut Map) -> ImmutableString {
|
||||
let mut result = String::with_capacity(16);
|
||||
let mut result = crate::stdlib::string::String::with_capacity(16);
|
||||
result.push_str("#{");
|
||||
|
||||
let len = map.len();
|
||||
|
@ -42,6 +42,7 @@ impl std::fmt::Display for MyStruct {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
#[test]
|
||||
fn test_print_custom_type() -> Result<(), Box<EvalAltResult>> {
|
||||
let mut engine = Engine::new();
|
||||
@ -65,7 +66,6 @@ fn test_print_custom_type() -> Result<(), Box<EvalAltResult>> {
|
||||
r#"[123, true, (), "world", hello: 42]"#
|
||||
);
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
assert!(engine
|
||||
.eval::<String>(
|
||||
r#"
|
||||
|
Loading…
Reference in New Issue
Block a user