Skip to content

Commit 232866b

Browse files
committed
Add test for taking remote type
1 parent 33f1207 commit 232866b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

crates/bevy_reflect/src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,36 @@ bevy_reflect::tests::should_reflect_debug::Test {
11201120
assert_eq!(321, data.0.inner.0);
11211121
}
11221122

1123+
#[test]
1124+
fn should_take_remote_type() {
1125+
mod external_crate {
1126+
#[derive(Debug, Default, PartialEq, Eq)]
1127+
pub struct TheirType {
1128+
pub value: String,
1129+
}
1130+
}
1131+
1132+
// === Remote Wrapper === //
1133+
#[reflect_remote(external_crate::TheirType)]
1134+
#[derive(Debug, Default)]
1135+
#[reflect(Debug, Default)]
1136+
struct MyType {
1137+
pub value: String,
1138+
}
1139+
1140+
let input: Box<dyn Reflect> = Box::new(MyType(external_crate::TheirType {
1141+
value: "Hello".to_string(),
1142+
}));
1143+
1144+
let output: MyType = input.take().expect("data should be of type `MyType`");
1145+
assert_eq!(
1146+
external_crate::TheirType {
1147+
value: "Hello".to_string(),
1148+
},
1149+
output.0
1150+
);
1151+
}
1152+
11231153
#[cfg(feature = "glam")]
11241154
mod glam {
11251155
use super::*;

0 commit comments

Comments
 (0)