summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/JSON/stringify/value-string-escape-unicode.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/JSON/stringify/value-string-escape-unicode.js')
-rw-r--r--js/src/tests/test262/built-ins/JSON/stringify/value-string-escape-unicode.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/JSON/stringify/value-string-escape-unicode.js b/js/src/tests/test262/built-ins/JSON/stringify/value-string-escape-unicode.js
new file mode 100644
index 0000000000..a333bcc996
--- /dev/null
+++ b/js/src/tests/test262/built-ins/JSON/stringify/value-string-escape-unicode.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2018 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-quotejsonstring
+description: >
+ JSON.stringify strings containing surrogate code units
+features: [well-formed-json-stringify]
+---*/
+
+assert.sameValue(JSON.stringify("\uD834"), '"\\ud834"',
+ 'JSON.stringify("\\uD834")');
+assert.sameValue(JSON.stringify("\uDF06"), '"\\udf06"',
+ 'JSON.stringify("\\uDF06")');
+
+assert.sameValue(JSON.stringify("\uD834\uDF06"), '"𝌆"',
+ 'JSON.stringify("\\uD834\\uDF06")');
+assert.sameValue(JSON.stringify("\uD834\uD834\uDF06\uD834"), '"\\ud834𝌆\\ud834"',
+ 'JSON.stringify("\\uD834\\uD834\\uDF06\\uD834")');
+assert.sameValue(JSON.stringify("\uD834\uD834\uDF06\uDF06"), '"\\ud834𝌆\\udf06"',
+ 'JSON.stringify("\\uD834\\uD834\\uDF06\\uDF06")');
+assert.sameValue(JSON.stringify("\uDF06\uD834\uDF06\uD834"), '"\\udf06𝌆\\ud834"',
+ 'JSON.stringify("\\uDF06\\uD834\\uDF06\\uD834")');
+assert.sameValue(JSON.stringify("\uDF06\uD834\uDF06\uDF06"), '"\\udf06𝌆\\udf06"',
+ 'JSON.stringify("\\uDF06\\uD834\\uDF06\\uDF06")');
+
+assert.sameValue(JSON.stringify("\uDF06\uD834"), '"\\udf06\\ud834"',
+ 'JSON.stringify("\\uDF06\\uD834")');
+assert.sameValue(JSON.stringify("\uD834\uDF06\uD834\uD834"), '"𝌆\\ud834\\ud834"',
+ 'JSON.stringify("\\uD834\\uDF06\\uD834\\uD834")');
+assert.sameValue(JSON.stringify("\uD834\uDF06\uD834\uDF06"), '"𝌆𝌆"',
+ 'JSON.stringify("\\uD834\\uDF06\\uD834\\uDF06")');
+assert.sameValue(JSON.stringify("\uDF06\uDF06\uD834\uD834"), '"\\udf06\\udf06\\ud834\\ud834"',
+ 'JSON.stringify("\\uDF06\\uDF06\\uD834\\uD834")');
+assert.sameValue(JSON.stringify("\uDF06\uDF06\uD834\uDF06"), '"\\udf06\\udf06𝌆"',
+ 'JSON.stringify("\\uDF06\\uDF06\\uD834\\uDF06")');
+
+reportCompare(0, 0);