[TypedArrays] Apply code consistency fixes after checks with JSHint

This commit is contained in:
Leonardo Balter 2016-04-28 18:11:42 -04:00 committed by Mike Pennisi
parent 56b988883e
commit f912927b1f
35 changed files with 49 additions and 59 deletions

View File

@ -46,7 +46,7 @@ assert.throws(TypeError, function() {
TypedArray.from(arrayLike, true); TypedArray.from(arrayLike, true);
}, "mapfn is a boolean"); }, "mapfn is a boolean");
var s = Symbol("1") var s = Symbol("1");
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
TypedArray.from(arrayLike, s); TypedArray.from(arrayLike, s);
}, "mapfn is a symbol"); }, "mapfn is a symbol");

View File

@ -24,7 +24,7 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)"); assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)");
var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT);
var sample = new TA(buffer2, offset) var sample = new TA(buffer2, offset);
var ta3 = new TA(sample); var ta3 = new TA(sample);
assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)"); assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)");
}); });

View File

@ -27,7 +27,6 @@ includes: [testTypedArray.js]
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample = new TA([42, 43, 44]); var sample = new TA([42, 43, 44]);
var calls = 0;
sample.every(function(v, i) { sample.every(function(v, i) {
if (i < sample.length - 1) { if (i < sample.length - 1) {

View File

@ -44,5 +44,5 @@ testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
sample.fill(s); sample.fill(s);
}) });
}); });

View File

@ -33,7 +33,7 @@ testWithTypedArrayConstructors(function(TA) {
var sample = new TA(3); var sample = new TA(3);
var called = 0; var called = 0;
var result = sample.find(function(val) { var result = sample.find(function() {
called++; called++;
return false; return false;
}); });
@ -41,21 +41,21 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(called, 3, "predicate was called three times"); assert.sameValue(called, 3, "predicate was called three times");
assert.sameValue(result, undefined); assert.sameValue(result, undefined);
result = sample.find(function(val) { return ""; }); result = sample.find(function() { return ""; });
assert.sameValue(result, undefined, "ToBoolean(empty string)"); assert.sameValue(result, undefined, "ToBoolean(empty string)");
result = sample.find(function(val) { return undefined; }); result = sample.find(function() { return undefined; });
assert.sameValue(result, undefined, "ToBoolean(undefined)"); assert.sameValue(result, undefined, "ToBoolean(undefined)");
result = sample.find(function(val) { return null; }); result = sample.find(function() { return null; });
assert.sameValue(result, undefined, "ToBoolean(null)"); assert.sameValue(result, undefined, "ToBoolean(null)");
result = sample.find(function(val) { return 0; }); result = sample.find(function() { return 0; });
assert.sameValue(result, undefined, "ToBoolean(0)"); assert.sameValue(result, undefined, "ToBoolean(0)");
result = sample.find(function(val) { return -0; }); result = sample.find(function() { return -0; });
assert.sameValue(result, undefined, "ToBoolean(-0)"); assert.sameValue(result, undefined, "ToBoolean(-0)");
result = sample.find(function(val) { return NaN; }); result = sample.find(function() { return NaN; });
assert.sameValue(result, undefined, "ToBoolean(NaN)"); assert.sameValue(result, undefined, "ToBoolean(NaN)");
}); });

View File

@ -30,7 +30,7 @@ testWithTypedArrayConstructors(function(TA) {
var sample = new TA([1, 2, 3]); var sample = new TA([1, 2, 3]);
var called = 0; var called = 0;
var result = sample.findIndex(function(val) { var result = sample.findIndex(function() {
called++; called++;
return false; return false;
}); });
@ -38,21 +38,21 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(called, 3, "predicate was called three times"); assert.sameValue(called, 3, "predicate was called three times");
assert.sameValue(result, -1, "result is -1 when predicate returns are false"); assert.sameValue(result, -1, "result is -1 when predicate returns are false");
result = sample.findIndex(function(val) { return ""; }); result = sample.findIndex(function() { return ""; });
assert.sameValue(result, -1, "ToBoolean(string)"); assert.sameValue(result, -1, "ToBoolean(string)");
result = sample.findIndex(function(val) { return undefined; }); result = sample.findIndex(function() { return undefined; });
assert.sameValue(result, -1, "ToBoolean(undefined)"); assert.sameValue(result, -1, "ToBoolean(undefined)");
result = sample.findIndex(function(val) { return null; }); result = sample.findIndex(function() { return null; });
assert.sameValue(result, -1, "ToBoolean(null)"); assert.sameValue(result, -1, "ToBoolean(null)");
result = sample.findIndex(function(val) { return 0; }); result = sample.findIndex(function() { return 0; });
assert.sameValue(result, -1, "ToBoolean(0)"); assert.sameValue(result, -1, "ToBoolean(0)");
result = sample.findIndex(function(val) { return -0; }); result = sample.findIndex(function() { return -0; });
assert.sameValue(result, -1, "ToBoolean(-0)"); assert.sameValue(result, -1, "ToBoolean(-0)");
result = sample.findIndex(function(val) { return NaN; }); result = sample.findIndex(function() { return NaN; });
assert.sameValue(result, -1, "ToBoolean(NaN)"); assert.sameValue(result, -1, "ToBoolean(NaN)");
}); });

View File

@ -27,7 +27,7 @@ includes: [testTypedArray.js]
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var called = 0; var called = 0;
var result1 = new TA().forEach(function() { new TA().forEach(function() {
called++; called++;
}); });

View File

@ -28,5 +28,5 @@ testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
sample.indexOf(7, fromIndex); sample.indexOf(7, fromIndex);
}) });
}); });

View File

@ -31,5 +31,5 @@ testWithTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
sample.indexOf(7, fromIndex); sample.indexOf(7, fromIndex);
}) });
}); });

View File

@ -28,5 +28,5 @@ testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
sample.lastIndexOf(7, fromIndex); sample.lastIndexOf(7, fromIndex);
}) });
}); });

View File

@ -31,5 +31,5 @@ testWithTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
sample.lastIndexOf(7, fromIndex); sample.lastIndexOf(7, fromIndex);
}) });
}); });

View File

@ -22,7 +22,7 @@ testWithTypedArrayConstructors(function(TA) {
var bar = Symbol("1"); var bar = Symbol("1");
sample.foo = 42; sample.foo = 42;
sample[bar] sample[bar] = 1;
var result = sample.map(function() { var result = sample.map(function() {
return 0; return 0;

View File

@ -29,9 +29,8 @@ features: [Symbol]
var s = Symbol("1"); var s = Symbol("1");
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var called = 0;
var sample = new TA(42); var sample = new TA(42);
var values = [ [
true, true,
1, 1,
"test262", "test262",

View File

@ -26,7 +26,6 @@ includes: [testTypedArray.js]
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample = new TA([42, 43, 44]); var sample = new TA([42, 43, 44]);
var calls = 0;
sample.some(function(v, i) { sample.some(function(v, i) {
if (i < sample.length - 1) { if (i < sample.length - 1) {

View File

@ -47,7 +47,7 @@ var o2 = {
end = true; end = true;
return 2; return 2;
} }
} };
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample = new TA(2); var sample = new TA(2);

View File

@ -37,7 +37,6 @@ features: [Symbol.species]
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample = new TA([40, 41, 42]); var sample = new TA([40, 41, 42]);
var calls = 0;
var expectedOffset = TA.BYTES_PER_ELEMENT; var expectedOffset = TA.BYTES_PER_ELEMENT;
var result, ctorThis; var result, ctorThis;
@ -46,7 +45,7 @@ testWithTypedArrayConstructors(function(TA) {
result = arguments; result = arguments;
ctorThis = this; ctorThis = this;
return new TA(buffer, offset, length); return new TA(buffer, offset, length);
};; };
sample.subarray(1); sample.subarray(1);

View File

@ -44,7 +44,7 @@ testWithTypedArrayConstructors(function(TA) {
sample.constructor[Symbol.species] = function(buffer, offset, length) { sample.constructor[Symbol.species] = function(buffer, offset, length) {
calls++; calls++;
return new TA(buffer, offset, length); return new TA(buffer, offset, length);
};; };
result = sample.subarray(1); result = sample.subarray(1);

View File

@ -23,7 +23,7 @@ var length = {
valueOf() { valueOf() {
throw new Test262Error(); throw new Test262Error();
} }
} };
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {

View File

@ -47,7 +47,7 @@ testWithTypedArrayConstructors(function(TA) {
TA.from(arrayLike, true); TA.from(arrayLike, true);
}, "mapfn is a boolean"); }, "mapfn is a boolean");
var s = Symbol("1") var s = Symbol("1");
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
TA.from(arrayLike, s); TA.from(arrayLike, s);
}, "mapfn is a symbol"); }, "mapfn is a symbol");

View File

@ -23,7 +23,7 @@ var thisArg = {};
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var results = []; var results = [];
var mapfn = function(kValue, k) { var mapfn = function() {
results.push(this); results.push(this);
}; };

View File

@ -24,7 +24,7 @@ var global = this;
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var results = []; var results = [];
var mapfn = function(kValue, k) { var mapfn = function() {
results.push(this); results.push(this);
}; };

View File

@ -23,7 +23,7 @@ var source = [42, 43];
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var results = []; var results = [];
var mapfn = function(kValue, k) { var mapfn = function() {
results.push(this); results.push(this);
}; };

View File

@ -15,7 +15,7 @@ testWithTypedArrayConstructors(function(TA) {
var ctor = function(len) { var ctor = function(len) {
assert.sameValue(arguments.length, 1); assert.sameValue(arguments.length, 1);
called++; called++;
return new TA(len) return new TA(len);
}; };
var result = TA.from.call(ctor, source); var result = TA.from.call(ctor, source);

View File

@ -10,7 +10,6 @@ includes: [testTypedArray.js]
var source = [42, 43, 42]; var source = [42, 43, 42];
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var lastValue;
var mapfn = function(kValue) { var mapfn = function(kValue) {
return kValue * 2; return kValue * 2;
}; };

View File

@ -37,7 +37,7 @@ var obj = {
valueOf: function() { valueOf: function() {
throw new Test262Error(); throw new Test262Error();
} }
} };
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample = new TA(42); var sample = new TA(42);

View File

@ -22,5 +22,5 @@ testWithTypedArrayConstructors(function(TA) {
$DETACHBUFFER(sample.buffer); $DETACHBUFFER(sample.buffer);
assert.sameValue(Reflect.set(sample, "foo", "test262"), true); assert.sameValue(Reflect.set(sample, "foo", "test262"), true);
assert.sameValue(sample["foo"], "test262"); assert.sameValue(sample.foo, "test262");
}); });

View File

@ -49,5 +49,5 @@ var length = Math.pow(2, 53);
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
new TA(length); new TA(length);
}) });
}); });

View File

@ -19,7 +19,7 @@ includes: [testTypedArray.js]
features: [Symbol.iterator] features: [Symbol.iterator]
---*/ ---*/
var obj = function () {} var obj = function () {};
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
obj[Symbol.iterator] = {}; obj[Symbol.iterator] = {};

View File

@ -19,7 +19,7 @@ includes: [testTypedArray.js]
features: [Symbol.iterator] features: [Symbol.iterator]
---*/ ---*/
var obj = function () {} var obj = function () {};
Object.defineProperty(obj, Symbol.iterator, { Object.defineProperty(obj, Symbol.iterator, {
get() { get() {

View File

@ -18,6 +18,6 @@ var s = Symbol("1");
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
var result = TA.of(s); TA.of(s);
}); });
}); });

View File

@ -25,9 +25,8 @@ includes: [testTypedArray.js]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample1 = Int8Array; var OtherCtor = TA === Int8Array ? Int16Array : Int8Array;
var sample2 = Int16Array; var sample = new OtherCtor();
var sample = new (TA === Int8Array ? sample2 : sample1);
Object.defineProperty(sample.buffer, "constructor", { Object.defineProperty(sample.buffer, "constructor", {
get() { get() {

View File

@ -26,12 +26,10 @@ includes: [testTypedArray.js]
features: [Symbol.species] features: [Symbol.species]
---*/ ---*/
var sample1 = new Int8Array();
var sample2 = new Int16Array();
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample = TA === Int8Array ? sample2 : sample1; var OtherCtor = TA === Int8Array ? Int16Array : Int8Array;
var ctor = {} var sample = new OtherCtor();
var ctor = {};
sample.buffer.constructor = ctor; sample.buffer.constructor = ctor;

View File

@ -26,12 +26,10 @@ includes: [testTypedArray.js]
features: [Symbol.species] features: [Symbol.species]
---*/ ---*/
var sample1 = new Int8Array();
var sample2 = new Int16Array();
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample = TA === Int8Array ? sample2 : sample1; var OtherCtor = TA === Int8Array ? Int16Array : Int8Array;
var ctor = {} var sample = new OtherCtor();
var ctor = {};
sample.buffer.constructor = ctor; sample.buffer.constructor = ctor;

View File

@ -35,7 +35,7 @@ features: [Symbol.species]
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample = new TA(4); var sample = new TA(4);
var ctor = {} var ctor = {};
sample.buffer.constructor = ctor; sample.buffer.constructor = ctor;

View File

@ -35,7 +35,7 @@ features: [Symbol.species]
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample = new TA(4); var sample = new TA(4);
var ctor = {} var ctor = {};
sample.buffer.constructor = ctor; sample.buffer.constructor = ctor;