Skip to content

Commit

Permalink
fixup! Add tests for TypedArrays constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
leobalter committed Feb 4, 2016
1 parent e74fbbb commit ed387f2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/built-ins/TypedArrays/object-argument-returns.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,28 @@ features: [Symbol]
---*/

var obj = {
"0": null,
"2": 42,
"3": "7",
"4": Symbol("1"),
length: 4
"4": NaN,
"5": Symbol("1"),
length: 5
};

testWithTypedArrayConstructors(function(TA) {
var typedArray = new TA(obj);
assert.sameValue(typedArray.length, 4);
assert.sameValue(typedArray[0], 0);
assert.sameValue(typedArray[2], 42);
assert.sameValue(typedArray[3], 7);
assert.sameValue(typedArray[5], undefined);
assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);

if (TA === Float32Array || TA === Float64Array) {
assert.sameValue(typedArray[1], NaN);
assert.sameValue(typedArray[4], NaN);
} else {
assert.sameValue(typedArray[1], 0);
assert.sameValue(typedArray[4], 0);
}
});

0 comments on commit ed387f2

Please sign in to comment.