OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 assertEquals("dead", RegExp["$1"]); | 207 assertEquals("dead", RegExp["$1"]); |
208 } else { | 208 } else { |
209 assertEquals(last_match_expectations[i], RegExp.lastMatch); | 209 assertEquals(last_match_expectations[i], RegExp.lastMatch); |
210 assertEquals(first_capture_expectations[i], RegExp["$1"]); | 210 assertEquals(first_capture_expectations[i], RegExp["$1"]); |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 | 215 |
216 // Test for different number of matches. | 216 // Test for different number of matches. |
217 for (var m = 0; m < 200; m++) { | 217 for (var m = 0; m < 33; m++) { |
218 // Create string that matches m times. | 218 // Create string that matches m times. |
219 var subject = ""; | 219 var subject = ""; |
220 var test_1_expectation = ""; | 220 var test_1_expectation = ""; |
221 var test_2_expectation = ""; | 221 var test_2_expectation = ""; |
222 var test_3_expectation = (m == 0) ? null : new Array(); | 222 var test_3_expectation = (m == 0) ? null : new Array(); |
223 for (var i = 0; i < m; i++) { | 223 for (var i = 0; i < m; i++) { |
224 subject += "a11"; | 224 subject += "a11"; |
225 test_1_expectation += "x1"; | 225 test_1_expectation += "x1"; |
226 test_2_expectation += "1"; | 226 test_2_expectation += "1"; |
227 test_3_expectation.push("a1"); | 227 test_3_expectation.push("a1"); |
(...skipping 17 matching lines...) Expand all Loading... |
245 // Test String hashing (compiling regular expression includes hashing). | 245 // Test String hashing (compiling regular expression includes hashing). |
246 var crosscheck = "\x80"; | 246 var crosscheck = "\x80"; |
247 for (var i = 0; i < 12; i++) crosscheck += crosscheck; | 247 for (var i = 0; i < 12; i++) crosscheck += crosscheck; |
248 new RegExp(crosscheck); | 248 new RegExp(crosscheck); |
249 | 249 |
250 var subject = "ascii~only~string~here~"; | 250 var subject = "ascii~only~string~here~"; |
251 var replacement = "\x80"; | 251 var replacement = "\x80"; |
252 var result = subject.replace(/~/g, replacement); | 252 var result = subject.replace(/~/g, replacement); |
253 for (var i = 0; i < 5; i++) result += result; | 253 for (var i = 0; i < 5; i++) result += result; |
254 new RegExp(result); | 254 new RegExp(result); |
OLD | NEW |