summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/literals/regexp/u-astral.js
blob: 70ab2b3cc64dd446ea1febf10b4261a78c73baa0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: Literal astral symbols within a pattern
es6id: 21.2.2.8.2
info: |
    21.2.2.2 Pattern

    The production Pattern :: Disjunction evaluates as follows:

        1. Evaluate Disjunction to obtain a Matcher m.
        2. Return an internal closure that takes two arguments, a String str
           and an integer index, and performs the following steps:
           1. If Unicode is true, let Input be a List consisting of the
              sequence of code points of str interpreted as a UTF-16 encoded
              (6.1.4) Unicode string. Otherwise, let Input be a List consisting
              of the sequence of code units that are the elements of str. Input
              will be used throughout the algorithms in 21.2.2. Each element of
              Input is considered to be a character.
---*/

assert(/𝌆{2}/u.test('𝌆𝌆'), 'quantifier application');

assert(/^[𝌆]$/u.test('𝌆'), 'as a ClassAtom');

var rangeRe = /[💩-💫]/u;
assert.sameValue(
  rangeRe.test('\ud83d\udca8'),
  false,
  'ClassAtom as lower range boundary, input below (U+1F4A8)'
);
assert.sameValue(
  rangeRe.test('\ud83d\udca9'),
  true,
  'ClassAtom as lower range boundary, input match (U+1F4A9)'
);
assert.sameValue(
  rangeRe.test('\ud83d\udcaa'),
  true,
  'ClassAtom as upper- and lower-range boundary, input within (U+1F4AA)'
);
assert.sameValue(
  rangeRe.test('\ud83d\udcab'),
  true,
  'ClassAtom as upper range boundary, input match (U+1F4AB)'
);
assert.sameValue(
  rangeRe.test('\ud83d\udcac'),
  false,
  'ClassAtom as upper range boundary, input above (U+1F4AC)'
);

assert(/[^𝌆]/u.test('\ud834'), 'Negated character classes (LeadSurrogate)');
assert(/[^𝌆]/u.test('\udf06'), 'Negated character classes (TrailSurrogate)');

reportCompare(0, 0);