Add tests for proposal-well-formed-stringify

* unpaired surrogate escape sequences
This commit is contained in:
Richard Gibson 2018-09-24 02:15:34 -04:00 committed by Rick Waldron
parent 783fc5d8bb
commit ce967f7a86
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
// 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
---*/
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")');