OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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" |
11 | 11 |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 v8::V8::IgnoreOutOfMemoryException(); | 684 v8::V8::IgnoreOutOfMemoryException(); |
685 v8::Local<v8::Value> result = CompileRun( | 685 v8::Local<v8::Value> result = CompileRun( |
686 "var a = 'a'; " | 686 "var a = 'a'; " |
687 "for (var i = 0; i < 16; i++) { " | 687 "for (var i = 0; i < 16; i++) { " |
688 " a += a; " | 688 " a += a; " |
689 "} " | 689 "} " |
690 "a.replace(/a/g, a); "); | 690 "a.replace(/a/g, a); "); |
691 CHECK(result.IsEmpty()); | 691 CHECK(result.IsEmpty()); |
692 CHECK(context->HasOutOfMemoryException()); | 692 CHECK(context->HasOutOfMemoryException()); |
693 } | 693 } |
| 694 |
| 695 |
| 696 TEST(StringReplaceAtomTwoByteResult) { |
| 697 InitializeVM(); |
| 698 HandleScope scope; |
| 699 LocalContext context; |
| 700 v8::Local<v8::Value> result = CompileRun( |
| 701 "var subject = 'ascii~only~string~'; " |
| 702 "var replace = '\x80'; " |
| 703 "subject.replace(/~/g, replace); "); |
| 704 CHECK(result->IsString()); |
| 705 Handle<String> string = v8::Utils::OpenHandle(v8::String::Cast(*result)); |
| 706 CHECK(string->IsSeqTwoByteString()); |
| 707 |
| 708 v8::Local<v8::String> expected = v8_str("ascii\x80only\x80string\x80"); |
| 709 CHECK(expected->Equals(result)); |
| 710 } |
OLD | NEW |