Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Side by Side Diff: tests/corelib/regexp/no-extensions_test.dart

Issue 691473002: Reapply "Port regexp tests from V8 to Dart." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. All rights reserved.
2 // Copyright 2013 the V8 project authors. All rights reserved.
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions
7 // are met:
8 // 1. Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // 2. Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
18 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
21 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
25 import 'v8_regexp_utils.dart';
26 import 'package:expect/expect.dart';
27
28 void main() {
29 description(
30 'Tests that regular expressions do not have extensions that diverge from the J avaScript specification. '
31 + 'Because WebKit originally used a copy of PCRE, various non-JavaScript regul ar expression features were historically present. '
32 + 'Also tests various related edge cases.'
33 );
34
35 shouldBeNull(new RegExp(r"\\x{41}").firstMatch("yA1"));
36 assertEquals(new RegExp(r"[\x{41}]").firstMatch("yA1").group(0), "1");
37 assertEquals(new RegExp(r"\x1g").firstMatch("x1g").group(0), "x1g");
38 assertEquals(new RegExp(r"[\x1g]").firstMatch("x").group(0), "x");
39 assertEquals(new RegExp(r"[\x1g]").firstMatch("1").group(0), "1");
40 assertEquals(new RegExp(r"\2147483648").firstMatch(new String.fromCharCode(140 ) + "7483648").group(0), new String.fromCharCode(140) + "7483648");
41 assertEquals(new RegExp(r"\4294967296").firstMatch("\"94967296").group(0), "\" 94967296");
42 assertEquals(new RegExp(r"\8589934592").firstMatch("\8589934592").group(0), "\ 8589934592");
43 assertEquals("\nAbc\n".replaceAllMapped(new RegExp(r"(\n)[^\n]+$"), (m) => m.g roup(1)), "\nAbc\n");
44 shouldBeNull(new RegExp(r"x$").firstMatch("x\n"));
45 assertThrows(() => new RegExp(r"x++"));
46 shouldBeNull(new RegExp(r"[]]").firstMatch("]"));
47
48 assertEquals(new RegExp(r"\060").firstMatch("y01").group(0), "0");
49 assertEquals(new RegExp(r"[\060]").firstMatch("y01").group(0), "0");
50 assertEquals(new RegExp(r"\606").firstMatch("y06").group(0), "06");
51 assertEquals(new RegExp(r"[\606]").firstMatch("y06").group(0), "0");
52 assertEquals(new RegExp(r"[\606]").firstMatch("y6").group(0), "6");
53 assertEquals(new RegExp(r"\101").firstMatch("yA1").group(0), "A");
54 assertEquals(new RegExp(r"[\101]").firstMatch("yA1").group(0), "A");
55 assertEquals(new RegExp(r"\1011").firstMatch("yA1").group(0), "A1");
56 assertEquals(new RegExp(r"[\1011]").firstMatch("yA1").group(0), "A");
57 assertEquals(new RegExp(r"[\1011]").firstMatch("y1").group(0), "1");
58 assertEquals(new RegExp(r"\10q").firstMatch("y" + new String.fromCharCode(8) + "q").group(0), new String.fromCharCode(8) + "q");
59 assertEquals(new RegExp(r"[\10q]").firstMatch("y" + new String.fromCharCode(8) + "q").group(0), new String.fromCharCode(8));
60 assertEquals(new RegExp(r"\1q").firstMatch("y" + new String.fromCharCode(1) + "q").group(0), new String.fromCharCode(1) + "q");
61 assertEquals(new RegExp(r"[\1q]").firstMatch("y" + new String.fromCharCode(1) + "q").group(0), new String.fromCharCode(1));
62 assertEquals(new RegExp(r"[\1q]").firstMatch("yq").group(0), "q");
63 assertEquals(new RegExp(r"\8q").firstMatch("\8q").group(0), "\8q");
64 assertEquals(new RegExp(r"[\8q]").firstMatch("y8q").group(0), "8");
65 assertEquals(new RegExp(r"[\8q]").firstMatch("yq").group(0), "q");
66 shouldBe(new RegExp(r"(x)\1q").firstMatch("xxq"), ["xxq", "x"]);
67 shouldBe(new RegExp(r"(x)[\1q]").firstMatch("xxq"), ["xq", "x"]);
68 shouldBe(new RegExp(r"(x)[\1q]").firstMatch("xx" + new String.fromCharCode(1)) , ["x" + new String.fromCharCode(1), "x"]);
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698