fix TypedArray.prototype.sort test (#2326)

* fix TypedArray.prototype.sort test

* Update sorted-values.js

* Update sorted-values.js
This commit is contained in:
Gus Caplan 2019-09-04 09:36:51 -05:00 committed by Leo Balter
parent b63cdfd4f4
commit 841b32c6da
1 changed files with 10 additions and 6 deletions

View File

@ -25,11 +25,18 @@ testWithTypedArrayConstructors(function(TA) {
sample = new TA([3, 4, 3, 1, 0, 1, 2]).sort(); sample = new TA([3, 4, 3, 1, 0, 1, 2]).sort();
assert(compareArray(sample, [0, 1, 1, 2, 3, 3, 4]), "repeating numbers"); assert(compareArray(sample, [0, 1, 1, 2, 3, 3, 4]), "repeating numbers");
sample = new TA([1, 0, -0, 2]).sort();
assert(compareArray(sample, [0, 0, 1, 2]), "0s");
}); });
testWithTypedArrayConstructors(function(TA) {
var sample = new TA([1, 0, -0, 2]).sort();
assert(compareArray(sample, [-0, 0, 1, 2]), "0s");
}, floatArrayConstructors);
testWithTypedArrayConstructors(function(TA) {
var sample = new TA([1, 0, -0, 2]).sort();
assert(compareArray(sample, [0, 0, 1, 2]), "0s");
}, intArrayConstructors);
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample = new TA([-4, 3, 4, -3, 2, -2, 1, 0]).sort(); var sample = new TA([-4, 3, 4, -3, 2, -2, 1, 0]).sort();
assert(compareArray(sample, [-4, -3, -2, 0, 1, 2, 3, 4]), "negative values"); assert(compareArray(sample, [-4, -3, -2, 0, 1, 2, 3, 4]), "negative values");
@ -44,9 +51,6 @@ testWithTypedArrayConstructors(function(TA) {
sample = new TA([0.5, 0, 1.5, -0.5, -1, -1.5, 1]).sort(); sample = new TA([0.5, 0, 1.5, -0.5, -1, -1.5, 1]).sort();
assert(compareArray(sample, [-1.5, -1, -0.5, 0, 0.5, 1, 1.5]), "non integers + negatives"); assert(compareArray(sample, [-1.5, -1, -0.5, 0, 0.5, 1, 1.5]), "non integers + negatives");
sample = new TA([1, 0, -0, 2]).sort();
assert(compareArray(sample, [0, 0, 1, 2]), "0 and -0");
sample = new TA([3, 4, Infinity, -Infinity, 1, 2]).sort(); sample = new TA([3, 4, Infinity, -Infinity, 1, 2]).sort();
assert(compareArray(sample, [-Infinity, 1, 2, 3, 4, Infinity]), "infinities"); assert(compareArray(sample, [-Infinity, 1, 2, 3, 4, Infinity]), "infinities");