OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 | 2 |
3 // Check that we can traverse very deep stacks of ConsStrings using | 3 // Check that we can traverse very deep stacks of ConsStrings using |
4 // StringInputBuffer. Check that Get(int) works on very deep stacks | 4 // StringInputBuffer. Check that Get(int) works on very deep stacks |
5 // of ConsStrings. These operations may not be very fast, but they | 5 // of ConsStrings. These operations may not be very fast, but they |
6 // should be possible without getting errors due to too deep recursion. | 6 // should be possible without getting errors due to too deep recursion. |
7 | 7 |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 #include "v8.h" | 10 #include "v8.h" |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 // Ordinary HeapNumbers within bounds can be handled (in runtime). | 665 // Ordinary HeapNumbers within bounds can be handled (in runtime). |
666 result = CompileRun("%_SubString(long, Math.sqrt(4), 17.1);"); | 666 result = CompileRun("%_SubString(long, Math.sqrt(4), 17.1);"); |
667 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); | 667 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); |
668 CHECK_EQ("cdefghijklmnopq", *(string->ToCString())); | 668 CHECK_EQ("cdefghijklmnopq", *(string->ToCString())); |
669 | 669 |
670 // Test that out-of-bounds substring of a slice fails when the indices | 670 // Test that out-of-bounds substring of a slice fails when the indices |
671 // would have been valid for the underlying string. | 671 // would have been valid for the underlying string. |
672 CompileRun("var slice = long.slice(1, 15);"); | 672 CompileRun("var slice = long.slice(1, 15);"); |
673 CheckException("%_SubString(slice, 0, 17);"); | 673 CheckException("%_SubString(slice, 0, 17);"); |
674 } | 674 } |
| 675 |
| 676 |
| 677 TEST(RegExpOverflow) { |
| 678 // Result string has the length 2^32, causing an 32-bit integer overflow. |
| 679 InitializeVM(); |
| 680 HandleScope scope; |
| 681 LocalContext context; |
| 682 v8::V8::IgnoreOutOfMemoryException(); |
| 683 v8::Local<v8::Value> result = CompileRun( |
| 684 "var a = 'a'; " |
| 685 "for (var i = 0; i < 16; i++) { " |
| 686 " a += a; " |
| 687 "} " |
| 688 "a.replace(/a/g, a); "); |
| 689 CHECK(result.IsEmpty()); |
| 690 CHECK(context->HasOutOfMemoryException()); |
| 691 } |
OLD | NEW |