Skip to content

Commit ec223c3

Browse files
committed
Fix glam tests
1 parent b6edf6e commit ec223c3

File tree

2 files changed

+39
-30
lines changed

2 files changed

+39
-30
lines changed

crates/bevy_reflect/src/impls/glam.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ impl_reflect_struct!(
1313
}
1414
);
1515
impl_reflect_struct!(
16-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
16+
#[reflect(Debug, PartialEq, Default)]
1717
struct IVec3 {
1818
x: i32,
1919
y: i32,
2020
z: i32,
2121
}
2222
);
2323
impl_reflect_struct!(
24-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
24+
#[reflect(Debug, PartialEq, Default)]
2525
struct IVec4 {
2626
x: i32,
2727
y: i32,
@@ -31,22 +31,22 @@ impl_reflect_struct!(
3131
);
3232

3333
impl_reflect_struct!(
34-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
34+
#[reflect(Debug, PartialEq, Default)]
3535
struct UVec2 {
3636
x: u32,
3737
y: u32,
3838
}
3939
);
4040
impl_reflect_struct!(
41-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
41+
#[reflect(Debug, PartialEq, Default)]
4242
struct UVec3 {
4343
x: u32,
4444
y: u32,
4545
z: u32,
4646
}
4747
);
4848
impl_reflect_struct!(
49-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
49+
#[reflect(Debug, PartialEq, Default)]
5050
struct UVec4 {
5151
x: u32,
5252
y: u32,
@@ -56,30 +56,30 @@ impl_reflect_struct!(
5656
);
5757

5858
impl_reflect_struct!(
59-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
59+
#[reflect(Debug, PartialEq, Default)]
6060
struct Vec2 {
6161
x: f32,
6262
y: f32,
6363
}
6464
);
6565
impl_reflect_struct!(
66-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
66+
#[reflect(Debug, PartialEq, Default)]
6767
struct Vec3 {
6868
x: f32,
6969
y: f32,
7070
z: f32,
7171
}
7272
);
7373
impl_reflect_struct!(
74-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
74+
#[reflect(Debug, PartialEq, Default)]
7575
struct Vec3A {
7676
x: f32,
7777
y: f32,
7878
z: f32,
7979
}
8080
);
8181
impl_reflect_struct!(
82-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
82+
#[reflect(Debug, PartialEq, Default)]
8383
struct Vec4 {
8484
x: f32,
8585
y: f32,
@@ -89,22 +89,22 @@ impl_reflect_struct!(
8989
);
9090

9191
impl_reflect_struct!(
92-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
92+
#[reflect(Debug, PartialEq, Default)]
9393
struct DVec2 {
9494
x: f64,
9595
y: f64,
9696
}
9797
);
9898
impl_reflect_struct!(
99-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
99+
#[reflect(Debug, PartialEq, Default)]
100100
struct DVec3 {
101101
x: f64,
102102
y: f64,
103103
z: f64,
104104
}
105105
);
106106
impl_reflect_struct!(
107-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
107+
#[reflect(Debug, PartialEq, Default)]
108108
struct DVec4 {
109109
x: f64,
110110
y: f64,
@@ -114,15 +114,15 @@ impl_reflect_struct!(
114114
);
115115

116116
impl_reflect_struct!(
117-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
117+
#[reflect(Debug, PartialEq, Default)]
118118
struct Mat3 {
119119
x_axis: Vec3,
120120
y_axis: Vec3,
121121
z_axis: Vec3,
122122
}
123123
);
124124
impl_reflect_struct!(
125-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
125+
#[reflect(Debug, PartialEq, Default)]
126126
struct Mat4 {
127127
x_axis: Vec4,
128128
y_axis: Vec4,
@@ -132,15 +132,15 @@ impl_reflect_struct!(
132132
);
133133

134134
impl_reflect_struct!(
135-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
135+
#[reflect(Debug, PartialEq, Default)]
136136
struct DMat3 {
137137
x_axis: DVec3,
138138
y_axis: DVec3,
139139
z_axis: DVec3,
140140
}
141141
);
142142
impl_reflect_struct!(
143-
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
143+
#[reflect(Debug, PartialEq, Default)]
144144
struct DMat4 {
145145
x_axis: DVec4,
146146
y_axis: DVec4,

crates/bevy_reflect/src/lib.rs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,6 @@ bevy_reflect::tests::should_reflect_debug::Test {
876876
#[cfg(feature = "glam")]
877877
mod glam {
878878
use super::*;
879-
use ::serde::Serialize;
880879

881880
#[test]
882881
fn vec3_serialization() {
@@ -885,25 +884,35 @@ bevy_reflect::tests::should_reflect_debug::Test {
885884
let mut registry = TypeRegistry::default();
886885
registry.add_registration(Vec3::get_type_registration());
887886

888-
let ser = ReflectSerializer::new(&v, &registry);
887+
let serializer = ReflectSerializer::new(&v, &registry);
889888

890-
let mut dest = vec![];
891-
let mut serializer = ron::ser::Serializer::new(&mut dest, None, false)
892-
.expect("Failed to acquire serializer");
893-
894-
ser.serialize(&mut serializer).expect("Failed to serialize");
895-
896-
let result = String::from_utf8(dest).expect("Failed to convert to string");
889+
let output = ron::ser::to_string_pretty(&serializer, Default::default()).unwrap();
890+
let expected = r#"
891+
{
892+
"type": "glam::vec3::Vec3",
893+
"value": {
894+
"x": 12,
895+
"y": 3,
896+
"z": -6.9,
897+
},
898+
}
899+
"#;
897900

898-
assert_eq!(
899-
result,
900-
r#"{"type":"glam::vec3::Vec3","struct":{"x":{"type":"f32","value":12},"y":{"type":"f32","value":3},"z":{"type":"f32","value":-6.9}}}"#
901-
);
901+
assert_eq!(expected, format!("\n{}\n", output));
902902
}
903903

904904
#[test]
905905
fn vec3_deserialization() {
906-
let data = r#"{"type":"glam::vec3::Vec3","struct":{"x":{"type":"f32","value":12},"y":{"type":"f32","value":3},"z":{"type":"f32","value":-6.9}}}"#;
906+
let data = r#"
907+
{
908+
"type": "glam::vec3::Vec3",
909+
"value": {
910+
"x": 12,
911+
"y": 3,
912+
"z": -6.9,
913+
},
914+
}
915+
"#;
907916

908917
let mut registry = TypeRegistry::default();
909918
registry.add_registration(Vec3::get_type_registration());

0 commit comments

Comments
 (0)