diff options
Diffstat (limited to 'js/src/tests/test262/annexB/built-ins/String/prototype/substr/surrogate-pairs.js')
-rw-r--r-- | js/src/tests/test262/annexB/built-ins/String/prototype/substr/surrogate-pairs.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/surrogate-pairs.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/surrogate-pairs.js new file mode 100644 index 0000000000..605596d335 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/surrogate-pairs.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.substr +es6id: B.2.3.1 +description: > + Behavior when input string contains a surrogate pair +info: | + [...] + 4. If length is undefined, let end be +∞; otherwise let end be ? + ToInteger(length). + [...] + 7. Let resultLength be min(max(end, 0), size - intStart). + 8. If resultLength ≤ 0, return the empty String "". + 9. Return a String containing resultLength consecutive code units from S + beginning with the code unit at index intStart. +---*/ + +assert.sameValue('\ud834\udf06'.substr(0), '\ud834\udf06', 'start: 0'); +assert.sameValue('\ud834\udf06'.substr(1), '\udf06', 'start: 1'); +assert.sameValue('\ud834\udf06'.substr(2), '', 'start: 2'); +assert.sameValue('\ud834\udf06'.substr(0, 0), '', 'end: 0'); +assert.sameValue('\ud834\udf06'.substr(0, 1), '\ud834', 'end: 1'); +assert.sameValue('\ud834\udf06'.substr(0, 2), '\ud834\udf06', 'end: 2'); + +reportCompare(0, 0); |