| 1 |
|
| 2 |
|
| 3 |
. |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
use crate::default::{F32x4, I32x4, U32x4}; |
| 12 |
use crate::scalar::F32x4 as F32x4S; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#[test] |
| 17 |
fn test_f32x4_constructors() { |
| 18 |
let a = F32x4::new(1.0, 2.0, 3.0, 4.0); |
| 19 |
assert_eq!((a[0], a[1], a[2], a[3]), (1.0, 2.0, 3.0, 4.0)); |
| 20 |
let b = F32x4::splat(10.0); |
| 21 |
assert_eq!(b, F32x4::new(10.0, 10.0, 10.0, 10.0)); |
| 22 |
} |
| 23 |
|
| 24 |
#[test] |
| 25 |
fn test_f32x4_accessors_and_mutators() { |
| 26 |
let a = F32x4::new(5.0, 6.0, 7.0, 8.0); |
| 27 |
assert_eq!((a.x(), a.y(), a.z(), a.w()), (5.0, 6.0, 7.0, 8.0)); |
| 28 |
let mut b = F32x4::new(10.0, 11.0, 12.0, 13.0); |
| 29 |
b.set_x(20.0); |
| 30 |
b.set_y(30.0); |
| 31 |
b.set_z(40.0); |
| 32 |
b.set_w(50.0); |
| 33 |
assert_eq!(b, F32x4::new(20.0, 30.0, 40.0, 50.0)); |
| 34 |
} |
| 35 |
|
| 36 |
fn test_f32x4_basic_ops() { |
| 37 |
let a = F32x4::new(1.0, 3.0, 5.0, 7.0); |
| 38 |
let b = F32x4::new(2.0, 2.0, 6.0, 6.0); |
| 39 |
assert_eq!(a.approx_recip(), F32x4::new(0.99975586, 0.333313, 0.19995117, 0.14282227)); |
| 40 |
assert_eq!(a.min(b), F32x4::new(1.0, 2.0, 5.0, 6.0)); |
| 41 |
assert_eq!(a.max(b), F32x4::new(2.0, 3.0, 6.0, 7.0)); |
| 42 |
let c = F32x4::new(-1.0, 1.3, -20.0, 3.6); |
| 43 |
assert_eq!(c.clamp(a, b), F32x4::new(1.0, 2.0, 5.0, 6.0)); |
| 44 |
assert_eq!(c.abs(), F32x4::new(1.0, 1.3, 20.0, 3.6)); |
| 45 |
assert_eq!(c.floor(), F32x4::new(-1.0, 1.0, -20.0, 3.0)); |
| 46 |
assert_eq!(c.ceil(), F32x4::new(-1.0, 2.0, -20.0, 4.0)); |
| 47 |
assert_eq!(c.to_i32x4().to_f32x4(), F32x4::new(-1.0, 1.0, -20.0, 4.0)); |
| 48 |
let d = F32x4::new(1.0, 2.0, 3.0, 4.0); |
| 49 |
assert_eq!(d.sqrt(), F32x4::new(1.0, 1.4142135, 1.7320508, 2.0)); |
| 50 |
} |
| 51 |
|
| 52 |
#[test] |
| 53 |
fn test_f32x4_packed_comparisons() { |
| 54 |
let a = F32x4::new(7.0, 3.0, 6.0, -2.0); |
| 55 |
let b = F32x4::new(10.0, 3.0, 5.0, -2.0); |
| 56 |
assert_eq!(a.packed_eq(b), U32x4::new(0, !0, 0, !0)); |
| 57 |
assert_eq!(a.packed_gt(b), U32x4::new(0, 0, !0, 0)); |
| 58 |
assert_eq!(a.packed_le(b), U32x4::new(!0, !0, 0, !0)); |
| 59 |
} |
| 60 |
|
| 61 |
#[test] |
| 62 |
fn test_f32x4_swizzles() { |
| 63 |
let a = F32x4::new(1.0, 2.0, 3.0, 4.0); |
| 64 |
assert_eq!(a.xxxx(), F32x4::splat(1.0)); |
| 65 |
assert_eq!(a.yyyy(), F32x4::splat(2.0)); |
| 66 |
assert_eq!(a.zzzz(), F32x4::splat(3.0)); |
| 67 |
assert_eq!(a.wwww(), F32x4::splat(4.0)); |
| 68 |
|
| 69 |
assert_eq!(a.yxxx(), F32x4::new(2.0, 1.0, 1.0, 1.0)); |
| 70 |
assert_eq!(a.zxxx(), F32x4::new(3.0, 1.0, 1.0, 1.0)); |
| 71 |
assert_eq!(a.wxxx(), F32x4::new(4.0, 1.0, 1.0, 1.0)); |
| 72 |
assert_eq!(a.xyxx(), F32x4::new(1.0, 2.0, 1.0, 1.0)); |
| 73 |
assert_eq!(a.yyxx(), F32x4::new(2.0, 2.0, 1.0, 1.0)); |
| 74 |
assert_eq!(a.zyxx(), F32x4::new(3.0, 2.0, 1.0, 1.0)); |
| 75 |
assert_eq!(a.wyxx(), F32x4::new(4.0, 2.0, 1.0, 1.0)); |
| 76 |
assert_eq!(a.xzxx(), F32x4::new(1.0, 3.0, 1.0, 1.0)); |
| 77 |
assert_eq!(a.yzxx(), F32x4::new(2.0, 3.0, 1.0, 1.0)); |
| 78 |
assert_eq!(a.zzxx(), F32x4::new(3.0, 3.0, 1.0, 1.0)); |
| 79 |
assert_eq!(a.wzxx(), F32x4::new(4.0, 3.0, 1.0, 1.0)); |
| 80 |
assert_eq!(a.xwxx(), F32x4::new(1.0, 4.0, 1.0, 1.0)); |
| 81 |
assert_eq!(a.ywxx(), F32x4::new(2.0, 4.0, 1.0, 1.0)); |
| 82 |
assert_eq!(a.zwxx(), F32x4::new(3.0, 4.0, 1.0, 1.0)); |
| 83 |
assert_eq!(a.wwxx(), F32x4::new(4.0, 4.0, 1.0, 1.0)); |
| 84 |
assert_eq!(a.xxyx(), F32x4::new(1.0, 1.0, 2.0, 1.0)); |
| 85 |
assert_eq!(a.yxyx(), F32x4::new(2.0, 1.0, 2.0, 1.0)); |
| 86 |
assert_eq!(a.zxyx(), F32x4::new(3.0, 1.0, 2.0, 1.0)); |
| 87 |
assert_eq!(a.wxyx(), F32x4::new(4.0, 1.0, 2.0, 1.0)); |
| 88 |
assert_eq!(a.xyyx(), F32x4::new(1.0, 2.0, 2.0, 1.0)); |
| 89 |
assert_eq!(a.yyyx(), F32x4::new(2.0, 2.0, 2.0, 1.0)); |
| 90 |
assert_eq!(a.zyyx(), F32x4::new(3.0, 2.0, 2.0, 1.0)); |
| 91 |
assert_eq!(a.wyyx(), F32x4::new(4.0, 2.0, 2.0, 1.0)); |
| 92 |
assert_eq!(a.xzyx(), F32x4::new(1.0, 3.0, 2.0, 1.0)); |
| 93 |
assert_eq!(a.yzyx(), F32x4::new(2.0, 3.0, 2.0, 1.0)); |
| 94 |
assert_eq!(a.zzyx(), F32x4::new(3.0, 3.0, 2.0, 1.0)); |
| 95 |
assert_eq!(a.wzyx(), F32x4::new(4.0, 3.0, 2.0, 1.0)); |
| 96 |
assert_eq!(a.xwyx(), F32x4::new(1.0, 4.0, 2.0, 1.0)); |
| 97 |
assert_eq!(a.ywyx(), F32x4::new(2.0, 4.0, 2.0, 1.0)); |
| 98 |
assert_eq!(a.zwyx(), F32x4::new(3.0, 4.0, 2.0, 1.0)); |
| 99 |
assert_eq!(a.wwyx(), F32x4::new(4.0, 4.0, 2.0, 1.0)); |
| 100 |
assert_eq!(a.xxzx(), F32x4::new(1.0, 1.0, 3.0, 1.0)); |
| 101 |
assert_eq!(a.yxzx(), F32x4::new(2.0, 1.0, 3.0, 1.0)); |
| 102 |
assert_eq!(a.zxzx(), F32x4::new(3.0, 1.0, 3.0, 1.0)); |
| 103 |
assert_eq!(a.wxzx(), F32x4::new(4.0, 1.0, 3.0, 1.0)); |
| 104 |
assert_eq!(a.xyzx(), F32x4::new(1.0, 2.0, 3.0, 1.0)); |
| 105 |
assert_eq!(a.yyzx(), F32x4::new(2.0, 2.0, 3.0, 1.0)); |
| 106 |
assert_eq!(a.zyzx(), F32x4::new(3.0, 2.0, 3.0, 1.0)); |
| 107 |
assert_eq!(a.wyzx(), F32x4::new(4.0, 2.0, 3.0, 1.0)); |
| 108 |
assert_eq!(a.xzzx(), F32x4::new(1.0, 3.0, 3.0, 1.0)); |
| 109 |
assert_eq!(a.yzzx(), F32x4::new(2.0, 3.0, 3.0, 1.0)); |
| 110 |
assert_eq!(a.zzzx(), F32x4::new(3.0, 3.0, 3.0, 1.0)); |
| 111 |
assert_eq!(a.wzzx(), F32x4::new(4.0, 3.0, 3.0, 1.0)); |
| 112 |
assert_eq!(a.xwzx(), F32x4::new(1.0, 4.0, 3.0, 1.0)); |
| 113 |
assert_eq!(a.ywzx(), F32x4::new(2.0, 4.0, 3.0, 1.0)); |
| 114 |
assert_eq!(a.zwzx(), F32x4::new(3.0, 4.0, 3.0, 1.0)); |
| 115 |
assert_eq!(a.wwzx(), F32x4::new(4.0, 4.0, 3.0, 1.0)); |
| 116 |
assert_eq!(a.xxwx(), F32x4::new(1.0, 1.0, 4.0, 1.0)); |
| 117 |
assert_eq!(a.yxwx(), F32x4::new(2.0, 1.0, 4.0, 1.0)); |
| 118 |
assert_eq!(a.zxwx(), F32x4::new(3.0, 1.0, 4.0, 1.0)); |
| 119 |
assert_eq!(a.wxwx(), F32x4::new(4.0, 1.0, 4.0, 1.0)); |
| 120 |
assert_eq!(a.xywx(), F32x4::new(1.0, 2.0, 4.0, 1.0)); |
| 121 |
assert_eq!(a.yywx(), F32x4::new(2.0, 2.0, 4.0, 1.0)); |
| 122 |
assert_eq!(a.zywx(), F32x4::new(3.0, 2.0, 4.0, 1.0)); |
| 123 |
assert_eq!(a.wywx(), F32x4::new(4.0, 2.0, 4.0, 1.0)); |
| 124 |
assert_eq!(a.xzwx(), F32x4::new(1.0, 3.0, 4.0, 1.0)); |
| 125 |
assert_eq!(a.yzwx(), F32x4::new(2.0, 3.0, 4.0, 1.0)); |
| 126 |
assert_eq!(a.zzwx(), F32x4::new(3.0, 3.0, 4.0, 1.0)); |
| 127 |
assert_eq!(a.wzwx(), F32x4::new(4.0, 3.0, 4.0, 1.0)); |
| 128 |
assert_eq!(a.xwwx(), F32x4::new(1.0, 4.0, 4.0, 1.0)); |
| 129 |
assert_eq!(a.ywwx(), F32x4::new(2.0, 4.0, 4.0, 1.0)); |
| 130 |
assert_eq!(a.zwwx(), F32x4::new(3.0, 4.0, 4.0, 1.0)); |
| 131 |
assert_eq!(a.wwwx(), F32x4::new(4.0, 4.0, 4.0, 1.0)); |
| 132 |
|
| 133 |
assert_eq!(a.xxxy(), F32x4::new(1.0, 1.0, 1.0, 2.0)); |
| 134 |
assert_eq!(a.yxxy(), F32x4::new(2.0, 1.0, 1.0, 2.0)); |
| 135 |
assert_eq!(a.zxxy(), F32x4::new(3.0, 1.0, 1.0, 2.0)); |
| 136 |
assert_eq!(a.wxxy(), F32x4::new(4.0, 1.0, 1.0, 2.0)); |
| 137 |
assert_eq!(a.xyxy(), F32x4::new(1.0, 2.0, 1.0, 2.0)); |
| 138 |
assert_eq!(a.yyxy(), F32x4::new(2.0, 2.0, 1.0, 2.0)); |
| 139 |
assert_eq!(a.zyxy(), F32x4::new(3.0, 2.0, 1.0, 2.0)); |
| 140 |
assert_eq!(a.wyxy(), F32x4::new(4.0, 2.0, 1.0, 2.0)); |
| 141 |
assert_eq!(a.xzxy(), F32x4::new(1.0, 3.0, 1.0, 2.0)); |
| 142 |
assert_eq!(a.yzxy(), F32x4::new(2.0, 3.0, 1.0, 2.0)); |
| 143 |
assert_eq!(a.zzxy(), F32x4::new(3.0, 3.0, 1.0, 2.0)); |
| 144 |
assert_eq!(a.wzxy(), F32x4::new(4.0, 3.0, 1.0, 2.0)); |
| 145 |
assert_eq!(a.xwxy(), F32x4::new(1.0, 4.0, 1.0, 2.0)); |
| 146 |
assert_eq!(a.ywxy(), F32x4::new(2.0, 4.0, 1.0, 2.0)); |
| 147 |
assert_eq!(a.zwxy(), F32x4::new(3.0, 4.0, 1.0, 2.0)); |
| 148 |
assert_eq!(a.wwxy(), F32x4::new(4.0, 4.0, 1.0, 2.0)); |
| 149 |
assert_eq!(a.xxyy(), F32x4::new(1.0, 1.0, 2.0, 2.0)); |
| 150 |
assert_eq!(a.yxyy(), F32x4::new(2.0, 1.0, 2.0, 2.0)); |
| 151 |
assert_eq!(a.zxyy(), F32x4::new(3.0, 1.0, 2.0, 2.0)); |
| 152 |
assert_eq!(a.wxyy(), F32x4::new(4.0, 1.0, 2.0, 2.0)); |
| 153 |
assert_eq!(a.xyyy(), F32x4::new(1.0, 2.0, 2.0, 2.0)); |
| 154 |
assert_eq!(a.zyyy(), F32x4::new(3.0, 2.0, 2.0, 2.0)); |
| 155 |
assert_eq!(a.wyyy(), F32x4::new(4.0, 2.0, 2.0, 2.0)); |
| 156 |
assert_eq!(a.xzyy(), F32x4::new(1.0, 3.0, 2.0, 2.0)); |
| 157 |
assert_eq!(a.yzyy(), F32x4::new(2.0, 3.0, 2.0, 2.0)); |
| 158 |
assert_eq!(a.zzyy(), F32x4::new(3.0, 3.0, 2.0, 2.0)); |
| 159 |
assert_eq!(a.wzyy(), F32x4::new(4.0, 3.0, 2.0, 2.0)); |
| 160 |
assert_eq!(a.xwyy(), F32x4::new(1.0, 4.0, 2.0, 2.0)); |
| 161 |
assert_eq!(a.ywyy(), F32x4::new(2.0, 4.0, 2.0, 2.0)); |
| 162 |
assert_eq!(a.zwyy(), F32x4::new(3.0, 4.0, 2.0, 2.0)); |
| 163 |
assert_eq!(a.wwyy(), F32x4::new(4.0, 4.0, 2.0, 2.0)); |
| 164 |
assert_eq!(a.xxzy(), F32x4::new(1.0, 1.0, 3.0, 2.0)); |
| 165 |
assert_eq!(a.yxzy(), F32x4::new(2.0, 1.0, 3.0, 2.0)); |
| 166 |
assert_eq!(a.zxzy(), F32x4::new(3.0, 1.0, 3.0, 2.0)); |
| 167 |
assert_eq!(a.wxzy(), F32x4::new(4.0, 1.0, 3.0, 2.0)); |
| 168 |
assert_eq!(a.xyzy(), F32x4::new(1.0, 2.0, 3.0, 2.0)); |
| 169 |
assert_eq!(a.yyzy(), F32x4::new(2.0, 2.0, 3.0, 2.0)); |
| 170 |
assert_eq!(a.zyzy(), F32x4::new(3.0, 2.0, 3.0, 2.0)); |
| 171 |
assert_eq!(a.wyzy(), F32x4::new(4.0, 2.0, 3.0, 2.0)); |
| 172 |
assert_eq!(a.xzzy(), F32x4::new(1.0, 3.0, 3.0, 2.0)); |
| 173 |
assert_eq!(a.yzzy(), F32x4::new(2.0, 3.0, 3.0, 2.0)); |
| 174 |
assert_eq!(a.zzzy(), F32x4::new(3.0, 3.0, 3.0, 2.0)); |
| 175 |
assert_eq!(a.wzzy(), F32x4::new(4.0, 3.0, 3.0, 2.0)); |
| 176 |
assert_eq!(a.xwzy(), F32x4::new(1.0, 4.0, 3.0, 2.0)); |
| 177 |
assert_eq!(a.ywzy(), F32x4::new(2.0, 4.0, 3.0, 2.0)); |
| 178 |
assert_eq!(a.zwzy(), F32x4::new(3.0, 4.0, 3.0, 2.0)); |
| 179 |
assert_eq!(a.wwzy(), F32x4::new(4.0, 4.0, 3.0, 2.0)); |
| 180 |
assert_eq!(a.xxwy(), F32x4::new(1.0, 1.0, 4.0, 2.0)); |
| 181 |
assert_eq!(a.yxwy(), F32x4::new(2.0, 1.0, 4.0, 2.0)); |
| 182 |
assert_eq!(a.zxwy(), F32x4::new(3.0, 1.0, 4.0, 2.0)); |
| 183 |
assert_eq!(a.wxwy(), F32x4::new(4.0, 1.0, 4.0, 2.0)); |
| 184 |
assert_eq!(a.xywy(), F32x4::new(1.0, 2.0, 4.0, 2.0)); |
| 185 |
assert_eq!(a.yywy(), F32x4::new(2.0, 2.0, 4.0, 2.0)); |
| 186 |
assert_eq!(a.zywy(), F32x4::new(3.0, 2.0, 4.0, 2.0)); |
| 187 |
assert_eq!(a.wywy(), F32x4::new(4.0, 2.0, 4.0, 2.0)); |
| 188 |
assert_eq!(a.xzwy(), F32x4::new(1.0, 3.0, 4.0, 2.0)); |
| 189 |
assert_eq!(a.yzwy(), F32x4::new(2.0, 3.0, 4.0, 2.0)); |
| 190 |
assert_eq!(a.zzwy(), F32x4::new(3.0, 3.0, 4.0, 2.0)); |
| 191 |
assert_eq!(a.wzwy(), F32x4::new(4.0, 3.0, 4.0, 2.0)); |
| 192 |
assert_eq!(a.xwwy(), F32x4::new(1.0, 4.0, 4.0, 2.0)); |
| 193 |
assert_eq!(a.ywwy(), F32x4::new(2.0, 4.0, 4.0, 2.0)); |
| 194 |
assert_eq!(a.zwwy(), F32x4::new(3.0, 4.0, 4.0, 2.0)); |
| 195 |
assert_eq!(a.wwwy(), F32x4::new(4.0, 4.0, 4.0, 2.0)); |
| 196 |
|
| 197 |
assert_eq!(a.xxxw(), F32x4::new(1.0, 1.0, 1.0, 4.0)); |
| 198 |
assert_eq!(a.yxxw(), F32x4::new(2.0, 1.0, 1.0, 4.0)); |
| 199 |
assert_eq!(a.zxxw(), F32x4::new(3.0, 1.0, 1.0, 4.0)); |
| 200 |
assert_eq!(a.wxxw(), F32x4::new(4.0, 1.0, 1.0, 4.0)); |
| 201 |
assert_eq!(a.xyxw(), F32x4::new(1.0, 2.0, 1.0, 4.0)); |
| 202 |
assert_eq!(a.yyxw(), F32x4::new(2.0, 2.0, 1.0, 4.0)); |
| 203 |
assert_eq!(a.zyxw(), F32x4::new(3.0, 2.0, 1.0, 4.0)); |
| 204 |
assert_eq!(a.wyxw(), F32x4::new(4.0, 2.0, 1.0, 4.0)); |
| 205 |
assert_eq!(a.xzxw(), F32x4::new(1.0, 3.0, 1.0, 4.0)); |
| 206 |
assert_eq!(a.yzxw(), F32x4::new(2.0, 3.0, 1.0, 4.0)); |
| 207 |
assert_eq!(a.zzxw(), F32x4::new(3.0, 3.0, 1.0, 4.0)); |
| 208 |
assert_eq!(a.wzxw(), F32x4::new(4.0, 3.0, 1.0, 4.0)); |
| 209 |
assert_eq!(a.xwxw(), F32x4::new(1.0, 4.0, 1.0, 4.0)); |
| 210 |
assert_eq!(a.ywxw(), F32x4::new(2.0, 4.0, 1.0, 4.0)); |
| 211 |
assert_eq!(a.zwxw(), F32x4::new(3.0, 4.0, 1.0, 4.0)); |
| 212 |
assert_eq!(a.wwxw(), F32x4::new(4.0, 4.0, 1.0, 4.0)); |
| 213 |
assert_eq!(a.xxyw(), F32x4::new(1.0, 1.0, 2.0, 4.0)); |
| 214 |
assert_eq!(a.yxyw(), F32x4::new(2.0, 1.0, 2.0, 4.0)); |
| 215 |
assert_eq!(a.zxyw(), F32x4::new(3.0, 1.0, 2.0, 4.0)); |
| 216 |
assert_eq!(a.wxyw(), F32x4::new(4.0, 1.0, 2.0, 4.0)); |
| 217 |
assert_eq!(a.xyyw(), F32x4::new(1.0, 2.0, 2.0, 4.0)); |
| 218 |
assert_eq!(a.yyyw(), F32x4::new(2.0, 2.0, 2.0, 4.0)); |
| 219 |
assert_eq!(a.zyyw(), F32x4::new(3.0, 2.0, 2.0, 4.0)); |
| 220 |
assert_eq!(a.wyyw(), F32x4::new(4.0, 2.0, 2.0, 4.0)); |
| 221 |
assert_eq!(a.xzyw(), F32x4::new(1.0, 3.0, 2.0, 4.0)); |
| 222 |
assert_eq!(a.yzyw(), F32x4::new(2.0, 3.0, 2.0, 4.0)); |
| 223 |
assert_eq!(a.zzyw(), F32x4::new(3.0, 3.0, 2.0, 4.0)); |
| 224 |
assert_eq!(a.wzyw(), F32x4::new(4.0, 3.0, 2.0, 4.0)); |
| 225 |
assert_eq!(a.xwyw(), F32x4::new(1.0, 4.0, 2.0, 4.0)); |
| 226 |
assert_eq!(a.ywyw(), F32x4::new(2.0, 4.0, 2.0, 4.0)); |
| 227 |
assert_eq!(a.zwyw(), F32x4::new(3.0, 4.0, 2.0, 4.0)); |
| 228 |
assert_eq!(a.wwyw(), F32x4::new(4.0, 4.0, 2.0, 4.0)); |
| 229 |
assert_eq!(a.xxzw(), F32x4::new(1.0, 1.0, 3.0, 4.0)); |
| 230 |
assert_eq!(a.yxzw(), F32x4::new(2.0, 1.0, 3.0, 4.0)); |
| 231 |
assert_eq!(a.zxzw(), F32x4::new(3.0, 1.0, 3.0, 4.0)); |
| 232 |
assert_eq!(a.wxzw(), F32x4::new(4.0, 1.0, 3.0, 4.0)); |
| 233 |
assert_eq!(a.xyzw(), F32x4::new(1.0, 2.0, 3.0, 4.0)); |
| 234 |
assert_eq!(a.yyzw(), F32x4::new(2.0, 2.0, 3.0, 4.0)); |
| 235 |
assert_eq!(a.zyzw(), F32x4::new(3.0, 2.0, 3.0, 4.0)); |
| 236 |
assert_eq!(a.wyzw(), F32x4::new(4.0, 2.0, 3.0, 4.0)); |
| 237 |
assert_eq!(a.xzzw(), F32x4::new(1.0, 3.0, 3.0, 4.0)); |
| 238 |
assert_eq!(a.yzzw(), F32x4::new(2.0, 3.0, 3.0, 4.0)); |
| 239 |
assert_eq!(a.zzzw(), F32x4::new(3.0, 3.0, 3.0, 4.0)); |
| 240 |
assert_eq!(a.wzzw(), F32x4::new(4.0, 3.0, 3.0, 4.0)); |
| 241 |
assert_eq!(a.xwzw(), F32x4::new(1.0, 4.0, 3.0, 4.0)); |
| 242 |
assert_eq!(a.ywzw(), F32x4::new(2.0, 4.0, 3.0, 4.0)); |
| 243 |
assert_eq!(a.zwzw(), F32x4::new(3.0, 4.0, 3.0, 4.0)); |
| 244 |
assert_eq!(a.wwzw(), F32x4::new(4.0, 4.0, 3.0, 4.0)); |
| 245 |
assert_eq!(a.xxww(), F32x4::new(1.0, 1.0, 4.0, 4.0)); |
| 246 |
assert_eq!(a.yxww(), F32x4::new(2.0, 1.0, 4.0, 4.0)); |
| 247 |
assert_eq!(a.zxww(), F32x4::new(3.0, 1.0, 4.0, 4.0)); |
| 248 |
assert_eq!(a.wxww(), F32x4::new(4.0, 1.0, 4.0, 4.0)); |
| 249 |
assert_eq!(a.xyww(), F32x4::new(1.0, 2.0, 4.0, 4.0)); |
| 250 |
assert_eq!(a.yyww(), F32x4::new(2.0, 2.0, 4.0, 4.0)); |
| 251 |
assert_eq!(a.zyww(), F32x4::new(3.0, 2.0, 4.0, 4.0)); |
| 252 |
assert_eq!(a.wzww(), F32x4::new(4.0, 3.0, 4.0, 4.0)); |
| 253 |
assert_eq!(a.xzww(), F32x4::new(1.0, 3.0, 4.0, 4.0)); |
| 254 |
assert_eq!(a.yzww(), F32x4::new(2.0, 3.0, 4.0, 4.0)); |
| 255 |
assert_eq!(a.zzww(), F32x4::new(3.0, 3.0, 4.0, 4.0)); |
| 256 |
assert_eq!(a.wzww(), F32x4::new(4.0, 3.0, 4.0, 4.0)); |
| 257 |
assert_eq!(a.xwww(), F32x4::new(1.0, 4.0, 4.0, 4.0)); |
| 258 |
assert_eq!(a.ywww(), F32x4::new(2.0, 4.0, 4.0, 4.0)); |
| 259 |
assert_eq!(a.zwww(), F32x4::new(3.0, 4.0, 4.0, 4.0)); |
| 260 |
|
| 261 |
assert_eq!(a.xxxz(), F32x4::new(1.0, 1.0, 1.0, 3.0)); |
| 262 |
assert_eq!(a.yxxz(), F32x4::new(2.0, 1.0, 1.0, 3.0)); |
| 263 |
assert_eq!(a.zxxz(), F32x4::new(3.0, 1.0, 1.0, 3.0)); |
| 264 |
assert_eq!(a.wxxz(), F32x4::new(4.0, 1.0, 1.0, 3.0)); |
| 265 |
assert_eq!(a.xyxz(), F32x4::new(1.0, 2.0, 1.0, 3.0)); |
| 266 |
assert_eq!(a.yyxz(), F32x4::new(2.0, 2.0, 1.0, 3.0)); |
| 267 |
assert_eq!(a.zyxz(), F32x4::new(3.0, 2.0, 1.0, 3.0)); |
| 268 |
assert_eq!(a.wyxz(), F32x4::new(4.0, 2.0, 1.0, 3.0)); |
| 269 |
assert_eq!(a.xzxz(), F32x4::new(1.0, 3.0, 1.0, 3.0)); |
| 270 |
assert_eq!(a.yzxz(), F32x4::new(2.0, 3.0, 1.0, 3.0)); |
| 271 |
assert_eq!(a.zzxz(), F32x4::new(3.0, 3.0, 1.0, 3.0)); |
| 272 |
assert_eq!(a.wzxz(), F32x4::new(4.0, 3.0, 1.0, 3.0)); |
| 273 |
assert_eq!(a.xwxz(), F32x4::new(1.0, 4.0, 1.0, 3.0)); |
| 274 |
assert_eq!(a.ywxz(), F32x4::new(2.0, 4.0, 1.0, 3.0)); |
| 275 |
assert_eq!(a.zwxz(), F32x4::new(3.0, 4.0, 1.0, 3.0)); |
| 276 |
assert_eq!(a.wwxz(), F32x4::new(4.0, 4.0, 1.0, 3.0)); |
| 277 |
assert_eq!(a.xxyz(), F32x4::new(1.0, 1.0, 2.0, 3.0)); |
| 278 |
assert_eq!(a.yxyz(), F32x4::new(2.0, 1.0, 2.0, 3.0)); |
| 279 |
assert_eq!(a.zxyz(), F32x4::new(3.0, 1.0, 2.0, 3.0)); |
| 280 |
assert_eq!(a.wxyz(), F32x4::new(4.0, 1.0, 2.0, 3.0)); |
| 281 |
assert_eq!(a.xyyz(), F32x4::new(1.0, 2.0, 2.0, 3.0)); |
| 282 |
assert_eq!(a.yyyz(), F32x4::new(2.0, 2.0, 2.0, 3.0)); |
| 283 |
assert_eq!(a.zyyz(), F32x4::new(3.0, 2.0, 2.0, 3.0)); |
| 284 |
assert_eq!(a.wyyz(), F32x4::new(4.0, 2.0, 2.0, 3.0)); |
| 285 |
assert_eq!(a.xzyz(), F32x4::new(1.0, 3.0, 2.0, 3.0)); |
| 286 |
assert_eq!(a.yzyz(), F32x4::new(2.0, 3.0, 2.0, 3.0)); |
| 287 |
assert_eq!(a.zzyz(), F32x4::new(3.0, 3.0, 2.0, 3.0)); |
| 288 |
assert_eq!(a.wzyz(), F32x4::new(4.0, 3.0, 2.0, 3.0)); |
| 289 |
assert_eq!(a.xwyz(), F32x4::new(1.0, 4.0, 2.0, 3.0)); |
| 290 |
assert_eq!(a.ywyz(), F32x4::new(2.0, 4.0, 2.0, 3.0)); |
| 291 |
assert_eq!(a.zwyz(), F32x4::new(3.0, 4.0, 2.0, 3.0)); |
| 292 |
assert_eq!(a.wwyz(), F32x4::new(4.0, 4.0, 2.0, 3.0)); |
| 293 |
assert_eq!(a.xxzz(), F32x4::new(1.0, 1.0, 3.0, 3.0)); |
| 294 |
assert_eq!(a.yxzz(), F32x4::new(2.0, 1.0, 3.0, 3.0)); |
| 295 |
assert_eq!(a.zxzz(), F32x4::new(3.0, 1.0, 3.0, 3.0)); |
| 296 |
assert_eq!(a.wxzz(), F32x4::new(4.0, 1.0, 3.0, 3.0)); |
| 297 |
assert_eq!(a.xyzz(), F32x4::new(1.0, 2.0, 3.0, 3.0)); |
| 298 |
assert_eq!(a.yyzz(), F32x4::new(2.0, 2.0, 3.0, 3.0)); |
| 299 |
assert_eq!(a.zyzz(), F32x4::new(3.0, 2.0, 3.0, 3.0)); |
| 300 |
assert_eq!(a.wyzz(), F32x4::new(4.0, 2.0, 3.0, 3.0)); |
| 301 |
assert_eq!(a.xzzz(), F32x4::new(1.0, 3.0, 3.0, 3.0)); |
| 302 |
assert_eq!(a.yzzz(), F32x4::new(2.0, 3.0, 3.0, 3.0)); |
| 303 |
assert_eq!(a.wzzz(), F32x4::new(4.0, 3.0, 3.0, 3.0)); |
| 304 |
assert_eq!(a.xwzz(), F32x4::new(1.0, 4.0, 3.0, 3.0)); |
| 305 |
assert_eq!(a.ywzz(), F32x4::new(2.0, 4.0, 3.0, 3.0)); |
| 306 |
assert_eq!(a.zwzz(), F32x4::new(3.0, 4.0, 3.0, 3.0)); |
| 307 |
assert_eq!(a.wwzz(), F32x4::new(4.0, 4.0, 3.0, 3.0)); |
| 308 |
assert_eq!(a.xxwz(), F32x4::new(1.0, 1.0, 4.0, 3.0)); |
| 309 |
assert_eq!(a.yxwz(), F32x4::new(2.0, 1.0, 4.0, 3.0)); |
| 310 |
assert_eq!(a.zxwz(), F32x4::new(3.0, 1.0, 4.0, 3.0)); |
| 311 |
assert_eq!(a.wxwz(), F32x4::new(4.0, 1.0, 4.0, 3.0)); |
| 312 |
assert_eq!(a.xywz(), F32x4::new(1.0, 2.0, 4.0, 3.0)); |
| 313 |
assert_eq!(a.yywz(), F32x4::new(2.0, 2.0, 4.0, 3.0)); |
| 314 |
assert_eq!(a.zywz(), F32x4::new(3.0, 2.0, 4.0, 3.0)); |
| 315 |
assert_eq!(a.wywz(), F32x4::new(4.0, 2.0, 4.0, 3.0)); |
| 316 |
assert_eq!(a.xzwz(), F32x4::new(1.0, 3.0, 4.0, 3.0)); |
| 317 |
assert_eq!(a.yzwz(), F32x4::new(2.0, 3.0, 4.0, 3.0)); |
| 318 |
assert_eq!(a.zzwz(), F32x4::new(3.0, 3.0, 4.0, 3.0)); |
| 319 |
assert_eq!(a.wzwz(), F32x4::new(4.0, 3.0, 4.0, 3.0)); |
| 320 |
assert_eq!(a.xwwz(), F32x4::new(1.0, 4.0, 4.0, 3.0)); |
| 321 |
assert_eq!(a.ywwz(), F32x4::new(2.0, 4.0, 4.0, 3.0)); |
| 322 |
assert_eq!(a.zwwz(), F32x4::new(3.0, 4.0, 4.0, 3.0)); |
| 323 |
assert_eq!(a.wwwz(), F32x4::new(4.0, 4.0, 4.0, 3.0)); |
| 324 |
} |
| 325 |
|
| 326 |
#[test] |
| 327 |
fn test_f32x4_concatenations() { |
| 328 |
let a = F32x4::new(4.0, 2.0, 6.0, -1.0); |
| 329 |
let b = F32x4::new(10.0, -3.0, 15.0, 41.0); |
| 330 |
assert_eq!(a.concat_xy_xy(b), F32x4::new(4.0, 2.0, 10.0, -3.0)); |
| 331 |
assert_eq!(a.concat_xy_zw(b), F32x4::new(4.0, 2.0, 15.0, 41.0)); |
| 332 |
assert_eq!(a.concat_zw_zw(b), F32x4::new(6.0, -1.0, 15.0, 41.0)); |
| 333 |
assert_eq!(a.concat_wz_yx(b), F32x4::new(-1.0, 6.0, -3.0, 10.0)); |
| 334 |
} |
| 335 |
|
| 336 |
#[test] |
| 337 |
fn test_f32x4_arithmetic_overloads() { |
| 338 |
let a = F32x4::new(4.0, -1.0, 6.0, -32.0); |
| 339 |
let b = F32x4::new(0.5, 0.5, 10.0, 3.0); |
| 340 |
let a_plus_b = F32x4::new(4.5, -0.5, 16.0, -29.0); |
| 341 |
let a_minus_b = F32x4::new(3.5, -1.5, -4.0, -35.0); |
| 342 |
let a_times_b = F32x4::new(2.0, -0.5, 60.0, -96.0); |
| 343 |
assert_eq!(a + b, a_plus_b); |
| 344 |
assert_eq!(a - b, a_minus_b); |
| 345 |
assert_eq!(a * b, a_times_b); |
| 346 |
let mut c = a; |
| 347 |
c += b; |
| 348 |
assert_eq!(c, a_plus_b); |
| 349 |
c = a; |
| 350 |
c -= b; |
| 351 |
assert_eq!(c, a_minus_b); |
| 352 |
c = a; |
| 353 |
c *= b; |
| 354 |
assert_eq!(c, a_times_b); |
| 355 |
assert_eq!(-a, F32x4::new(-4.0, 1.0, -6.0, 32.0)); |
| 356 |
} |
| 357 |
|
| 358 |
#[test] |
| 359 |
fn test_f32x4_index_overloads() { |
| 360 |
let mut a = F32x4::new(4.0, 1.0, -32.5, 75.0); |
| 361 |
assert_eq!(a[2], -32.5); |
| 362 |
a[3] = 300.0; |
| 363 |
assert_eq!(a[3], 300.0); |
| 364 |
a[0] *= 0.5; |
| 365 |
assert_eq!(a[0], 2.0); |
| 366 |
} |
| 367 |
|
| 368 |
#[test] |
| 369 |
fn test_f32x4_conversions() { |
| 370 |
let a = F32x4::new(48.0, -4.0, 200.0, 7.0); |
| 371 |
assert_eq!(a.to_i32x4(), I32x4::new(48, -4, 200, 7)); |
| 372 |
} |
| 373 |
|
| 374 |
#[test] |
| 375 |
fn test_f32x4_debug() { |
| 376 |
let a = F32x4::new(48.0, -4.0, 200.0, 7.0); |
| 377 |
assert_eq!("<48, -4, 200, 7>", format!("{:?}", a)); |
| 378 |
} |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
#[test] |
| 383 |
fn test_i32x4_constructors() { |
| 384 |
let a = I32x4::new(3, 58, 10, 4); |
| 385 |
assert_eq!((a[0], a[1], a[2], a[3]), (3, 58, 10, 4)); |
| 386 |
let b = I32x4::splat(39); |
| 387 |
assert_eq!(b, I32x4::new(39, 39, 39, 39)); |
| 388 |
} |
| 389 |
|
| 390 |
#[test] |
| 391 |
fn test_i32x4_basic_ops() { |
| 392 |
let a = I32x4::new(6, 29, -40, 2); |
| 393 |
let b = I32x4::new(10, -5, 10, 46); |
| 394 |
assert_eq!(a.min(b), I32x4::new(6, -5, -40, 2)); |
| 395 |
} |
| 396 |
|
| 397 |
#[test] |
| 398 |
fn test_i32x4_packed_comparisons() { |
| 399 |
let a = I32x4::new(59, 1, 5, 63); |
| 400 |
let b = I32x4::new(-59, 1, 5, 104); |
| 401 |
assert_eq!(a.packed_eq(b), U32x4::new(0, !0, !0, 0)); |
| 402 |
} |
| 403 |
|
| 404 |
#[test] |
| 405 |
fn test_i32x4_swizzles() { |
| 406 |
let a = I32x4::new(1, 2, 3, 4); |
| 407 |
assert_eq!(a.xxxx(), I32x4::splat(1)); |
| 408 |
assert_eq!(a.yyyy(), I32x4::splat(2)); |
| 409 |
assert_eq!(a.zzzz(), I32x4::splat(3)); |
| 410 |
assert_eq!(a.wwww(), I32x4::splat(4)); |
| 411 |
|
| 412 |
assert_eq!(a.yxxx(), I32x4::new(2, 1, 1, 1)); |
| 413 |
assert_eq!(a.zxxx(), I32x4::new(3, 1, 1, 1)); |
| 414 |
assert_eq!(a.wxxx(), I32x4::new(4, 1, 1, 1)); |
| 415 |
assert_eq!(a.xyxx(), I32x4::new(1, 2, 1, 1)); |
| 416 |
assert_eq!(a.yyxx(), I32x4::new(2, 2, 1, 1)); |
| 417 |
assert_eq!(a.zyxx(), I32x4::new(3, 2, 1, 1)); |
| 418 |
assert_eq!(a.wyxx(), I32x4::new(4, 2, 1, 1)); |
| 419 |
assert_eq!(a.xzxx(), I32x4::new(1, 3, 1, 1)); |
| 420 |
assert_eq!(a.yzxx(), I32x4::new(2, 3, 1, 1)); |
| 421 |
assert_eq!(a.zzxx(), I32x4::new(3, 3, 1, 1)); |
| 422 |
assert_eq!(a.wzxx(), I32x4::new(4, 3, 1, 1)); |
| 423 |
assert_eq!(a.xwxx(), I32x4::new(1, 4, 1, 1)); |
| 424 |
assert_eq!(a.ywxx(), I32x4::new(2, 4, 1, 1)); |
| 425 |
assert_eq!(a.zwxx(), I32x4::new(3, 4, 1, 1)); |
| 426 |
assert_eq!(a.wwxx(), I32x4::new(4, 4, 1, 1)); |
| 427 |
assert_eq!(a.xxyx(), I32x4::new(1, 1, 2, 1)); |
| 428 |
assert_eq!(a.yxyx(), I32x4::new(2, 1, 2, 1)); |
| 429 |
assert_eq!(a.zxyx(), I32x4::new(3, 1, 2, 1)); |
| 430 |
assert_eq!(a.wxyx(), I32x4::new(4, 1, 2, 1)); |
| 431 |
assert_eq!(a.xyyx(), I32x4::new(1, 2, 2, 1)); |
| 432 |
assert_eq!(a.yyyx(), I32x4::new(2, 2, 2, 1)); |
| 433 |
assert_eq!(a.zyyx(), I32x4::new(3, 2, 2, 1)); |
| 434 |
assert_eq!(a.wyyx(), I32x4::new(4, 2, 2, 1)); |
| 435 |
assert_eq!(a.xzyx(), I32x4::new(1, 3, 2, 1)); |
| 436 |
assert_eq!(a.yzyx(), I32x4::new(2, 3, 2, 1)); |
| 437 |
assert_eq!(a.zzyx(), I32x4::new(3, 3, 2, 1)); |
| 438 |
assert_eq!(a.wzyx(), I32x4::new(4, 3, 2, 1)); |
| 439 |
assert_eq!(a.xwyx(), I32x4::new(1, 4, 2, 1)); |
| 440 |
assert_eq!(a.ywyx(), I32x4::new(2, 4, 2, 1)); |
| 441 |
assert_eq!(a.zwyx(), I32x4::new(3, 4, 2, 1)); |
| 442 |
assert_eq!(a.wwyx(), I32x4::new(4, 4, 2, 1)); |
| 443 |
assert_eq!(a.xxzx(), I32x4::new(1, 1, 3, 1)); |
| 444 |
assert_eq!(a.yxzx(), I32x4::new(2, 1, 3, 1)); |
| 445 |
assert_eq!(a.zxzx(), I32x4::new(3, 1, 3, 1)); |
| 446 |
assert_eq!(a.wxzx(), I32x4::new(4, 1, 3, 1)); |
| 447 |
assert_eq!(a.xyzx(), I32x4::new(1, 2, 3, 1)); |
| 448 |
assert_eq!(a.yyzx(), I32x4::new(2, 2, 3, 1)); |
| 449 |
assert_eq!(a.zyzx(), I32x4::new(3, 2, 3, 1)); |
| 450 |
assert_eq!(a.wyzx(), I32x4::new(4, 2, 3, 1)); |
| 451 |
assert_eq!(a.xzzx(), I32x4::new(1, 3, 3, 1)); |
| 452 |
assert_eq!(a.yzzx(), I32x4::new(2, 3, 3, 1)); |
| 453 |
assert_eq!(a.zzzx(), I32x4::new(3, 3, 3, 1)); |
| 454 |
assert_eq!(a.wzzx(), I32x4::new(4, 3, 3, 1)); |
| 455 |
assert_eq!(a.xwzx(), I32x4::new(1, 4, 3, 1)); |
| 456 |
assert_eq!(a.ywzx(), I32x4::new(2, 4, 3, 1)); |
| 457 |
assert_eq!(a.zwzx(), I32x4::new(3, 4, 3, 1)); |
| 458 |
assert_eq!(a.wwzx(), I32x4::new(4, 4, 3, 1)); |
| 459 |
assert_eq!(a.xxwx(), I32x4::new(1, 1, 4, 1)); |
| 460 |
assert_eq!(a.yxwx(), I32x4::new(2, 1, 4, 1)); |
| 461 |
assert_eq!(a.zxwx(), I32x4::new(3, 1, 4, 1)); |
| 462 |
assert_eq!(a.wxwx(), I32x4::new(4, 1, 4, 1)); |
| 463 |
assert_eq!(a.xywx(), I32x4::new(1, 2, 4, 1)); |
| 464 |
assert_eq!(a.yywx(), I32x4::new(2, 2, 4, 1)); |
| 465 |
assert_eq!(a.zywx(), I32x4::new(3, 2, 4, 1)); |
| 466 |
assert_eq!(a.wywx(), I32x4::new(4, 2, 4, 1)); |
| 467 |
assert_eq!(a.xzwx(), I32x4::new(1, 3, 4, 1)); |
| 468 |
assert_eq!(a.yzwx(), I32x4::new(2, 3, 4, 1)); |
| 469 |
assert_eq!(a.zzwx(), I32x4::new(3, 3, 4, 1)); |
| 470 |
assert_eq!(a.wzwx(), I32x4::new(4, 3, 4, 1)); |
| 471 |
assert_eq!(a.xwwx(), I32x4::new(1, 4, 4, 1)); |
| 472 |
assert_eq!(a.ywwx(), I32x4::new(2, 4, 4, 1)); |
| 473 |
assert_eq!(a.zwwx(), I32x4::new(3, 4, 4, 1)); |
| 474 |
assert_eq!(a.wwwx(), I32x4::new(4, 4, 4, 1)); |
| 475 |
|
| 476 |
assert_eq!(a.xxxy(), I32x4::new(1, 1, 1, 2)); |
| 477 |
assert_eq!(a.yxxy(), I32x4::new(2, 1, 1, 2)); |
| 478 |
assert_eq!(a.zxxy(), I32x4::new(3, 1, 1, 2)); |
| 479 |
assert_eq!(a.wxxy(), I32x4::new(4, 1, 1, 2)); |
| 480 |
assert_eq!(a.xyxy(), I32x4::new(1, 2, 1, 2)); |
| 481 |
assert_eq!(a.yyxy(), I32x4::new(2, 2, 1, 2)); |
| 482 |
assert_eq!(a.zyxy(), I32x4::new(3, 2, 1, 2)); |
| 483 |
assert_eq!(a.wyxy(), I32x4::new(4, 2, 1, 2)); |
| 484 |
assert_eq!(a.xzxy(), I32x4::new(1, 3, 1, 2)); |
| 485 |
assert_eq!(a.yzxy(), I32x4::new(2, 3, 1, 2)); |
| 486 |
assert_eq!(a.zzxy(), I32x4::new(3, 3, 1, 2)); |
| 487 |
assert_eq!(a.wzxy(), I32x4::new(4, 3, 1, 2)); |
| 488 |
assert_eq!(a.xwxy(), I32x4::new(1, 4, 1, 2)); |
| 489 |
assert_eq!(a.ywxy(), I32x4::new(2, 4, 1, 2)); |
| 490 |
assert_eq!(a.zwxy(), I32x4::new(3, 4, 1, 2)); |
| 491 |
assert_eq!(a.wwxy(), I32x4::new(4, 4, 1, 2)); |
| 492 |
assert_eq!(a.xxyy(), I32x4::new(1, 1, 2, 2)); |
| 493 |
assert_eq!(a.yxyy(), I32x4::new(2, 1, 2, 2)); |
| 494 |
assert_eq!(a.zxyy(), I32x4::new(3, 1, 2, 2)); |
| 495 |
assert_eq!(a.wxyy(), I32x4::new(4, 1, 2, 2)); |
| 496 |
assert_eq!(a.xyyy(), I32x4::new(1, 2, 2, 2)); |
| 497 |
assert_eq!(a.zyyy(), I32x4::new(3, 2, 2, 2)); |
| 498 |
assert_eq!(a.wyyy(), I32x4::new(4, 2, 2, 2)); |
| 499 |
assert_eq!(a.xzyy(), I32x4::new(1, 3, 2, 2)); |
| 500 |
assert_eq!(a.yzyy(), I32x4::new(2, 3, 2, 2)); |
| 501 |
assert_eq!(a.zzyy(), I32x4::new(3, 3, 2, 2)); |
| 502 |
assert_eq!(a.wzyy(), I32x4::new(4, 3, 2, 2)); |
| 503 |
assert_eq!(a.xwyy(), I32x4::new(1, 4, 2, 2)); |
| 504 |
assert_eq!(a.ywyy(), I32x4::new(2, 4, 2, 2)); |
| 505 |
assert_eq!(a.zwyy(), I32x4::new(3, 4, 2, 2)); |
| 506 |
assert_eq!(a.wwyy(), I32x4::new(4, 4, 2, 2)); |
| 507 |
assert_eq!(a.xxzy(), I32x4::new(1, 1, 3, 2)); |
| 508 |
assert_eq!(a.yxzy(), I32x4::new(2, 1, 3, 2)); |
| 509 |
assert_eq!(a.zxzy(), I32x4::new(3, 1, 3, 2)); |
| 510 |
assert_eq!(a.wxzy(), I32x4::new(4, 1, 3, 2)); |
| 511 |
assert_eq!(a.xyzy(), I32x4::new(1, 2, 3, 2)); |
| 512 |
assert_eq!(a.yyzy(), I32x4::new(2, 2, 3, 2)); |
| 513 |
assert_eq!(a.zyzy(), I32x4::new(3, 2, 3, 2)); |
| 514 |
assert_eq!(a.wyzy(), I32x4::new(4, 2, 3, 2)); |
| 515 |
assert_eq!(a.xzzy(), I32x4::new(1, 3, 3, 2)); |
| 516 |
assert_eq!(a.yzzy(), I32x4::new(2, 3, 3, 2)); |
| 517 |
assert_eq!(a.zzzy(), I32x4::new(3, 3, 3, 2)); |
| 518 |
assert_eq!(a.wzzy(), I32x4::new(4, 3, 3, 2)); |
| 519 |
assert_eq!(a.xwzy(), I32x4::new(1, 4, 3, 2)); |
| 520 |
assert_eq!(a.ywzy(), I32x4::new(2, 4, 3, 2)); |
| 521 |
assert_eq!(a.zwzy(), I32x4::new(3, 4, 3, 2)); |
| 522 |
assert_eq!(a.wwzy(), I32x4::new(4, 4, 3, 2)); |
| 523 |
assert_eq!(a.xxwy(), I32x4::new(1, 1, 4, 2)); |
| 524 |
assert_eq!(a.yxwy(), I32x4::new(2, 1, 4, 2)); |
| 525 |
assert_eq!(a.zxwy(), I32x4::new(3, 1, 4, 2)); |
| 526 |
assert_eq!(a.wxwy(), I32x4::new(4, 1, 4, 2)); |
| 527 |
assert_eq!(a.xywy(), I32x4::new(1, 2, 4, 2)); |
| 528 |
assert_eq!(a.yywy(), I32x4::new(2, 2, 4, 2)); |
| 529 |
assert_eq!(a.zywy(), I32x4::new(3, 2, 4, 2)); |
| 530 |
assert_eq!(a.wywy(), I32x4::new(4, 2, 4, 2)); |
| 531 |
assert_eq!(a.xzwy(), I32x4::new(1, 3, 4, 2)); |
| 532 |
assert_eq!(a.yzwy(), I32x4::new(2, 3, 4, 2)); |
| 533 |
assert_eq!(a.zzwy(), I32x4::new(3, 3, 4, 2)); |
| 534 |
assert_eq!(a.wzwy(), I32x4::new(4, 3, 4, 2)); |
| 535 |
assert_eq!(a.xwwy(), I32x4::new(1, 4, 4, 2)); |
| 536 |
assert_eq!(a.ywwy(), I32x4::new(2, 4, 4, 2)); |
| 537 |
assert_eq!(a.zwwy(), I32x4::new(3, 4, 4, 2)); |
| 538 |
assert_eq!(a.wwwy(), I32x4::new(4, 4, 4, 2)); |
| 539 |
|
| 540 |
assert_eq!(a.xxxz(), I32x4::new(1, 1, 1, 3)); |
| 541 |
assert_eq!(a.yxxz(), I32x4::new(2, 1, 1, 3)); |
| 542 |
assert_eq!(a.zxxz(), I32x4::new(3, 1, 1, 3)); |
| 543 |
assert_eq!(a.wxxz(), I32x4::new(4, 1, 1, 3)); |
| 544 |
assert_eq!(a.xyxz(), I32x4::new(1, 2, 1, 3)); |
| 545 |
assert_eq!(a.yyxz(), I32x4::new(2, 2, 1, 3)); |
| 546 |
assert_eq!(a.zyxz(), I32x4::new(3, 2, 1, 3)); |
| 547 |
assert_eq!(a.wyxz(), I32x4::new(4, 2, 1, 3)); |
| 548 |
assert_eq!(a.xzxz(), I32x4::new(1, 3, 1, 3)); |
| 549 |
assert_eq!(a.yzxz(), I32x4::new(2, 3, 1, 3)); |
| 550 |
assert_eq!(a.zzxz(), I32x4::new(3, 3, 1, 3)); |
| 551 |
assert_eq!(a.wzxz(), I32x4::new(4, 3, 1, 3)); |
| 552 |
assert_eq!(a.xwxz(), I32x4::new(1, 4, 1, 3)); |
| 553 |
assert_eq!(a.ywxz(), I32x4::new(2, 4, 1, 3)); |
| 554 |
assert_eq!(a.zwxz(), I32x4::new(3, 4, 1, 3)); |
| 555 |
assert_eq!(a.wwxz(), I32x4::new(4, 4, 1, 3)); |
| 556 |
assert_eq!(a.xxyz(), I32x4::new(1, 1, 2, 3)); |
| 557 |
assert_eq!(a.yxyz(), I32x4::new(2, 1, 2, 3)); |
| 558 |
assert_eq!(a.zxyz(), I32x4::new(3, 1, 2, 3)); |
| 559 |
assert_eq!(a.wxyz(), I32x4::new(4, 1, 2, 3)); |
| 560 |
assert_eq!(a.xyyz(), I32x4::new(1, 2, 2, 3)); |
| 561 |
assert_eq!(a.yyyz(), I32x4::new(2, 2, 2, 3)); |
| 562 |
assert_eq!(a.zyyz(), I32x4::new(3, 2, 2, 3)); |
| 563 |
assert_eq!(a.wyyz(), I32x4::new(4, 2, 2, 3)); |
| 564 |
assert_eq!(a.xzyz(), I32x4::new(1, 3, 2, 3)); |
| 565 |
assert_eq!(a.yzyz(), I32x4::new(2, 3, 2, 3)); |
| 566 |
assert_eq!(a.zzyz(), I32x4::new(3, 3, 2, 3)); |
| 567 |
assert_eq!(a.wzyz(), I32x4::new(4, 3, 2, 3)); |
| 568 |
assert_eq!(a.xwyz(), I32x4::new(1, 4, 2, 3)); |
| 569 |
assert_eq!(a.ywyz(), I32x4::new(2, 4, 2, 3)); |
| 570 |
assert_eq!(a.zwyz(), I32x4::new(3, 4, 2, 3)); |
| 571 |
assert_eq!(a.wwyz(), I32x4::new(4, 4, 2, 3)); |
| 572 |
assert_eq!(a.xxzz(), I32x4::new(1, 1, 3, 3)); |
| 573 |
assert_eq!(a.yxzz(), I32x4::new(2, 1, 3, 3)); |
| 574 |
assert_eq!(a.zxzz(), I32x4::new(3, 1, 3, 3)); |
| 575 |
assert_eq!(a.wxzz(), I32x4::new(4, 1, 3, 3)); |
| 576 |
assert_eq!(a.xyzz(), I32x4::new(1, 2, 3, 3)); |
| 577 |
assert_eq!(a.yyzz(), I32x4::new(2, 2, 3, 3)); |
| 578 |
assert_eq!(a.zyzz(), I32x4::new(3, 2, 3, 3)); |
| 579 |
assert_eq!(a.wyzz(), I32x4::new(4, 2, 3, 3)); |
| 580 |
assert_eq!(a.xzzz(), I32x4::new(1, 3, 3, 3)); |
| 581 |
assert_eq!(a.yzzz(), I32x4::new(2, 3, 3, 3)); |
| 582 |
assert_eq!(a.wzzz(), I32x4::new(4, 3, 3, 3)); |
| 583 |
assert_eq!(a.xwzz(), I32x4::new(1, 4, 3, 3)); |
| 584 |
assert_eq!(a.ywzz(), I32x4::new(2, 4, 3, 3)); |
| 585 |
assert_eq!(a.zwzz(), I32x4::new(3, 4, 3, 3)); |
| 586 |
assert_eq!(a.wwzz(), I32x4::new(4, 4, 3, 3)); |
| 587 |
assert_eq!(a.xxwz(), I32x4::new(1, 1, 4, 3)); |
| 588 |
assert_eq!(a.yxwz(), I32x4::new(2, 1, 4, 3)); |
| 589 |
assert_eq!(a.zxwz(), I32x4::new(3, 1, 4, 3)); |
| 590 |
assert_eq!(a.wxwz(), I32x4::new(4, 1, 4, 3)); |
| 591 |
assert_eq!(a.xywz(), I32x4::new(1, 2, 4, 3)); |
| 592 |
assert_eq!(a.yywz(), I32x4::new(2, 2, 4, 3)); |
| 593 |
assert_eq!(a.zywz(), I32x4::new(3, 2, 4, 3)); |
| 594 |
assert_eq!(a.wywz(), I32x4::new(4, 2, 4, 3)); |
| 595 |
assert_eq!(a.xzwz(), I32x4::new(1, 3, 4, 3)); |
| 596 |
assert_eq!(a.yzwz(), I32x4::new(2, 3, 4, 3)); |
| 597 |
assert_eq!(a.zzwz(), I32x4::new(3, 3, 4, 3)); |
| 598 |
assert_eq!(a.wzwz(), I32x4::new(4, 3, 4, 3)); |
| 599 |
assert_eq!(a.xwwz(), I32x4::new(1, 4, 4, 3)); |
| 600 |
assert_eq!(a.ywwz(), I32x4::new(2, 4, 4, 3)); |
| 601 |
assert_eq!(a.zwwz(), I32x4::new(3, 4, 4, 3)); |
| 602 |
assert_eq!(a.wwwz(), I32x4::new(4, 4, 4, 3)); |
| 603 |
|
| 604 |
assert_eq!(a.xxxw(), I32x4::new(1, 1, 1, 4)); |
| 605 |
assert_eq!(a.yxxw(), I32x4::new(2, 1, 1, 4)); |
| 606 |
assert_eq!(a.zxxw(), I32x4::new(3, 1, 1, 4)); |
| 607 |
assert_eq!(a.wxxw(), I32x4::new(4, 1, 1, 4)); |
| 608 |
assert_eq!(a.xyxw(), I32x4::new(1, 2, 1, 4)); |
| 609 |
assert_eq!(a.yyxw(), I32x4::new(2, 2, 1, 4)); |
| 610 |
assert_eq!(a.zyxw(), I32x4::new(3, 2, 1, 4)); |
| 611 |
assert_eq!(a.wyxw(), I32x4::new(4, 2, 1, 4)); |
| 612 |
assert_eq!(a.xzxw(), I32x4::new(1, 3, 1, 4)); |
| 613 |
assert_eq!(a.yzxw(), I32x4::new(2, 3, 1, 4)); |
| 614 |
assert_eq!(a.zzxw(), I32x4::new(3, 3, 1, 4)); |
| 615 |
assert_eq!(a.wzxw(), I32x4::new(4, 3, 1, 4)); |
| 616 |
assert_eq!(a.xwxw(), I32x4::new(1, 4, 1, 4)); |
| 617 |
assert_eq!(a.ywxw(), I32x4::new(2, 4, 1, 4)); |
| 618 |
assert_eq!(a.zwxw(), I32x4::new(3, 4, 1, 4)); |
| 619 |
assert_eq!(a.wwxw(), I32x4::new(4, 4, 1, 4)); |
| 620 |
assert_eq!(a.xxyw(), I32x4::new(1, 1, 2, 4)); |
| 621 |
assert_eq!(a.yxyw(), I32x4::new(2, 1, 2, 4)); |
| 622 |
assert_eq!(a.zxyw(), I32x4::new(3, 1, 2, 4)); |
| 623 |
assert_eq!(a.wxyw(), I32x4::new(4, 1, 2, 4)); |
| 624 |
assert_eq!(a.xyyw(), I32x4::new(1, 2, 2, 4)); |
| 625 |
assert_eq!(a.yyyw(), I32x4::new(2, 2, 2, 4)); |
| 626 |
assert_eq!(a.zyyw(), I32x4::new(3, 2, 2, 4)); |
| 627 |
assert_eq!(a.wyyw(), I32x4::new(4, 2, 2, 4)); |
| 628 |
assert_eq!(a.xzyw(), I32x4::new(1, 3, 2, 4)); |
| 629 |
assert_eq!(a.yzyw(), I32x4::new(2, 3, 2, 4)); |
| 630 |
assert_eq!(a.zzyw(), I32x4::new(3, 3, 2, 4)); |
| 631 |
assert_eq!(a.wzyw(), I32x4::new(4, 3, 2, 4)); |
| 632 |
assert_eq!(a.xwyw(), I32x4::new(1, 4, 2, 4)); |
| 633 |
assert_eq!(a.ywyw(), I32x4::new(2, 4, 2, 4)); |
| 634 |
assert_eq!(a.zwyw(), I32x4::new(3, 4, 2, 4)); |
| 635 |
assert_eq!(a.wwyw(), I32x4::new(4, 4, 2, 4)); |
| 636 |
assert_eq!(a.xxzw(), I32x4::new(1, 1, 3, 4)); |
| 637 |
assert_eq!(a.yxzw(), I32x4::new(2, 1, 3, 4)); |
| 638 |
assert_eq!(a.zxzw(), I32x4::new(3, 1, 3, 4)); |
| 639 |
assert_eq!(a.wxzw(), I32x4::new(4, 1, 3, 4)); |
| 640 |
assert_eq!(a.xyzw(), I32x4::new(1, 2, 3, 4)); |
| 641 |
assert_eq!(a.yyzw(), I32x4::new(2, 2, 3, 4)); |
| 642 |
assert_eq!(a.zyzw(), I32x4::new(3, 2, 3, 4)); |
| 643 |
assert_eq!(a.wyzw(), I32x4::new(4, 2, 3, 4)); |
| 644 |
assert_eq!(a.xzzw(), I32x4::new(1, 3, 3, 4)); |
| 645 |
assert_eq!(a.yzzw(), I32x4::new(2, 3, 3, 4)); |
| 646 |
assert_eq!(a.zzzw(), I32x4::new(3, 3, 3, 4)); |
| 647 |
assert_eq!(a.wzzw(), I32x4::new(4, 3, 3, 4)); |
| 648 |
assert_eq!(a.xwzw(), I32x4::new(1, 4, 3, 4)); |
| 649 |
assert_eq!(a.ywzw(), I32x4::new(2, 4, 3, 4)); |
| 650 |
assert_eq!(a.zwzw(), I32x4::new(3, 4, 3, 4)); |
| 651 |
assert_eq!(a.wwzw(), I32x4::new(4, 4, 3, 4)); |
| 652 |
assert_eq!(a.xxww(), I32x4::new(1, 1, 4, 4)); |
| 653 |
assert_eq!(a.yxww(), I32x4::new(2, 1, 4, 4)); |
| 654 |
assert_eq!(a.zxww(), I32x4::new(3, 1, 4, 4)); |
| 655 |
assert_eq!(a.wxww(), I32x4::new(4, 1, 4, 4)); |
| 656 |
assert_eq!(a.xyww(), I32x4::new(1, 2, 4, 4)); |
| 657 |
assert_eq!(a.yyww(), I32x4::new(2, 2, 4, 4)); |
| 658 |
assert_eq!(a.zyww(), I32x4::new(3, 2, 4, 4)); |
| 659 |
assert_eq!(a.wzww(), I32x4::new(4, 3, 4, 4)); |
| 660 |
assert_eq!(a.xzww(), I32x4::new(1, 3, 4, 4)); |
| 661 |
assert_eq!(a.yzww(), I32x4::new(2, 3, 4, 4)); |
| 662 |
assert_eq!(a.zzww(), I32x4::new(3, 3, 4, 4)); |
| 663 |
assert_eq!(a.wzww(), I32x4::new(4, 3, 4, 4)); |
| 664 |
assert_eq!(a.xwww(), I32x4::new(1, 4, 4, 4)); |
| 665 |
assert_eq!(a.ywww(), I32x4::new(2, 4, 4, 4)); |
| 666 |
assert_eq!(a.zwww(), I32x4::new(3, 4, 4, 4)); |
| 667 |
} |
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
#[test] |
| 672 |
fn test_f32x4s_constructors() { |
| 673 |
let a = F32x4S::new(1.0, 2.0, 3.0, 4.0); |
| 674 |
assert_eq!((a[0], a[1], a[2], a[3]), (1.0, 2.0, 3.0, 4.0)); |
| 675 |
let b = F32x4S::splat(10.0); |
| 676 |
assert_eq!(b, F32x4S::new(10.0, 10.0, 10.0, 10.0)); |
| 677 |
} |
| 678 |
|
| 679 |
#[test] |
| 680 |
fn test_f32x4s_basic_ops() { |
| 681 |
let a = F32x4S::new(1.0, 3.0, 5.0, 7.0); |
| 682 |
let b = F32x4S::new(2.0, 2.0, 6.0, 6.0); |
| 683 |
assert_eq!(a.min(b), F32x4S::new(1.0, 2.0, 5.0, 6.0)); |
| 684 |
assert_eq!(a.max(b), F32x4S::new(2.0, 3.0, 6.0, 7.0)); |
| 685 |
let c = F32x4S::new(-1.0, 1.3, -20.0, 3.6); |
| 686 |
assert_eq!(c.abs(), F32x4S::new(1.0, 1.3, 20.0, 3.6)); |
| 687 |
assert_eq!(c.floor(), F32x4S::new(-1.0, 1.0, -20.0, 3.0)); |
| 688 |
assert_eq!(c.ceil(), F32x4S::new(-1.0, 2.0, -20.0, 4.0)); |
| 689 |
assert_eq!(c.to_i32x4().to_f32x4(), F32x4S::new(-1.0, 1.0, -20.0, 4.0)); |
| 690 |
} |