diff --git a/test/harness/testTypedArray-conversions-call-error.js b/test/harness/testTypedArray-conversions-call-error.js new file mode 100644 index 0000000000000000000000000000000000000000..20837bed2ac62dc444f4d9968d4d8240cd6d4c7e --- /dev/null +++ b/test/harness/testTypedArray-conversions-call-error.js @@ -0,0 +1,29 @@ +// Copyright (c) 2017 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Including testTypedArray.js will expose: + + testTypedArrayConversions() + +includes: [testTypedArray.js] +---*/ +var threw = false; + +try { + testTypedArrayConversions({}, () => {}); +} catch(err) { + threw = true; + if (err.constructor !== TypeError) { + throw new Error( + 'Expected a TypeError, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a TypeError, but no error was thrown.'); +} + + diff --git a/test/harness/testTypedArray-conversions.js b/test/harness/testTypedArray-conversions.js new file mode 100644 index 0000000000000000000000000000000000000000..05a44c552aa9e4c61901f675424c3533eeb4ee7d --- /dev/null +++ b/test/harness/testTypedArray-conversions.js @@ -0,0 +1,54 @@ +// Copyright (c) 2017 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Including testTypedArray.js will expose: + + testTypedArrayConversions() + +includes: [testTypedArray.js] +---*/ +var callCount = 0; +var bcv = { + values: [ + 127, + ], + expected: { + Int8: [ + 127, + ], + Uint8: [ + 127, + ], + Uint8Clamped: [ + 127, + ], + Int16: [ + 127, + ], + Uint16: [ + 127, + ], + Int32: [ + 127, + ], + Uint32: [ + 127, + ], + Float32: [ + 127, + ], + Float64: [ + 127, + ] + } +}; + +testTypedArrayConversions(bcv, function(TA, value, expected, initial) { + var sample = new TA([initial]); + sample.fill(value); + assert.sameValue(initial, 0); + assert.sameValue(sample[0], expected); + callCount++; +}); + diff --git a/test/harness/testTypedArray.js b/test/harness/testTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..ffb6e9e3b7ec3827603e365b645d152e5dc926e4 --- /dev/null +++ b/test/harness/testTypedArray.js @@ -0,0 +1,39 @@ +// Copyright (c) 2017 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Including testTypedArray.js will expose: + + var typedArrayConstructors = [ array of TypedArray constructors ] + var TypedArray + + testWithTypedArrayConstructors() + testTypedArrayConversions() + +includes: [testTypedArray.js,arrayContains.js] +---*/ +var TAConstructors = [ + Float64Array, + Float32Array, + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + Uint8ClampedArray +]; +var length = TAConstructors.length; + +assert( + arrayContains(typedArrayConstructors, TAConstructors), + "All TypedArray constructors are accounted for" +); +assert(typeof TypedArray === "function"); +assert.sameValue(TypedArray, Object.getPrototypeOf(Uint8Array)); + + +var callCount = 0; +testWithTypedArrayConstructors(() => callCount++); +assert.sameValue(callCount, length); +