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