summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Symbol/typed-arrays.js
blob: a07cf396bb8b58a4cb2591ba22a7d764e5f5fd28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/ */

// Symbol-to-number type conversions involving typed arrays.

for (var T of [Uint8Array, Uint8ClampedArray, Int16Array, Float32Array]) {
    // Typed array constructors convert symbols using ToNumber(), which throws.
    assertThrowsInstanceOf(() => new T([Symbol("a")]), TypeError);

    // Assignment does the same.
    var arr = new T([1]);
    assertThrowsInstanceOf(() => { arr[0] = Symbol.iterator; }, TypeError);
    assertEq(arr[0], 1);
}

if (typeof reportCompare === "function")
    reportCompare(0, 0);