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

Side by Side Diff: tests/corelib_strong/regexp/regexp_kde_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
(...skipping 16 matching lines...) Expand all
27 27
28 void main() { 28 void main() {
29 description("KDE JS Test"); 29 description("KDE JS Test");
30 30
31 var ri = new RegExp(r"a", caseSensitive: false); 31 var ri = new RegExp(r"a", caseSensitive: false);
32 var rm = new RegExp(r"a", multiLine: true); 32 var rm = new RegExp(r"a", multiLine: true);
33 var rg = new RegExp(r"a"); 33 var rg = new RegExp(r"a");
34 34
35 shouldBe(new RegExp(r"(b)c").firstMatch('abcd'), ["bc", "b"]); 35 shouldBe(new RegExp(r"(b)c").firstMatch('abcd'), ["bc", "b"]);
36 36
37 shouldBe(firstMatch('abcdefghi', new RegExp(r"(abc)def(ghi)")), ['abcdefghi', 'abc', 'ghi']); 37 shouldBe(firstMatch('abcdefghi', new RegExp(r"(abc)def(ghi)")),
38 shouldBe(new RegExp(r"(abc)def(ghi)").firstMatch('abcdefghi'), ['abcdefghi', ' abc', 'ghi']); 38 ['abcdefghi', 'abc', 'ghi']);
39 shouldBe(new RegExp(r"(abc)def(ghi)").firstMatch('abcdefghi'),
40 ['abcdefghi', 'abc', 'ghi']);
39 41
40 shouldBe(firstMatch('abcdefghi', new RegExp(r"(a(b(c(d(e)f)g)h)i)")), ['abcdef ghi', 'abcdefghi', 'bcdefgh', 'cdefg', 'def', 'e']); 42 shouldBe(firstMatch('abcdefghi', new RegExp(r"(a(b(c(d(e)f)g)h)i)")),
43 ['abcdefghi', 'abcdefghi', 'bcdefgh', 'cdefg', 'def', 'e']);
41 44
42 shouldBe(firstMatch('(100px 200px 150px 15px)', new RegExp(r"\((\d+)(px)* (\d+ )(px)* (\d+)(px)* (\d+)(px)*\)")), 45 shouldBe(
43 ['(100px 200px 150px 15px)', '100', 'px', '200', 'px', '150', 'px', '1 5', 'px']); 46 firstMatch('(100px 200px 150px 15px)',
44 shouldBeNull(firstMatch('', new RegExp(r"\((\d+)(px)* (\d+)(px)* (\d+)(px)* (\ d+)(px)*\)"))); 47 new RegExp(r"\((\d+)(px)* (\d+)(px)* (\d+)(px)* (\d+)(px)*\)")),
48 [
49 '(100px 200px 150px 15px)',
50 '100',
51 'px',
52 '200',
53 'px',
54 '150',
55 'px',
56 '15',
57 'px'
58 ]);
59 shouldBeNull(firstMatch(
60 '', new RegExp(r"\((\d+)(px)* (\d+)(px)* (\d+)(px)* (\d+)(px)*\)")));
45 61
46 var invalidChars = new RegExp(r"[^@\.\w]"); // #47092 62 var invalidChars = new RegExp(r"[^@\.\w]"); // #47092
47 shouldBeTrue(firstMatch('faure@kde.org', invalidChars) == null); 63 shouldBeTrue(firstMatch('faure@kde.org', invalidChars) == null);
48 shouldBeFalse(firstMatch('faure-kde@kde.org', invalidChars) == null); 64 shouldBeFalse(firstMatch('faure-kde@kde.org', invalidChars) == null);
49 65
50 assertEquals('test1test2'.replaceAll('test','X'),'X1X2'); 66 assertEquals('test1test2'.replaceAll('test', 'X'), 'X1X2');
51 assertEquals('test1test2'.replaceAll(new RegExp(r"\d"),'X'),'testXtestX'); 67 assertEquals('test1test2'.replaceAll(new RegExp(r"\d"), 'X'), 'testXtestX');
52 assertEquals('1test2test3'.replaceAll(new RegExp(r"\d"),''),'testtest'); 68 assertEquals('1test2test3'.replaceAll(new RegExp(r"\d"), ''), 'testtest');
53 assertEquals('test1test2'.replaceAll(new RegExp(r"test"),'X'),'X1X2'); 69 assertEquals('test1test2'.replaceAll(new RegExp(r"test"), 'X'), 'X1X2');
54 assertEquals('1test2test3'.replaceAll(new RegExp(r"\d"),''),'testtest'); 70 assertEquals('1test2test3'.replaceAll(new RegExp(r"\d"), ''), 'testtest');
55 assertEquals('1test2test3'.replaceAll(new RegExp(r"x"),''),'1test2test3'); 71 assertEquals('1test2test3'.replaceAll(new RegExp(r"x"), ''), '1test2test3');
56 assertEquals('test1test2'.replaceAllMapped(new RegExp(r"(te)(st)"), 72 assertEquals(
57 (m) => "${m.group(2)}${m.group(1)}"),'stte1stte2'); 73 'test1test2'.replaceAllMapped(
58 assertEquals('foo+bar'.replaceAll(new RegExp(r"\+"),'%2B'), 'foo%2Bbar'); 74 new RegExp(r"(te)(st)"), (m) => "${m.group(2)}${m.group(1)}"),
59 var caught = false; try { new RegExp("+"); } catch (e) { caught = true; } 75 'stte1stte2');
76 assertEquals('foo+bar'.replaceAll(new RegExp(r"\+"), '%2B'), 'foo%2Bbar');
77 var caught = false;
78 try {
79 new RegExp("+");
80 } catch (e) {
81 caught = true;
82 }
60 shouldBeTrue(caught); // #40435 83 shouldBeTrue(caught); // #40435
61 assertEquals('foo'.replaceAll(new RegExp(r"z?"),'x'), 'xfxoxox'); 84 assertEquals('foo'.replaceAll(new RegExp(r"z?"), 'x'), 'xfxoxox');
62 assertEquals('test test'.replaceAll(new RegExp(r"\s*"),''),'testtest'); // #50 985 85 assertEquals(
63 assertEquals('abc\$%@'.replaceAll(new RegExp(r"[^0-9a-z]*", caseSensitive: fal se),''),'abc'); // #50848 86 'test test'.replaceAll(new RegExp(r"\s*"), ''), 'testtest'); // #50985
64 assertEquals('ab'.replaceAll(new RegExp(r"[^\d\.]*", caseSensitive: false),'') ,''); // #75292 87 assertEquals(
65 assertEquals('1ab'.replaceAll(new RegExp(r"[^\d\.]*", caseSensitive: false),'' ),'1'); // #75292 88 'abc\$%@'.replaceAll(new RegExp(r"[^0-9a-z]*", caseSensitive: false), ''),
89 'abc'); // #50848
90 assertEquals(
91 'ab'.replaceAll(new RegExp(r"[^\d\.]*", caseSensitive: false), ''),
92 ''); // #75292
93 assertEquals(
94 '1ab'.replaceAll(new RegExp(r"[^\d\.]*", caseSensitive: false), ''),
95 '1'); // #75292
66 96
67 Expect.listEquals('1test2test3blah'.split(new RegExp(r"test")), ['1', '2', '3b lah']); 97 Expect.listEquals(
98 '1test2test3blah'.split(new RegExp(r"test")), ['1', '2', '3blah']);
68 var reg = new RegExp(r"(\d\d )"); 99 var reg = new RegExp(r"(\d\d )");
69 var str = '98 76 blah'; 100 var str = '98 76 blah';
70 shouldBe(reg.firstMatch(str),['98 ', '98 ']); 101 shouldBe(reg.firstMatch(str), ['98 ', '98 ']);
71 102
72 str = "For more information, see Chapter 3.4.5.1"; 103 str = "For more information, see Chapter 3.4.5.1";
73 var re = new RegExp(r"(chapter \d+(\.\d)*)", caseSensitive: false); 104 var re = new RegExp(r"(chapter \d+(\.\d)*)", caseSensitive: false);
74 // This returns the array containing Chapter 3.4.5.1,Chapter 3.4.5.1,.1 105 // This returns the array containing Chapter 3.4.5.1,Chapter 3.4.5.1,.1
75 // 'Chapter 3.4.5.1' is the first match and the first value remembered from (C hapter \d+(\.\d)*). 106 // 'Chapter 3.4.5.1' is the first match and the first value remembered from (C hapter \d+(\.\d)*).
76 // '.1' is the second value remembered from (\.\d) 107 // '.1' is the second value remembered from (\.\d)
77 shouldBe(firstMatch(str, re),['Chapter 3.4.5.1', 'Chapter 3.4.5.1', '.1']); 108 shouldBe(firstMatch(str, re), ['Chapter 3.4.5.1', 'Chapter 3.4.5.1', '.1']);
78 109
79 str = "abcDdcba"; 110 str = "abcDdcba";
80 // The returned array contains D, d. 111 // The returned array contains D, d.
81 re = new RegExp(r"d", caseSensitive: false); 112 re = new RegExp(r"d", caseSensitive: false);
82 var matches = re.allMatches(str); 113 var matches = re.allMatches(str);
83 Expect.listEquals( 114 Expect.listEquals(matches.map((m) => m.group(0)).toList(), ['D', 'd']);
84 matches.map((m) => m.group(0)).toList(),
85 ['D', 'd']);
86 115
87 // unicode escape sequence 116 // unicode escape sequence
88 shouldBe(firstMatch('abc', new RegExp(r"\u0062")), ['b']); 117 shouldBe(firstMatch('abc', new RegExp(r"\u0062")), ['b']);
89 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698