OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. All rights reserved. | 1 // Copyright (c) 2014, the Dart project authors. All rights reserved. |
2 // Copyright 2008 the V8 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 | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following | 10 // copyright notice, this list of conditions and the following |
(...skipping 15 matching lines...) Expand all Loading... |
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
29 import 'v8_regexp_utils.dart'; | 29 import 'v8_regexp_utils.dart'; |
30 import 'package:expect/expect.dart'; | 30 import 'package:expect/expect.dart'; |
31 | 31 |
32 void main() { | 32 void main() { |
33 // UC16 | 33 // UC16 |
34 // Characters used: | 34 // Characters used: |
35 // "\u03a3\u03c2\u03c3\u039b\u03bb" - Sigma, final sigma, sigma, Lambda, lamda | 35 // "\u03a3\u03c2\u03c3\u039b\u03bb" - Sigma, final sigma, sigma, Lambda, lamda |
36 shouldBe(new RegExp(r"x(.)\1x", caseSensitive: false).firstMatch("x\u03a3\u03c
3x"), | 36 shouldBe( |
37 ["x\u03a3\u03c3x", "\u03a3"], "backref-UC16"); | 37 new RegExp(r"x(.)\1x", caseSensitive: false).firstMatch("x\u03a3\u03c3x"), |
38 assertFalse(new RegExp(r"x(...)\1", caseSensitive: false).hasMatch("x\u03a3\u0
3c2\u03c3\u03c2\u03c3"), | 38 ["x\u03a3\u03c3x", "\u03a3"], |
39 "\1 ASCII, string short"); | 39 "backref-UC16"); |
40 assertTrue(new RegExp(r"\u03a3((?:))\1\1x", caseSensitive: false).hasMatch("\u
03c2x"), "backref-UC16-empty"); | 40 assertFalse( |
41 assertTrue(new RegExp(r"x(?:...|(...))\1x", caseSensitive: false).hasMatch("x\
u03a3\u03c2\u03c3x"), | 41 new RegExp(r"x(...)\1", caseSensitive: false) |
42 "backref-UC16-uncaptured"); | 42 .hasMatch("x\u03a3\u03c2\u03c3\u03c2\u03c3"), |
43 assertTrue(new RegExp(r"x(?:...|(...))\1x", caseSensitive: false).hasMatch("x\
u03c2\u03c3\u039b\u03a3\u03c2\u03bbx"), | 43 "\1 ASCII, string short"); |
44 "backref-UC16-backtrack"); | 44 assertTrue( |
45 var longUC16String = "x\u03a3\u03c2\u039b\u03c2\u03c3\u03bb\u03c3\u03a3\u03bb"
; | 45 new RegExp(r"\u03a3((?:))\1\1x", caseSensitive: false) |
46 shouldBe(new RegExp(r"x(...)\1\1", caseSensitive: false).firstMatch(longUC16St
ring), | 46 .hasMatch("\u03c2x"), |
47 [longUC16String, longUC16String.substring(1,4)], | 47 "backref-UC16-empty"); |
48 "backref-UC16-twice"); | 48 assertTrue( |
| 49 new RegExp(r"x(?:...|(...))\1x", caseSensitive: false) |
| 50 .hasMatch("x\u03a3\u03c2\u03c3x"), |
| 51 "backref-UC16-uncaptured"); |
| 52 assertTrue( |
| 53 new RegExp(r"x(?:...|(...))\1x", caseSensitive: false) |
| 54 .hasMatch("x\u03c2\u03c3\u039b\u03a3\u03c2\u03bbx"), |
| 55 "backref-UC16-backtrack"); |
| 56 var longUC16String = |
| 57 "x\u03a3\u03c2\u039b\u03c2\u03c3\u03bb\u03c3\u03a3\u03bb"; |
| 58 shouldBe( |
| 59 new RegExp(r"x(...)\1\1", caseSensitive: false) |
| 60 .firstMatch(longUC16String), |
| 61 [longUC16String, longUC16String.substring(1, 4)], |
| 62 "backref-UC16-twice"); |
49 | 63 |
50 assertFalse(new RegExp(r"\xc1", caseSensitive: false).hasMatch('fooA'), "quick
check-uc16-pattern-ascii-subject"); | 64 assertFalse(new RegExp(r"\xc1", caseSensitive: false).hasMatch('fooA'), |
51 assertFalse(new RegExp(r"[\xe9]").hasMatch('i'), "charclass-uc16-pattern-ascii
-subject"); | 65 "quickcheck-uc16-pattern-ascii-subject"); |
52 assertFalse(new RegExp(r"\u5e74|\u6708").hasMatch('t'), "alternation-uc16-patt
ern-ascii-subject"); | 66 assertFalse(new RegExp(r"[\xe9]").hasMatch('i'), |
| 67 "charclass-uc16-pattern-ascii-subject"); |
| 68 assertFalse(new RegExp(r"\u5e74|\u6708").hasMatch('t'), |
| 69 "alternation-uc16-pattern-ascii-subject"); |
53 } | 70 } |
OLD | NEW |