OLD | NEW |
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 Loading... |
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]); | |
OLD | NEW |