Repository: bitshifter/glam-rs
Pull request #653 (2025-06-21 09:38:38)

More missing tests.


Patch:
diff --git a/src/bool/coresimd/bvec4a.rs b/src/bool/coresimd/bvec4a.rs
index 8260d91..96aa952 100644
--- a/src/bool/coresimd/bvec4a.rs
+++ b/src/bool/coresimd/bvec4a.rs
@@ -104,7 +104,6 @@ impl BVec4A {
     /// Panics if `index` is greater than 3.
     #[inline]
     pub fn set(&mut self, index: usize, value: bool) {
-        assert!(index < 4, "index out of bounds");
         self.0.set(index, value)
     }
 
diff --git a/templates/vec_mask.rs.tera b/templates/vec_mask.rs.tera
index e7ad219..50288ef 100644
--- a/templates/vec_mask.rs.tera
+++ b/templates/vec_mask.rs.tera
@@ -317,7 +317,9 @@ impl {{ self_t }} {
                 _ => panic!("index out of bounds")
             }
         {% elif is_coresimd %}
-            assert!(index < {{ dim }}, "index out of bounds");
+            {% if dim < 4 %}
+                assert!(index < {{ dim }}, "index out of bounds");
+            {%- endif %}
             self.0.set(index, value)
         {% elif is_neon %}
             self.0 = match index { 


Test patch:
diff --git a/tests/mat2.rs b/tests/mat2.rs
index 860907c..a147a03 100644
--- a/tests/mat2.rs
+++ b/tests/mat2.rs
@@ -78,10 +78,30 @@ macro_rules! impl_mat2_tests {
 
         glam_test!(test_mat2_mul, {
             let mat_a = $mat2::from_angle(deg(90.0));
+
             let res_a = mat_a * $vec2::Y;
             assert_approx_eq!($newvec2(-1.0, 0.0), res_a);
+
+            let res_a = &mat_a * $vec2::Y;
+            assert_approx_eq!($newvec2(-1.0, 0.0), res_a);
+
+            let res_a = mat_a * &$vec2::Y;
+            assert_approx_eq!($newvec2(-1.0, 0.0), res_a);
+
+            let res_a = &mat_a * &$vec2::Y;
+            assert_approx_eq!($newvec2(-1.0, 0.0), res_a);
+
             let res_b = mat_a * $vec2::X;
             assert_approx_eq!($newvec2(0.0, 1.0), res_b);
+
+            let res_b = &mat_a * $vec2::X;
+            assert_approx_eq!($newvec2(0.0, 1.0), res_b);
+
+            let res_b = mat_a * &$vec2::X;
+            assert_approx_eq!($newvec2(0.0, 1.0), res_b);
+
+            let res_b = &mat_a * &$vec2::X;
+            assert_approx_eq!($newvec2(0.0, 1.0), res_b);
         });
 
         glam_test!(test_from_scale_angle, {
@@ -216,20 +236,41 @@ macro_rules! impl_mat2_tests {
             m1 *= 2.0;
             assert_eq!(m0x2, m1);
 
+            let mut m1 = m0;
+            m1 *= &2.0;
+            assert_eq!(m0x2, m1);
+
             let mut m1 = m0x2;
             m1 /= 2.0;
             assert_eq!(m0, m1);
 
+            let mut m1 = m0x2;
+            m1 /= &2.0;
+            assert_eq!(m0, m1);
+
             let mut m1 = m0;
             m1 += m0;
             assert_eq!(m0x2, m1);
 
+            let mut m1 = m0;
+            m1 += &m0;
+            assert_eq!(m0x2, m1);
+
             let mut m1 = m0;
             m1 -= m0;
             assert_eq!($mat2::ZERO, m1);
 
+            let mut m1 = m0;
+            m1 -= &m0;
+            assert_eq!($mat2::ZERO, m1);
+
             let mut m1 = $mat2::IDENTITY;
             m1 *= m0;
+            assert_eq!(m0, m1);
+
+            let mut m1 = $mat2::IDENTITY;
+            m1 *= &m0;
+            assert_eq!(m0, m1);
         });
 
         glam_test!(test_mat2_fmt, {
diff --git a/tests/mat3.rs b/tests/mat3.rs
index fc9bfa7..16ad1be 100644
--- a/tests/mat3.rs
+++ b/tests/mat3.rs
@@ -133,12 +133,13 @@ macro_rules! impl_mat3_tests {
         });
 
         glam_test!(test_mat3_mul_vec3, {
-            let mat_a = $mat3::from_axis_angle($vec3::Z, deg(90.0));
-            assert_approx_eq!($newvec3(-1.0, 0.0, 0.0), mat_a * $newvec3(0.0, 1.0, 0.0));
-            assert_approx_eq!(
-                $vec3::new(-1.0, 0.0, 0.0),
-                mat_a.mul_vec3($vec3::new(0.0, 1.0, 0.0))
-            );
+            let m = $mat3::from_axis_angle($vec3::Z, deg(90.0));
+            assert_approx_eq!($vec3::NEG_X, m * $vec3::Y);
+            assert_approx_eq!($vec3::NEG_X, &m * $vec3::Y);
+            assert_approx_eq!($vec3::NEG_X, m * &$vec3::Y);
+            assert_approx_eq!($vec3::NEG_X, &m * &$vec3::Y);
+
+            assert_approx_eq!($vec3::NEG_X, m.mul_vec3($vec3::Y))
         });
 
         glam_test!(test_mat3_transform2d, {
@@ -376,21 +377,41 @@ macro_rules! impl_mat3_tests {
             m1 *= 2.0;
             assert_eq!(m0x2, m1);
 
+            let mut m1 = m0;
+            m1 *= &2.0;
+            assert_eq!(m0x2, m1);
+
             let mut m1 = m0x2;
             m1 /= 2.0;
             assert_eq!(m0, m1);
 
+            let mut m1 = m0x2;
+            m1 /= &2.0;
+            assert_eq!(m0, m1);
+
             let mut m1 = m0;
             m1 += m0;
             assert_eq!(m0x2, m1);
 
+            let mut m1 = m0;
+            m1 += &m0;
+            assert_eq!(m0x2, m1);
+
             let mut m1 = m0;
             m1 -= m0;
             assert_eq!($mat3::ZERO, m1);
 
+            let mut m1 = m0;
+            m1 -= &m0;
+            assert_eq!($mat3::ZERO, m1);
+
             let mut m1 = $mat3::IDENTITY;
             m1 *= m0;
-            assert_approx_eq!(m0, m1);
+            assert_eq!(m0, m1);
+
+            let mut m1 = $mat3::IDENTITY;
+            m1 *= &m0;
+            assert_eq!(m0, m1);
         });
 
         glam_test!(test_mat3_abs, {
diff --git a/tests/mat4.rs b/tests/mat4.rs
index faf3802..8a5a17b 100644
--- a/tests/mat4.rs
+++ b/tests/mat4.rs
@@ -695,21 +695,41 @@ macro_rules! impl_mat4_tests {
             m1 *= 2.0;
             assert_eq!(m0x2, m1);
 
+            let mut m1 = m0;
+            m1 *= &2.0;
+            assert_eq!(m0x2, m1);
+
             let mut m1 = m0x2;
             m1 /= 2.0;
             assert_eq!(m0, m1);
 
+            let mut m1 = m0x2;
+            m1 /= &2.0;
+            assert_eq!(m0, m1);
+
             let mut m1 = m0;
             m1 += m0;
             assert_eq!(m0x2, m1);
 
+            let mut m1 = m0;
+            m1 += &m0;
+            assert_eq!(m0x2, m1);
+
             let mut m1 = m0;
             m1 -= m0;
             assert_eq!($mat4::ZERO, m1);
 
+            let mut m1 = m0;
+            m1 -= &m0;
+            assert_eq!($mat4::ZERO, m1);
+
             let mut m1 = $mat4::IDENTITY;
             m1 *= m0;
-            assert_approx_eq!(m0, m1);
+            assert_eq!(m0, m1);
+
+            let mut m1 = $mat4::IDENTITY;
+            m1 *= &m0;
+            assert_eq!(m0, m1);
         });
 
         glam_test!(test_mat4_fmt, {
diff --git a/tests/quat.rs b/tests/quat.rs
index bc5be84..a1458c6 100644
--- a/tests/quat.rs
+++ b/tests/quat.rs
@@ -107,6 +107,13 @@ macro_rules! impl_quat_tests {
             let yx1 = $quat::from_euler(EulerRot::YXZ, yaw, pitch, zero);
             assert_approx_eq!(yx0, yx1);
 
+            let yx0 = &y0 * x0;
+            assert_approx_eq!(yx0, yx1);
+            let yx0 = y0 * &x0;
+            assert_approx_eq!(yx0, yx1);
+            let yx0 = &y0 * &x0;
+            assert_approx_eq!(yx0, yx1);
+
             let yxz0 = y0 * x0 * z0;
             assert!(yxz0.is_normalized());
             let yxz1 = $quat::from_euler(EulerRot::YXZ, yaw, pitch, roll);
@@ -134,6 +141,10 @@ macro_rules! impl_quat_tests {
             x0 *= x0;
             assert_approx_eq!(x0, $quat::from_rotation_x(pitch * 2.0));
 
+            let mut x0 = $quat::from_rotation_x(pitch);
+            x0 *= &x0.clone();
+            assert_approx_eq!(x0, $quat::from_rotation_x(pitch * 2.0));
+
             should_glam_assert!({ ($quat::IDENTITY * 2.0).inverse() });
             should_glam_assert!({ $quat::from_axis_angle($vec3::ZERO, 0.0) });
         });