Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion crates/bevy_mod_scripting_core/src/bindings/pretty_print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ impl ReflectReferencePrinter {
}
id if id == TypeId::of::<char>() => downcast_case!(v, output, char),
id if id == TypeId::of::<bool>() => downcast_case!(v, output, bool),
id if id == TypeId::of::<ScriptValue>() => downcast_case!(v, output, ScriptValue),
_ => {
output.push_str(
v.get_represented_type_info()
Expand Down Expand Up @@ -654,7 +655,7 @@ impl<K: DisplayWithWorld + 'static, V: DisplayWithWorld + 'static> DisplayWithWo

#[cfg(test)]
mod test {
use bevy::prelude::AppTypeRegistry;
use bevy::{prelude::AppTypeRegistry, reflect::Reflect};

use crate::bindings::{
function::script_function::AppScriptFunctionRegistry, AppReflectAllocator,
Expand Down Expand Up @@ -778,4 +779,29 @@ mod test {

assert_eq!(map.display_value_with_world(world.clone()), "{hello: true}");
}

#[test]
fn test_script_value_in_reference() {
let mut world = setup_world();
let world = WorldGuard::new_exclusive(&mut world);

#[derive(Reflect)]
struct Test {
val: ScriptValue,
}

let test = Test {
val: ScriptValue::Bool(true),
};

let allocator = world.allocator();
let mut allocator_write = allocator.write();

let reflect_reference = ReflectReference::new_allocated(test, &mut allocator_write);
drop(allocator_write);
assert_eq!(
reflect_reference.display_value_with_world(world.clone()),
"{val: Reflect(ScriptValue(Bool(true)))}"
);
}
}
Loading