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

var symbols = [
    Symbol(),
    Symbol("ok"),
    Symbol.for("dummies"),
    Symbol.iterator
];

for (var sym of symbols) {
    assertEq(sym.valueOf(), sym);
    assertEq(Object(sym).valueOf(), sym);
}

// Any other value throws.
var nonsymbols = [undefined, null, NaN, {}, Symbol.prototype];
for (var nonsym of nonsymbols)
    assertThrowsInstanceOf(() => Symbol.prototype.valueOf.call(nonsym), TypeError);

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