|
| 1 | +describe(module.id, function () { |
| 2 | + it("simd_float4x4Matrix", function(){ |
| 3 | + var simdMatrix = getMatrixFloat4x4(); |
| 4 | + for (var i = 0; i < 16; i++) { |
| 5 | + expect(simdMatrix.columns[i%4][Math.floor(i/4)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 6 | + } |
| 7 | + }); |
| 8 | + |
| 9 | + it("simd_float4x3Matrix", function(){ |
| 10 | + var simdMatrix = getMatrixFloat4x3(); |
| 11 | + for (var i = 0; i < 12; i++) { |
| 12 | + expect(simdMatrix.columns[i%4][Math.floor(i/4)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 13 | + } |
| 14 | + }); |
| 15 | + |
| 16 | + it("simd_float4x2Matrix", function(){ |
| 17 | + var simdMatrix = getMatrixFloat4x2(); |
| 18 | + for (var i = 0; i < 8; i++) { |
| 19 | + expect(simdMatrix.columns[i%4][Math.floor(i/4)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 20 | + } |
| 21 | + }); |
| 22 | + |
| 23 | + it("simd_float3x4Matrix", function(){ |
| 24 | + var simdMatrix = getMatrixFloat3x4(); |
| 25 | + for (var i = 0; i < 12; i++) { |
| 26 | + expect(simdMatrix.columns[i%3][Math.floor(i/3)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 27 | + } |
| 28 | + }); |
| 29 | + |
| 30 | + it("simd_float3x3Matrix", function(){ |
| 31 | + var simdMatrix = getMatrixFloat3x3(); |
| 32 | + for (var i = 0; i < 9; i++) { |
| 33 | + expect(simdMatrix.columns[i%3][Math.floor(i/3)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 34 | + } |
| 35 | + }); |
| 36 | + |
| 37 | + it("simd_float3x2Matrix", function(){ |
| 38 | + var simdMatrix = getMatrixFloat3x2(); |
| 39 | + for (var i = 0; i < 6; i++) { |
| 40 | + expect(simdMatrix.columns[i%3][Math.floor(i/3)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 41 | + } |
| 42 | + }); |
| 43 | + |
| 44 | + it("simd_float2x4Matrix", function(){ |
| 45 | + var simdMatrix = getMatrixFloat2x4(); |
| 46 | + for (var i = 0; i < 8; i++) { |
| 47 | + expect(simdMatrix.columns[i%2][Math.floor(i/2)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 48 | + } |
| 49 | + }); |
| 50 | + |
| 51 | + it("simd_float2x3Matrix", function(){ |
| 52 | + var simdMatrix = getMatrixFloat2x3(); |
| 53 | + for (var i = 0; i < 6; i++) { |
| 54 | + expect(simdMatrix.columns[i%2][Math.floor(i/2)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 55 | + } |
| 56 | + }); |
| 57 | + |
| 58 | + it("simd_float2x2Matrix", function(){ |
| 59 | + var simdMatrix = getMatrixFloat2x2(); |
| 60 | + for (var i = 0; i < 4; i++) { |
| 61 | + expect(simdMatrix.columns[i%2][Math.floor(i/2)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 62 | + } |
| 63 | + }); |
| 64 | + |
| 65 | + it("simd_double4x4Matrix", function(){ |
| 66 | + var simdMatrix = getMatrixDouble4x4(); |
| 67 | + for (var i = 0; i < 16; i++) { |
| 68 | + expect(simdMatrix.columns[i%4][Math.floor(i/4)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 69 | + } |
| 70 | + }); |
| 71 | + |
| 72 | + it("simd_double4x3Matrix", function(){ |
| 73 | + var simdMatrix = getMatrixDouble4x3(); |
| 74 | + for (var i = 0; i < 12; i++) { |
| 75 | + expect(simdMatrix.columns[i%4][Math.floor(i/4)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 76 | + } |
| 77 | + }); |
| 78 | + |
| 79 | + it("simd_double4x2Matrix", function(){ |
| 80 | + var simdMatrix = getMatrixDouble4x2(); |
| 81 | + for (var i = 0; i < 8; i++) { |
| 82 | + expect(simdMatrix.columns[i%4][Math.floor(i/4)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 83 | + } |
| 84 | + }); |
| 85 | + |
| 86 | + it("simd_double3x4Matrix", function(){ |
| 87 | + var simdMatrix = getMatrixDouble3x4(); |
| 88 | + for (var i = 0; i < 12; i++) { |
| 89 | + expect(simdMatrix.columns[i%3][Math.floor(i/3)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 90 | + } |
| 91 | + }); |
| 92 | + |
| 93 | + it("simd_double3x3Matrix", function(){ |
| 94 | + var simdMatrix = getMatrixDouble3x3(); |
| 95 | + for (var i = 0; i < 9; i++) { |
| 96 | + expect(simdMatrix.columns[i%3][Math.floor(i/3)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 97 | + } |
| 98 | + }); |
| 99 | + |
| 100 | + it("simd_double3x2Matrix", function(){ |
| 101 | + var simdMatrix = getMatrixDouble3x2(); |
| 102 | + for (var i = 0; i < 6; i++) { |
| 103 | + expect(simdMatrix.columns[i%3][Math.floor(i/3)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 104 | + } |
| 105 | + }); |
| 106 | + |
| 107 | + it("simd_double2x4Matrix", function(){ |
| 108 | + var simdMatrix = getMatrixDouble2x4(); |
| 109 | + for (var i = 0; i < 8; i++) { |
| 110 | + expect(simdMatrix.columns[i%2][Math.floor(i/2)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 111 | + } |
| 112 | + }); |
| 113 | + |
| 114 | + it("simd_double2x3Matrix", function(){ |
| 115 | + var simdMatrix = getMatrixDouble2x3(); |
| 116 | + for (var i = 0; i < 6; i++) { |
| 117 | + expect(simdMatrix.columns[i%2][Math.floor(i/2)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 118 | + } |
| 119 | + }); |
| 120 | + |
| 121 | + it("simd_double2x2Matrix", function(){ |
| 122 | + var simdMatrix = getMatrixDouble2x2(); |
| 123 | + for (var i = 0; i < 4; i++) { |
| 124 | + expect(simdMatrix.columns[i%2][Math.floor(i/2)].toFixed(4)).toBe((i*3.1415).toFixed(4)); |
| 125 | + } |
| 126 | + }); |
| 127 | + |
| 128 | + it("SCNMatrix4FromMat4", function() { |
| 129 | + const m1 = getMatrixFloat4x4(); |
| 130 | + const m2 = _SCNMatrix4FromMat4(m1); |
| 131 | + |
| 132 | + for (let col = 0; col < 4; col++) { |
| 133 | + for (let row = 0; row < 4; row++) { |
| 134 | + expect(m2[`m${col+1}${row+1}`].toFixed(4)).toBe((m1.columns[col][row]).toFixed(4)); |
| 135 | + } |
| 136 | + } |
| 137 | + }); |
| 138 | + |
| 139 | + it("SCNMatrix4ToMat4", function() { |
| 140 | + const m1 = {}; |
| 141 | + for (let col = 0; col < 4; col++) { |
| 142 | + for (let row = 0; row < 4; row++) { |
| 143 | + m1[`m${col+1}${row+1}`] = 3.1415*(row*4 + col); |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + const m2 = _SCNMatrix4ToMat4(m1); |
| 148 | + |
| 149 | + for (let col = 0; col < 4; col++) { |
| 150 | + for (let row = 0; row < 4; row++) { |
| 151 | + expect((m2.columns[col][row]).toFixed(4)).toBe(m1[`m${col+1}${row+1}`].toFixed(4)); |
| 152 | + } |
| 153 | + } |
| 154 | + }); |
| 155 | + }); |
0 commit comments