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

Side by Side Diff: test/webkit/fast/regex/assertion.js

Issue 20280003: Migrate more tests from blink repository. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions
6 // are met:
7 // 1. Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // 2. Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 //
13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
24 description("This page tests handling of parenthetical assertions.");
25
26 var regex1 = /(x)(?=\1)x/;
27 shouldBe("regex1.exec('xx')", "['xx','x']");
28
29 var regex2 = /(.*?)a(?!(a+)b\2c)\2(.*)/;
30 shouldBe("regex2.exec('baaabaac')", "['baaabaac','ba',undefined,'abaac']");
31
32 var regex3 = /(?=(a+?))(\1ab)/;
33 shouldBe("regex3.exec('aaab')", "['aab','a','aab']");
34
35 var regex4 = /(?=(a+?))(\1ab)/;
36 shouldBe("regex4.exec('aaab')", "['aab','a','aab']");
37
38 var regex5 = /^P([1-6])(?=\1)([1-6])$/;
39 shouldBe("regex5.exec('P11')", "['P11','1','1']");
40
41 var regex6 = /(([a-c])b*?\2)*/;
42 shouldBe("regex6.exec('ababbbcbc')", "['ababb','bb','b']");
43
44 var regex7 = /(x)(?=x)x/;
45 shouldBe("regex7.exec('xx')", "['xx','x']");
46
47 var regex8 = /(x)(\1)/;
48 shouldBe("regex8.exec('xx')", "['xx','x','x']");
49
50 var regex9 = /(x)(?=\1)x/;
51 shouldBeNull("regex9.exec('xy')");
52
53 var regex10 = /(x)(?=x)x/;
54 shouldBeNull("regex10.exec('xy')");
55
56 var regex11 = /(x)(\1)/;
57 shouldBeNull("regex11.exec('xy')");
58
59 var regex12 = /(x)(?=\1)x/;
60 shouldBeNull("regex12.exec('x')");
61 shouldBe("regex12.exec('xx')", "['xx','x']");
62 shouldBe("regex12.exec('xxy')", "['xx','x']");
63
64 var regex13 = /(x)zzz(?=\1)x/;
65 shouldBe("regex13.exec('xzzzx')", "['xzzzx','x']");
66 shouldBe("regex13.exec('xzzzxy')", "['xzzzx','x']");
67
68 var regex14 = /(a)\1(?=(b*c))bc/;
69 shouldBe("regex14.exec('aabc')", "['aabc','a','bc']");
70 shouldBe("regex14.exec('aabcx')", "['aabc','a','bc']");
71
72 var regex15 = /(a)a(?=(b*c))bc/;
73 shouldBe("regex15.exec('aabc')", "['aabc','a','bc']");
74 shouldBe("regex15.exec('aabcx')", "['aabc','a','bc']");
75
76 var regex16 = /a(?=(b*c))bc/;
77 shouldBeNull("regex16.exec('ab')");
78 shouldBe("regex16.exec('abc')", "['abc','bc']");
79
80 var regex17 = /(?=((?:ab)*))a/;
81 shouldBe("regex17.exec('ab')", "['a','ab']");
82 shouldBe("regex17.exec('abc')", "['a','ab']");
83
84 var regex18 = /(?=((?:xx)*))x/;
85 shouldBe("regex18.exec('x')", "['x','']");
86 shouldBe("regex18.exec('xx')", "['x','xx']");
87 shouldBe("regex18.exec('xxx')", "['x','xx']");
88
89 var regex19 = /(?=((xx)*))x/;
90 shouldBe("regex19.exec('x')", "['x','',undefined]");
91 shouldBe("regex19.exec('xx')", "['x','xx','xx']");
92 shouldBe("regex19.exec('xxx')", "['x','xx','xx']");
93
94 var regex20 = /(?=(xx))+x/;
95 shouldBeNull("regex20.exec('x')");
96 shouldBe("regex20.exec('xx')", "['x','xx']");
97 shouldBe("regex20.exec('xxx')", "['x','xx']");
98
99 var regex21 = /(?=a+b)aab/;
100 shouldBe("regex21.exec('aab')", "['aab']");
101
102 var regex22 = /(?!(u|m{0,}g+)u{1,}|2{2,}!1%n|(?!K|(?=y)|(?=ip))+?)(?=(?=(((?:7)) *?)*?))p/m;
103 shouldBe("regex22.exec('55up')", "null");
104
105 var regex23 = /(?=(a)b|c?)()*d/;
106 shouldBe("regex23.exec('ax')", "null");
107
108 var regex24 = /(?=a|b?)c/;
109 shouldBe("regex24.exec('x')", "null");
110
OLDNEW
« no previous file with comments | « test/webkit/fast/regex/alternative-length-miscalculation-expected.txt ('k') | test/webkit/fast/regex/assertion-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698