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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 months 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. All rights reserved. 1 // Copyright (c) 2014, the Dart project authors. All rights reserved.
2 // Copyright 2013 the V8 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. 3 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions 6 // modification, are permitted provided that the following conditions
7 // are met: 7 // are met:
8 // 1. Redistributions of source code must retain the above copyright 8 // 1. Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // 2. Redistributions in binary form must reproduce the above copyright 10 // 2. Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the 11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution. 12 // documentation and/or other materials provided with the distribution.
13 // 13 //
14 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y 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 15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 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 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 18 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 23 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 24
25 import 'v8_regexp_utils.dart'; 25 import 'v8_regexp_utils.dart';
26 import 'package:expect/expect.dart'; 26 import 'package:expect/expect.dart';
27 27
28 void main() { 28 void main() {
29 description( 29 description(
30 'Tests that regular expressions do not have extensions that diverge from the J avaScript specification. ' 30 'Tests that regular expressions do not have extensions that diverge from t he JavaScript specification. ' +
31 + 'Because WebKit originally used a copy of PCRE, various non-JavaScript regul ar expression features were historically present. ' 31 'Because WebKit originally used a copy of PCRE, various non-JavaScript regular expression features were historically present. ' +
32 + 'Also tests various related edge cases.' 32 'Also tests various related edge cases.');
33 );
34 33
35 shouldBeNull(new RegExp(r"\\x{41}").firstMatch("yA1")); 34 shouldBeNull(new RegExp(r"\\x{41}").firstMatch("yA1"));
36 assertEquals(new RegExp(r"[\x{41}]").firstMatch("yA1").group(0), "1"); 35 assertEquals(new RegExp(r"[\x{41}]").firstMatch("yA1").group(0), "1");
37 assertEquals(new RegExp(r"\x1g").firstMatch("x1g").group(0), "x1g"); 36 assertEquals(new RegExp(r"\x1g").firstMatch("x1g").group(0), "x1g");
38 assertEquals(new RegExp(r"[\x1g]").firstMatch("x").group(0), "x"); 37 assertEquals(new RegExp(r"[\x1g]").firstMatch("x").group(0), "x");
39 assertEquals(new RegExp(r"[\x1g]").firstMatch("1").group(0), "1"); 38 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"); 39 assertEquals(
41 assertEquals(new RegExp(r"\4294967296").firstMatch("\"94967296").group(0), "\" 94967296"); 40 new RegExp(r"\2147483648")
42 assertEquals(new RegExp(r"\8589934592").firstMatch("\8589934592").group(0), "\ 8589934592"); 41 .firstMatch(new String.fromCharCode(140) + "7483648")
43 assertEquals("\nAbc\n".replaceAllMapped(new RegExp(r"(\n)[^\n]+$"), (m) => m.g roup(1)), "\nAbc\n"); 42 .group(0),
43 new String.fromCharCode(140) + "7483648");
44 assertEquals(new RegExp(r"\4294967296").firstMatch("\"94967296").group(0),
45 "\"94967296");
46 assertEquals(new RegExp(r"\8589934592").firstMatch("\8589934592").group(0),
47 "\8589934592");
48 assertEquals(
49 "\nAbc\n".replaceAllMapped(new RegExp(r"(\n)[^\n]+$"), (m) => m.group(1)),
50 "\nAbc\n");
44 shouldBeNull(new RegExp(r"x$").firstMatch("x\n")); 51 shouldBeNull(new RegExp(r"x$").firstMatch("x\n"));
45 assertThrows(() => new RegExp(r"x++")); 52 assertThrows(() => new RegExp(r"x++"));
46 shouldBeNull(new RegExp(r"[]]").firstMatch("]")); 53 shouldBeNull(new RegExp(r"[]]").firstMatch("]"));
47 54
48 assertEquals(new RegExp(r"\060").firstMatch("y01").group(0), "0"); 55 assertEquals(new RegExp(r"\060").firstMatch("y01").group(0), "0");
49 assertEquals(new RegExp(r"[\060]").firstMatch("y01").group(0), "0"); 56 assertEquals(new RegExp(r"[\060]").firstMatch("y01").group(0), "0");
50 assertEquals(new RegExp(r"\606").firstMatch("y06").group(0), "06"); 57 assertEquals(new RegExp(r"\606").firstMatch("y06").group(0), "06");
51 assertEquals(new RegExp(r"[\606]").firstMatch("y06").group(0), "0"); 58 assertEquals(new RegExp(r"[\606]").firstMatch("y06").group(0), "0");
52 assertEquals(new RegExp(r"[\606]").firstMatch("y6").group(0), "6"); 59 assertEquals(new RegExp(r"[\606]").firstMatch("y6").group(0), "6");
53 assertEquals(new RegExp(r"\101").firstMatch("yA1").group(0), "A"); 60 assertEquals(new RegExp(r"\101").firstMatch("yA1").group(0), "A");
54 assertEquals(new RegExp(r"[\101]").firstMatch("yA1").group(0), "A"); 61 assertEquals(new RegExp(r"[\101]").firstMatch("yA1").group(0), "A");
55 assertEquals(new RegExp(r"\1011").firstMatch("yA1").group(0), "A1"); 62 assertEquals(new RegExp(r"\1011").firstMatch("yA1").group(0), "A1");
56 assertEquals(new RegExp(r"[\1011]").firstMatch("yA1").group(0), "A"); 63 assertEquals(new RegExp(r"[\1011]").firstMatch("yA1").group(0), "A");
57 assertEquals(new RegExp(r"[\1011]").firstMatch("y1").group(0), "1"); 64 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"); 65 assertEquals(
59 assertEquals(new RegExp(r"[\10q]").firstMatch("y" + new String.fromCharCode(8) + "q").group(0), new String.fromCharCode(8)); 66 new RegExp(r"\10q")
60 assertEquals(new RegExp(r"\1q").firstMatch("y" + new String.fromCharCode(1) + "q").group(0), new String.fromCharCode(1) + "q"); 67 .firstMatch("y" + new String.fromCharCode(8) + "q")
61 assertEquals(new RegExp(r"[\1q]").firstMatch("y" + new String.fromCharCode(1) + "q").group(0), new String.fromCharCode(1)); 68 .group(0),
69 new String.fromCharCode(8) + "q");
70 assertEquals(
71 new RegExp(r"[\10q]")
72 .firstMatch("y" + new String.fromCharCode(8) + "q")
73 .group(0),
74 new String.fromCharCode(8));
75 assertEquals(
76 new RegExp(r"\1q")
77 .firstMatch("y" + new String.fromCharCode(1) + "q")
78 .group(0),
79 new String.fromCharCode(1) + "q");
80 assertEquals(
81 new RegExp(r"[\1q]")
82 .firstMatch("y" + new String.fromCharCode(1) + "q")
83 .group(0),
84 new String.fromCharCode(1));
62 assertEquals(new RegExp(r"[\1q]").firstMatch("yq").group(0), "q"); 85 assertEquals(new RegExp(r"[\1q]").firstMatch("yq").group(0), "q");
63 assertEquals(new RegExp(r"\8q").firstMatch("\8q").group(0), "\8q"); 86 assertEquals(new RegExp(r"\8q").firstMatch("\8q").group(0), "\8q");
64 assertEquals(new RegExp(r"[\8q]").firstMatch("y8q").group(0), "8"); 87 assertEquals(new RegExp(r"[\8q]").firstMatch("y8q").group(0), "8");
65 assertEquals(new RegExp(r"[\8q]").firstMatch("yq").group(0), "q"); 88 assertEquals(new RegExp(r"[\8q]").firstMatch("yq").group(0), "q");
66 shouldBe(new RegExp(r"(x)\1q").firstMatch("xxq"), ["xxq", "x"]); 89 shouldBe(new RegExp(r"(x)\1q").firstMatch("xxq"), ["xxq", "x"]);
67 shouldBe(new RegExp(r"(x)[\1q]").firstMatch("xxq"), ["xq", "x"]); 90 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"]); 91 shouldBe(
92 new RegExp(r"(x)[\1q]").firstMatch("xx" + new String.fromCharCode(1)),
93 ["x" + new String.fromCharCode(1), "x"]);
69 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698