]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/object-get-own-property-symbols-perform-to-object.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / object-get-own-property-symbols-perform-to-object.js
CommitLineData
ed1e77d3
A
1var primitives = [
2 ["string", []],
3 [42, []],
4 [Symbol("symbol"), []],
5 [true, []],
6 [false, []]
7];
8
9function compare(ax, bx) {
10 if (ax.length !== bx.length)
11 return false;
12 for (var i = 0, iz = ax.length; i < iz; ++i) {
13 if (ax[i] !== bx[i])
14 return false;
15 }
16 return true;
17}
18
19for (var [primitive, expected] of primitives) {
20 var ret = Object.getOwnPropertySymbols(primitive);
21 if (!compare(ret, expected))
22 throw new Error("bad value for " + String(primitive) + ": " + String(ret));
23}
24
25[
26 [ null, "TypeError: null is not an object (evaluating 'Object.getOwnPropertySymbols(value)')" ],
27 [ undefined, "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertySymbols(value)')" ]
28].forEach(function ([value, message]) {
29 var error = null;
30 try {
31 Object.getOwnPropertySymbols(value);
32 } catch (e) {
33 error = e;
34 }
35 if (!error)
36 throw new Error("error not thrown");
37 if (String(error) !== message)
38 throw new Error("bad error: " + String(error));
39});