зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1123643: Fix typo in float64x2 ctor and add test cases; r=till
--HG-- extra : rebase_source : a21dccaa2af04d623f002f7f3cb693d6611ae4ea extra : amend_source : 640dde0724252f5421179a550d74bb9093c30d27
This commit is contained in:
Родитель
d7f9c27adb
Коммит
82fdaebf07
|
@ -384,9 +384,10 @@ SimdTypeDescr::call(JSContext *cx, unsigned argc, Value *vp)
|
|||
case SimdTypeDescr::TYPE_FLOAT64: {
|
||||
double *mem = reinterpret_cast<double*>(result->typedMem());
|
||||
for (unsigned i = 0; i < 2; i++) {
|
||||
if (!ToNumber(cx, args[i], &mem[i]))
|
||||
if (!ToNumber(cx, args.get(i), &mem[i]))
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
args.rval().setObject(*result);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var float32x4 = SIMD.float32x4;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
function test() {
|
||||
|
||||
function TestInt32x4Ctor() {
|
||||
// Constructors.
|
||||
assertEqX4(int32x4(1, 2, 3, 4), [1,2,3,4]);
|
||||
assertEqX4(int32x4(1, 2, 3), [1,2,3,0]);
|
||||
|
@ -14,14 +14,6 @@ function test() {
|
|||
assertEqX4(int32x4(1, 2, 3, 4, 5), [1,2,3,4]);
|
||||
assertEqX4(int32x4(1, 2, 3, 4, 5, 6), [1,2,3,4]);
|
||||
|
||||
assertEqX4(float32x4(1, 2, 3, 4), [1,2,3,4]);
|
||||
assertEqX4(float32x4(1, 2, 3), [1,2,3,NaN]);
|
||||
assertEqX4(float32x4(1, 2), [1,2,NaN,NaN]);
|
||||
// The 1-argument form is reserved for coercions.
|
||||
assertEqX4(float32x4(), [NaN,NaN,NaN,NaN]);
|
||||
assertEqX4(float32x4(1, 2, 3, 4, 5), [1,2,3,4]);
|
||||
assertEqX4(float32x4(1, 2, 3, 4, 5, 6), [1,2,3,4]);
|
||||
|
||||
// Constructors used as coercion.
|
||||
var x = int32x4(1, 2, 3, 4);
|
||||
var y = int32x4(x);
|
||||
|
@ -39,7 +31,18 @@ function test() {
|
|||
|
||||
assertThrowsInstanceOf(() => int32x4(3), TypeError);
|
||||
assertThrowsInstanceOf(() => int32x4(float32x4(1,2,3,4)), TypeError);
|
||||
assertThrowsInstanceOf(() => int32x4(float64x2(1,2)), TypeError);
|
||||
assertThrowsInstanceOf(() => int32x4('pony x 4'), TypeError);
|
||||
}
|
||||
|
||||
function TestFloat32x4Ctor() {
|
||||
assertEqX4(float32x4(1, 2, 3, 4), [1,2,3,4]);
|
||||
assertEqX4(float32x4(1, 2, 3), [1,2,3,NaN]);
|
||||
assertEqX4(float32x4(1, 2), [1,2,NaN,NaN]);
|
||||
// The 1-argument form is reserved for coercions.
|
||||
assertEqX4(float32x4(), [NaN,NaN,NaN,NaN]);
|
||||
assertEqX4(float32x4(1, 2, 3, 4, 5), [1,2,3,4]);
|
||||
assertEqX4(float32x4(1, 2, 3, 4, 5, 6), [1,2,3,4]);
|
||||
|
||||
var x = float32x4(NaN, 13.37, -Infinity, 4);
|
||||
var y = float32x4(x);
|
||||
|
@ -57,10 +60,43 @@ function test() {
|
|||
|
||||
assertThrowsInstanceOf(() => float32x4(3), TypeError);
|
||||
assertThrowsInstanceOf(() => float32x4(int32x4(1,2,3,4)), TypeError);
|
||||
assertThrowsInstanceOf(() => float32x4(float64x2(1,2)), TypeError);
|
||||
assertThrowsInstanceOf(() => float32x4('pony x 4'), TypeError);
|
||||
}
|
||||
|
||||
function TestFloat64x2Ctor() {
|
||||
assertEqX2(float64x2(1, 2), [1,2]);
|
||||
// The 1-argument form is reserved for coercions.
|
||||
assertEqX2(float64x2(), [NaN,NaN]);
|
||||
assertEqX2(float64x2(1, 2, 3), [1,2]);
|
||||
assertEqX2(float64x2(1, 2, 3, 4), [1,2]);
|
||||
assertEqX2(float64x2(1, 2, 3, 4, 5), [1,2]);
|
||||
assertEqX2(float64x2(1, 2, 3, 4, 5), [1,2]);
|
||||
assertEqX2(float64x2(1, 2, 3, 4, 5, 6), [1,2]);
|
||||
|
||||
var x = float64x2(NaN, 13.37);
|
||||
var y = float64x2(x);
|
||||
|
||||
assertEq(x, y);
|
||||
|
||||
assertEq(y.x, x.x);
|
||||
assertEq(y.x, NaN);
|
||||
assertEq(y.y, x.y);
|
||||
assertEq(y.y, 13.37);
|
||||
|
||||
assertThrowsInstanceOf(() => float64x2(3), TypeError);
|
||||
assertThrowsInstanceOf(() => float64x2(int32x4(1,2,3,4)), TypeError);
|
||||
assertThrowsInstanceOf(() => float64x2(float32x4(1,2,3,4)), TypeError);
|
||||
assertThrowsInstanceOf(() => float64x2('pony x 4'), TypeError);
|
||||
}
|
||||
|
||||
function test() {
|
||||
TestFloat32x4Ctor();
|
||||
TestInt32x4Ctor();
|
||||
TestFloat64x2Ctor();
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче