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

Side by Side Diff: tests/corelib_2/regexp/standalones_test.dart

Issue 2985823002: Migrated test block 24 to Dart 2.0. (Closed)
Patch Set: Created 3 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
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 2008 the V8 project authors. All rights reserved. 2 // Copyright 2008 the V8 project authors. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
5 // met: 5 // met:
6 // 6 //
7 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following 10 // copyright notice, this list of conditions and the following
(...skipping 20 matching lines...) Expand all
31 31
32 void main() { 32 void main() {
33 /* Many of the Mozilla regexp tests used 'toSource' to test their 33 /* Many of the Mozilla regexp tests used 'toSource' to test their
34 * results. Since we don't currently support toSource, those tests 34 * results. Since we don't currently support toSource, those tests
35 * are disabled and standalone versions are included here. 35 * are disabled and standalone versions are included here.
36 */ 36 */
37 37
38 // Tests from ecma_3/RegExp/regress-78156.js 38 // Tests from ecma_3/RegExp/regress-78156.js
39 var string = 'aaa\n789\r\nccc\r\n345'; 39 var string = 'aaa\n789\r\nccc\r\n345';
40 var pattern = new RegExp(r"^\d", multiLine: true); 40 var pattern = new RegExp(r"^\d", multiLine: true);
41 var result = pattern.allMatches(string).toList(); 41 var resultList = pattern.allMatches(string).toList();
42 assertEquals(2, result.length, "1"); 42 assertEquals(2, resultList.length, "1");
43 assertEquals('7', result[0].group(0), "2"); 43 assertEquals('7', resultList[0].group(0), "2");
44 assertEquals('3', result[1].group(0), "3"); 44 assertEquals('3', resultList[1].group(0), "3");
45 45
46 pattern = new RegExp(r"\d$", multiLine: true); 46 pattern = new RegExp(r"\d$", multiLine: true);
47 result = pattern.allMatches(string).toList(); 47 resultList = pattern.allMatches(string).toList();
48 assertEquals(2, result.length, "4"); 48 assertEquals(2, resultList.length, "4");
49 assertEquals('9', result[0].group(0), "5"); 49 assertEquals('9', resultList[0].group(0), "5");
50 assertEquals('5', result[1].group(0), "6"); 50 assertEquals('5', resultList[1].group(0), "6");
51 51
52 string = 'aaa\n789\r\nccc\r\nddd'; 52 string = 'aaa\n789\r\nccc\r\nddd';
53 pattern = new RegExp(r"^\d", multiLine: true); 53 pattern = new RegExp(r"^\d", multiLine: true);
54 result = pattern.allMatches(string).toList(); 54 resultList = pattern.allMatches(string).toList();
55 assertEquals(1, result.length, "7"); 55 assertEquals(1, resultList.length, "7");
56 assertEquals('7', result[0].group(0), "8"); 56 assertEquals('7', resultList[0].group(0), "8");
57 57
58 pattern = new RegExp(r"\d$", multiLine: true); 58 pattern = new RegExp(r"\d$", multiLine: true);
59 result = pattern.allMatches(string).toList(); 59 resultList = pattern.allMatches(string).toList();
60 assertEquals(1, result.length, "9"); 60 assertEquals(1, resultList.length, "9");
61 assertEquals('9', result[0].group(0), "10"); 61 assertEquals('9', resultList[0].group(0), "10");
62 62
63 // Tests from ecma_3/RegExp/regress-72964.js 63 // Tests from ecma_3/RegExp/regress-72964.js
64 pattern = new RegExp(r"[\S]+"); 64 pattern = new RegExp(r"[\S]+");
65 string = '\u00BF\u00CD\u00BB\u00A7'; 65 string = '\u00BF\u00CD\u00BB\u00A7';
66 result = pattern.firstMatch(string); 66 var resultMatch = pattern.firstMatch(string);
67 assertEquals(1, result.groupCount + 1, "11"); 67 assertEquals(1, resultMatch.groupCount + 1, "11");
68 assertEquals(string, result.group(0), "12"); 68 assertEquals(string, resultMatch.group(0), "12");
69 69
70 string = '\u00BF\u00CD \u00BB\u00A7'; 70 string = '\u00BF\u00CD \u00BB\u00A7';
71 result = pattern.firstMatch(string); 71 resultMatch = pattern.firstMatch(string);
72 assertEquals(1, result.groupCount + 1, "13"); 72 assertEquals(1, resultMatch.groupCount + 1, "13");
73 assertEquals('\u00BF\u00CD', result.group(0), "14"); 73 assertEquals('\u00BF\u00CD', resultMatch.group(0), "14");
74 74
75 string = '\u4e00\uac00\u4e03\u4e00'; 75 string = '\u4e00\uac00\u4e03\u4e00';
76 result = pattern.firstMatch(string); 76 resultMatch = pattern.firstMatch(string);
77 assertEquals(1, result.groupCount + 1, "15"); 77 assertEquals(1, resultMatch.groupCount + 1, "15");
78 assertEquals(string, result.group(0), "16"); 78 assertEquals(string, resultMatch.group(0), "16");
79 79
80 string = '\u4e00\uac00 \u4e03\u4e00'; 80 string = '\u4e00\uac00 \u4e03\u4e00';
81 result = pattern.firstMatch(string); 81 resultMatch = pattern.firstMatch(string);
82 assertEquals(1, result.groupCount + 1, "17"); 82 assertEquals(1, resultMatch.groupCount + 1, "17");
83 assertEquals('\u4e00\uac00', result.group(0), "18"); 83 assertEquals('\u4e00\uac00', resultMatch.group(0), "18");
84 } 84 }
OLDNEW
« no previous file with comments | « tests/corelib_2/regexp/stack-overflow_test.dart ('k') | tests/corelib_2/regexp/toString_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698