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

Side by Side Diff: test/mjsunit/string-replace.js

Issue 12315130: Fix wrong test in r13766 (Insert conversion to string in string.replace). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 assertEquals("axc", "abc".replace(/b/, replace_obj)); 218 assertEquals("axc", "abc".replace(/b/, replace_obj));
219 assertEquals("axc", "abc".replace(/b/g, replace_obj)); 219 assertEquals("axc", "abc".replace(/b/g, replace_obj));
220 220
221 var search_obj = { length: 1, toString: function() { return "b"; }}; 221 var search_obj = { length: 1, toString: function() { return "b"; }};
222 assertEquals("axc", "abc".replace(search_obj, function() { return "x"; })); 222 assertEquals("axc", "abc".replace(search_obj, function() { return "x"; }));
223 223
224 var side_effect_flag = false; 224 var side_effect_flag = false;
225 var replace_obj_side_effects = { 225 var replace_obj_side_effects = {
226 toString: function() { side_effect_flag = true; return "x" } 226 toString: function() { side_effect_flag = true; return "x" }
227 } 227 }
228 assertEquals("abc", "abc".replace(/z/g, function() { return "x"; })); 228 assertEquals("abc", "abc".replace(/z/g, replace_obj_side_effects));
229 assertTrue(side_effect_flag); // Side effect triggers even without a match. 229 assertTrue(side_effect_flag); // Side effect triggers even without a match.
230 230
231 var regexp99pattern = ""; 231 var regexp99pattern = "";
232 var subject = ""; 232 var subject = "";
233 for (var i = 0; i < 99; i++) { 233 for (var i = 0; i < 99; i++) {
234 regexp99pattern += "(.)"; 234 regexp99pattern += "(.)";
235 subject += String.fromCharCode(i + 24); 235 subject += String.fromCharCode(i + 24);
236 } 236 }
237 237
238 function testIndices99(re) { 238 function testIndices99(re) {
(...skipping 27 matching lines...) Expand all
266 // followed by "0", $61 as $6, followed by "1" and so on. 266 // followed by "0", $61 as $6, followed by "1" and so on.
267 var tail = subject.substr(59); 267 var tail = subject.substr(59);
268 for (var i = 60; i < 100; i++) { 268 for (var i = 60; i < 100; i++) {
269 assertEquals(String.fromCharCode(i / 10 + 23) + (i % 10) + tail, 269 assertEquals(String.fromCharCode(i / 10 + 23) + (i % 10) + tail,
270 subject.replace(re, "$" + i)); 270 subject.replace(re, "$" + i));
271 } 271 }
272 } 272 }
273 273
274 testIndices59(new RegExp(regexp59pattern)); 274 testIndices59(new RegExp(regexp59pattern));
275 testIndices59(new RegExp(regexp59pattern, "g")); 275 testIndices59(new RegExp(regexp59pattern, "g"));
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698