]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/symbol-seal-and-freeze.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / symbol-seal-and-freeze.js
1 // This tests Object.seal and Object.freeze affect on Symbol properties.
2
3 var object = {
4 [Symbol.iterator]: 42
5 };
6
7 if (!object.hasOwnProperty(Symbol.iterator))
8 throw "Error: object doesn't have Symbol.iterator";
9 if (JSON.stringify(Object.getOwnPropertyDescriptor(object, Symbol.iterator)) !== '{"value":42,"writable":true,"enumerable":true,"configurable":true}')
10 throw "Error: bad property descriptor " + JSON.stringify(Object.getOwnPropertyDescriptor(object, Symbol.iterator));
11 if (Object.getOwnPropertySymbols(object).length !== 1)
12 throw "Error: bad value " + Object.getOwnPropertySymbols(object).length;
13 if (Object.getOwnPropertySymbols(object)[0] !== Symbol.iterator)
14 throw "Error: bad value " + String(Object.getOwnPropertySymbols(object)[0]);
15
16 Object.seal(object);
17 if (!object.hasOwnProperty(Symbol.iterator))
18 throw "Error: object doesn't have Symbol.iterator";
19 if (JSON.stringify(Object.getOwnPropertyDescriptor(object, Symbol.iterator)) !== '{"value":42,"writable":true,"enumerable":true,"configurable":false}')
20 throw "Error: bad property descriptor " + JSON.stringify(Object.getOwnPropertyDescriptor(object, Symbol.iterator));
21
22 Object.freeze(object);
23 if (!object.hasOwnProperty(Symbol.iterator))
24 throw "Error: object doesn't have Symbol.iterator";
25 if (JSON.stringify(Object.getOwnPropertyDescriptor(object, Symbol.iterator)) !== '{"value":42,"writable":false,"enumerable":true,"configurable":false}')
26 throw "Error: bad property descriptor " + JSON.stringify(Object.getOwnPropertyDescriptor(object, Symbol.iterator));