X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/2d39b0e377c0896910ee49ae70082ba665faf986..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/tests/stress/symbol-with-json.js diff --git a/tests/stress/symbol-with-json.js b/tests/stress/symbol-with-json.js new file mode 100644 index 0000000..3c03d5d --- /dev/null +++ b/tests/stress/symbol-with-json.js @@ -0,0 +1,14 @@ +// This tests JSON correctly behaves with Symbol. + +if (JSON.stringify(Symbol('Cocoa')) !== undefined) + throw "Error: bad value " + JSON.stringify(Symbol('Cocoa')); + +var object = {}; +var symbol = Symbol("Cocoa"); +object[symbol] = 42; +object['Cappuccino'] = 42; +if (JSON.stringify(object) !== '{"Cappuccino":42}') + throw "Error: bad value " + JSON.stringify(object); + +if (JSON.stringify(object, [ Symbol('Cocoa') ]) !== "{}") + throw "Error: bad value " + JSON.stringify(object, [ Symbol('Cocoa') ]);