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

Side by Side Diff: LayoutTests/fast/regex/script-tests/toString.js

Issue 20867002: Remove old tests that have been migrated to the v8 repo. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove unused script-tests as well Created 7 years, 4 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 description("This page tests toString conversion of RegExp objects, particularly wrt to '/' characters and RegExp.prototype.");
2
3 function testForwardSlash(pattern, _string)
4 {
5 string = _string;
6
7 re1 = new RegExp(pattern);
8 re2 = eval(re1.toString());
9
10 return re1.test(string) && re2.test(string);
11 }
12
13 function testLineTerminator(pattern)
14 {
15 re1 = new RegExp(pattern);
16
17 return /\n|\r|\u2028|\u2029/.test(re1.toString());
18 }
19
20 shouldBe("RegExp('/').source", '"\\\\/"');
21 shouldBe("RegExp('').source", '"(?:)"');
22 shouldBe("RegExp.prototype.source", '"(?:)"');
23
24 shouldBe("RegExp('/').toString()", '"/\\\\//"');
25 shouldBe("RegExp('').toString()", '"/(?:)/"');
26 shouldBe("RegExp.prototype.toString()", '"/(?:)/"');
27
28 // These strings are equivalent, since the '\' is identity escaping the '/' at t he string level.
29 shouldBeTrue('testForwardSlash("^/$", "/");');
30 shouldBeTrue('testForwardSlash("^\/$", "/");');
31 // This string passes "^\/$" to the RegExp, so the '/' is escaped in the re!
32 shouldBeTrue('testForwardSlash("^\\/$", "/");');
33 // These strings pass "^\\/$" and "^\\\/$" respectively to the RegExp, giving on e '\' to match.
34 shouldBeTrue('testForwardSlash("^\\\\/$", "\\/");');
35 shouldBeTrue('testForwardSlash("^\\\\\\/$", "\\/");');
36 // These strings match two backslashes (the second with the '/' escaped).
37 shouldBeTrue('testForwardSlash("^\\\\\\\\/$", "\\\\/");');
38 shouldBeTrue('testForwardSlash("^\\\\\\\\\\/$", "\\\\/");');
39 // Test that nothing goes wrongif there are multiple forward slashes!
40 shouldBeTrue('testForwardSlash("x/x/x", "x\\/x\\/x");');
41 shouldBeTrue('testForwardSlash("x\\/x/x", "x\\/x\\/x");');
42 shouldBeTrue('testForwardSlash("x/x\\/x", "x\\/x\\/x");');
43 shouldBeTrue('testForwardSlash("x\\/x\\/x", "x\\/x\\/x");');
44
45 shouldBeFalse('testLineTerminator("\\n");');
46 shouldBeFalse('testLineTerminator("\\\\n");');
47 shouldBeFalse('testLineTerminator("\\r");');
48 shouldBeFalse('testLineTerminator("\\\\r");');
49 shouldBeFalse('testLineTerminator("\\u2028");');
50 shouldBeFalse('testLineTerminator("\\\\u2028");');
51 shouldBeFalse('testLineTerminator("\\u2029");');
52 shouldBeFalse('testLineTerminator("\\\\u2029");');
53
54 shouldBe("RegExp('[/]').source", "'[/]'");
55 shouldBe("RegExp('\\\\[/]').source", "'\\\\[\\\\/]'");
56
57 // See 15.10.6.4
58 // The first half of this checks that:
59 // Return the String value formed by concatenating the Strings "/", the
60 // String value of the source property of this RegExp object, and "/";
61 // The second half checks that:
62 // The returned String has the form of a RegularExpressionLiteral that
63 // evaluates to another RegExp object with the same behaviour as this object .
64 shouldBe("var o = new RegExp(); o.toString() === '/'+o.source+'/' && eval(o.toSt ring()+'.exec(String())')", '[""]');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698