| 1 |
// Copyright (C) 2015 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
description: Literal astral symbols within a pattern |
| 6 |
es6id: 21.2.2.8.2 |
| 7 |
info: | |
| 8 |
21.2.2.2 Pattern |
| 9 |
|
| 10 |
The production Pattern :: Disjunction evaluates as follows: |
| 11 |
|
| 12 |
1. Evaluate Disjunction to obtain a Matcher m. |
| 13 |
2. Return an internal closure that takes two arguments, a String str |
| 14 |
and an integer index, and performs the following steps: |
| 15 |
1. If Unicode is true, let Input be a List consisting of the |
| 16 |
sequence of code points of str interpreted as a UTF-16 encoded |
| 17 |
(6.1.4) Unicode string. Otherwise, let Input be a List consisting |
| 18 |
of the sequence of code units that are the elements of str. Input |
| 19 |
will be used throughout the algorithms in 21.2.2. Each element of |
| 20 |
Input is considered to be a character. |
| 21 |
---*/ |
| 22 |
|
| 23 |
assert(/π{2}/u.test('ππ'), 'quantifier application'); |
| 24 |
|
| 25 |
assert(/^[π]$/u.test('π'), 'as a ClassAtom'); |
| 26 |
|
| 27 |
var rangeRe = /[π©-π«]/u; |
| 28 |
assert.sameValue( |
| 29 |
rangeRe.test('\ud83d\udca8'), |
| 30 |
false, |
| 31 |
'ClassAtom as lower range boundary, input below (U+1F4A8)' |
| 32 |
); |
| 33 |
assert.sameValue( |
| 34 |
rangeRe.test('\ud83d\udca9'), |
| 35 |
true, |
| 36 |
'ClassAtom as lower range boundary, input match (U+1F4A9)' |
| 37 |
); |
| 38 |
assert.sameValue( |
| 39 |
rangeRe.test('\ud83d\udcaa'), |
| 40 |
true, |
| 41 |
'ClassAtom as upper- and lower-range boundary, input within (U+1F4AA)' |
| 42 |
); |
| 43 |
assert.sameValue( |
| 44 |
rangeRe.test('\ud83d\udcab'), |
| 45 |
true, |
| 46 |
'ClassAtom as upper range boundary, input match (U+1F4AB)' |
| 47 |
); |
| 48 |
assert.sameValue( |
| 49 |
rangeRe.test('\ud83d\udcac'), |
| 50 |
false, |
| 51 |
'ClassAtom as upper range boundary, input above (U+1F4AC)' |
| 52 |
); |
| 53 |
|
| 54 |
assert(/[^π]/u.test('\ud834'), 'Negated character classes (LeadSurrogate)'); |
| 55 |
assert(/[^π]/u.test('\udf06'), 'Negated character classes (TrailSurrogate)'); |