Add tests for surrogate pairs with RegExp atoms (#722)

This commit is contained in:
jugglinmike 2016-08-25 16:29:51 -04:00 committed by Tom Care
parent b2b4254266
commit 4ffee35d89
4 changed files with 109 additions and 0 deletions

View File

@ -0,0 +1,33 @@
// 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-atom
es6id: 21.2.2.8
description: >
Support for surrogate pairs within patterns match by the CharacterClass Atom
info: |
The production Atom :: CharacterClass evaluates as follows:
1. Evaluate CharacterClass to obtain a CharSet A and a Boolean invert.
2. Call CharacterSetMatcher(A, invert) and return its Matcher result.
Runtime Semantics: CharacterSetMatcher Abstract Operation
1. Return an internal Matcher closure that takes two arguments, a State x and
a Continuation c, and performs the following steps when evaluated:
[...]
d. Let cc be Canonicalize(ch).
[...]
---*/
assert(/^[\ud800\udc00]$/u.test('\ud800\udc00'));
assert.sameValue(
/[\ud800\udc00]/u.test('\ud800'),
false,
'\\ud800 does not qualify as a class member'
);
assert.sameValue(
/[\ud800\udc00]/u.test('\udc00'),
false,
'\\udc00 does not qualify as a class member'
);

View File

@ -0,0 +1,23 @@
// 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-atom
es6id: 21.2.2.8
description: >
Support for surrogate pairs within patterns match by the "period" Atom
info: |
The production Atom :: . evaluates as follows:
1. Let A be the set of all characters except LineTerminator.
2. Call CharacterSetMatcher(A, false) and return its Matcher result.
Runtime Semantics: CharacterSetMatcher Abstract Operation
1. Return an internal Matcher closure that takes two arguments, a State x and
a Continuation c, and performs the following steps when evaluated:
[...]
d. Let cc be Canonicalize(ch).
[...]
---*/
assert(/^.$/u.test('\ud800\udc00'));

View File

@ -0,0 +1,24 @@
// 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-atomescape
es6id: 21.2.2.9
description: >
Support for surrogate pairs within patterns match by the CharacterClassEscape
AtomEscape
info: |
The production AtomEscape :: CharacterClassEscape evaluates as follows:
1. Evaluate CharacterClassEscape to obtain a CharSet A.
2. Call CharacterSetMatcher(A, false) and return its Matcher result.
Runtime Semantics: CharacterSetMatcher Abstract Operation
1. Return an internal Matcher closure that takes two arguments, a State x and
a Continuation c, and performs the following steps when evaluated:
[...]
d. Let cc be Canonicalize(ch).
[...]
---*/
assert(/^\S$/u.test('\ud800\udc00'));

View File

@ -0,0 +1,29 @@
// 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-atomescape
es6id: 21.2.2.9
description: >
Support for surrogate pairs within patterns match by the DecimalEscape
AtomEscape
info: |
The production AtomEscape :: DecimalEscape evaluates as follows:
[...]
3. Return an internal Matcher closure that takes two arguments, a State x and
a Continuation c, and performs the following steps:
[...]
h. If there exists an integer i between 0 (inclusive) and len (exclusive)
such that Canonicalize(s[i]) is not the same character value as
Canonicalize(Input[e+i]), return failure.
Runtime Semantics: CharacterSetMatcher Abstract Operation
1. Return an internal Matcher closure that takes two arguments, a State x and
a Continuation c, and performs the following steps when evaluated:
[...]
d. Let cc be Canonicalize(ch).
[...]
---*/
assert.sameValue(/(.+).*\1/u.test('\ud800\udc00\ud800'), false);