OLD | NEW |
| (Empty) |
1 // Copyright (c) 2014, the Dart project authors. All rights reserved. | |
2 // Copyright 2008 the V8 project authors. All rights reserved. | |
3 // Redistribution and use in source and binary forms, with or without | |
4 // modification, are permitted provided that the following conditions are | |
5 // met: | |
6 // | |
7 // * Redistributions of source code must retain the above copyright | |
8 // notice, this list of conditions and the following disclaimer. | |
9 // * Redistributions in binary form must reproduce the above | |
10 // copyright notice, this list of conditions and the following | |
11 // disclaimer in the documentation and/or other materials provided | |
12 // with the distribution. | |
13 // * Neither the name of Google Inc. nor the names of its | |
14 // contributors may be used to endorse or promote products derived | |
15 // from this software without specific prior written permission. | |
16 // | |
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | |
29 import 'v8_regexp_utils.dart'; | |
30 import 'package:expect/expect.dart'; | |
31 | |
32 void main() { | |
33 // UC16 | |
34 // Characters used: | |
35 // "\u03a3\u03c2\u03c3\u039b\u03bb" - Sigma, final sigma, sigma, Lambda, | |
36 // lambda | |
37 shouldBe( | |
38 new RegExp(r"x(.)\1x", caseSensitive: false).firstMatch("x\u03a3\u03c3x"), | |
39 ["x\u03a3\u03c3x", "\u03a3"], | |
40 "backref-UC16"); | |
41 assertFalse( | |
42 new RegExp(r"x(...)\1", caseSensitive: false) | |
43 .hasMatch("x\u03a3\u03c2\u03c3\u03c2\u03c3"), | |
44 "\1 ASCII, string short"); | |
45 assertTrue( | |
46 new RegExp(r"\u03a3((?:))\1\1x", caseSensitive: false) | |
47 .hasMatch("\u03c2x"), | |
48 "backref-UC16-empty"); | |
49 assertTrue( | |
50 new RegExp(r"x(?:...|(...))\1x", caseSensitive: false) | |
51 .hasMatch("x\u03a3\u03c2\u03c3x"), | |
52 "backref-UC16-uncaptured"); | |
53 assertTrue( | |
54 new RegExp(r"x(?:...|(...))\1x", caseSensitive: false) | |
55 .hasMatch("x\u03c2\u03c3\u039b\u03a3\u03c2\u03bbx"), | |
56 "backref-UC16-backtrack"); | |
57 var longUC16String = | |
58 "x\u03a3\u03c2\u039b\u03c2\u03c3\u03bb\u03c3\u03a3\u03bb"; | |
59 shouldBe( | |
60 new RegExp(r"x(...)\1\1", caseSensitive: false) | |
61 .firstMatch(longUC16String), | |
62 [longUC16String, longUC16String.substring(1, 4)], | |
63 "backref-UC16-twice"); | |
64 | |
65 assertFalse(new RegExp(r"\xc1", caseSensitive: false).hasMatch('fooA'), | |
66 "quickcheck-uc16-pattern-ascii-subject"); | |
67 assertFalse(new RegExp(r"[\xe9]").hasMatch('i'), | |
68 "charclass-uc16-pattern-ascii-subject"); | |
69 assertFalse(new RegExp(r"\u5e74|\u6708").hasMatch('t'), | |
70 "alternation-uc16-pattern-ascii-subject"); | |
71 } | |
OLD | NEW |