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

Side by Side Diff: test/mjsunit/regexp.js

Issue 1745017: Port regexp fix (backslash-b at end of input) to (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « src/jsregexp.cc ('k') | 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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 for (var i = 0; i < 100000; i++) { 381 for (var i = 0; i < 100000; i++) {
382 long = "a?" + long; 382 long = "a?" + long;
383 } 383 }
384 // Don't crash on this one, but maybe throw an exception. 384 // Don't crash on this one, but maybe throw an exception.
385 try { 385 try {
386 RegExp(long).exec("a"); 386 RegExp(long).exec("a");
387 } catch (e) { 387 } catch (e) {
388 assertTrue(String(e).indexOf("Stack overflow") >= 0, "overflow"); 388 assertTrue(String(e).indexOf("Stack overflow") >= 0, "overflow");
389 } 389 }
390 390
391
392 // Test that compile works on modified objects
393 var re = /re+/;
394 assertEquals("re+", re.source);
395 assertFalse(re.global);
396 assertFalse(re.ignoreCase);
397 assertFalse(re.multiline);
398 assertEquals(0, re.lastIndex);
399
400 re.compile("ro+", "gim");
401 assertEquals("ro+", re.source);
402 assertTrue(re.global);
403 assertTrue(re.ignoreCase);
404 assertTrue(re.multiline);
405 assertEquals(0, re.lastIndex);
406
407 re.lastIndex = 42;
408 re.someOtherProperty = 42;
409 re.someDeletableProperty = 42;
410 re[37] = 37;
411 re[42] = 42;
412
413 re.compile("ra+", "i");
414 assertEquals("ra+", re.source);
415 assertFalse(re.global);
416 assertTrue(re.ignoreCase);
417 assertFalse(re.multiline);
418 assertEquals(0, re.lastIndex);
419
420 assertEquals(42, re.someOtherProperty);
421 assertEquals(42, re.someDeletableProperty);
422 assertEquals(37, re[37]);
423 assertEquals(42, re[42]);
424
425 re.lastIndex = -1;
426 re.someOtherProperty = 37;
427 re[42] = 37;
428 assertTrue(delete re[37]);
429 assertTrue(delete re.someDeletableProperty);
430 re.compile("ri+", "gm");
431
432 assertEquals("ri+", re.source);
433 assertTrue(re.global);
434 assertFalse(re.ignoreCase);
435 assertTrue(re.multiline);
436 assertEquals(0, re.lastIndex);
437 assertEquals(37, re.someOtherProperty);
438 assertEquals(37, re[42]);
439
440 // Test boundary-checks.
441 function assertRegExpTest(re, input, test) {
442 assertEquals(test, re.test(input), "test:" + re + ":" + input);
443 }
444
445 assertRegExpTest(/b\b/, "b", true);
446 assertRegExpTest(/b\b$/, "b", true);
447 assertRegExpTest(/\bb/, "b", true);
448 assertRegExpTest(/^\bb/, "b", true);
449 assertRegExpTest(/,\b/, ",", false);
450 assertRegExpTest(/,\b$/, ",", false);
451 assertRegExpTest(/\b,/, ",", false);
452 assertRegExpTest(/^\b,/, ",", false);
453
454 assertRegExpTest(/b\B/, "b", false);
455 assertRegExpTest(/b\B$/, "b", false);
456 assertRegExpTest(/\Bb/, "b", false);
457 assertRegExpTest(/^\Bb/, "b", false);
458 assertRegExpTest(/,\B/, ",", true);
459 assertRegExpTest(/,\B$/, ",", true);
460 assertRegExpTest(/\B,/, ",", true);
461 assertRegExpTest(/^\B,/, ",", true);
462
463 assertRegExpTest(/b\b/, "b,", true);
464 assertRegExpTest(/b\b/, "ba", false);
465 assertRegExpTest(/b\B/, "b,", false);
466 assertRegExpTest(/b\B/, "ba", true);
467
468 assertRegExpTest(/b\Bb/, "bb", true);
469 assertRegExpTest(/b\bb/, "bb", false);
470
471 assertRegExpTest(/b\b[,b]/, "bb", false);
472 assertRegExpTest(/b\B[,b]/, "bb", true);
473 assertRegExpTest(/b\b[,b]/, "b,", true);
474 assertRegExpTest(/b\B[,b]/, "b,", false);
475
476 assertRegExpTest(/[,b]\bb/, "bb", false);
477 assertRegExpTest(/[,b]\Bb/, "bb", true);
478 assertRegExpTest(/[,b]\bb/, ",b", true);
479 assertRegExpTest(/[,b]\Bb/, ",b", false);
480
481 assertRegExpTest(/[,b]\b[,b]/, "bb", false);
482 assertRegExpTest(/[,b]\B[,b]/, "bb", true);
483 assertRegExpTest(/[,b]\b[,b]/, ",b", true);
484 assertRegExpTest(/[,b]\B[,b]/, ",b", false);
485 assertRegExpTest(/[,b]\b[,b]/, "b,", true);
486 assertRegExpTest(/[,b]\B[,b]/, "b,", false);
OLDNEW
« no previous file with comments | « src/jsregexp.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698