]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/symbol-with-json.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / symbol-with-json.js
1 // This tests JSON correctly behaves with Symbol.
2
3 if (JSON.stringify(Symbol('Cocoa')) !== undefined)
4 throw "Error: bad value " + JSON.stringify(Symbol('Cocoa'));
5
6 var object = {};
7 var symbol = Symbol("Cocoa");
8 object[symbol] = 42;
9 object['Cappuccino'] = 42;
10 if (JSON.stringify(object) !== '{"Cappuccino":42}')
11 throw "Error: bad value " + JSON.stringify(object);
12
13 if (JSON.stringify(object, [ Symbol('Cocoa') ]) !== "{}")
14 throw "Error: bad value " + JSON.stringify(object, [ Symbol('Cocoa') ]);