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

Unified Diff: test/cctest/test-strings.cc

Issue 24704005: Merged r16393 into 3.20 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.20
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/mjsunit/allocation-folding.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-strings.cc
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc
index 310d93c04ea8b9cadda0c1cbad1d3e25658b923f..726188d917d231b16c8bf019dcd9d4d9182d65da 100644
--- a/test/cctest/test-strings.cc
+++ b/test/cctest/test-strings.cc
@@ -1017,6 +1017,36 @@ TEST(ExternalShortStringAdd) {
}
+TEST(JSONStringifySliceMadeExternal) {
+ Isolate* isolate = Isolate::Current();
+ Zone zone(isolate);
+ CcTest::InitializeVM();
+ // Create a sliced string from a one-byte string. The latter is turned
+ // into a two-byte external string. Check that JSON.stringify works.
+ v8::HandleScope handle_scope(CcTest::isolate());
+ v8::Handle<v8::String> underlying =
+ CompileRun("var underlying = 'abcdefghijklmnopqrstuvwxyz';"
+ "underlying")->ToString();
+ v8::Handle<v8::String> slice =
+ CompileRun("var slice = underlying.slice(1);"
+ "slice")->ToString();
+ CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString());
+ CHECK(v8::Utils::OpenHandle(*underlying)->IsSeqOneByteString());
+
+ int length = underlying->Length();
+ uc16* two_byte = zone.NewArray<uc16>(length + 1);
+ underlying->Write(two_byte);
+ Resource* resource =
+ new(&zone) Resource(Vector<const uc16>(two_byte, length));
+ CHECK(underlying->MakeExternal(resource));
+ CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString());
+ CHECK(v8::Utils::OpenHandle(*underlying)->IsExternalTwoByteString());
+
+ CHECK_EQ("\"bcdefghijklmnopqrstuvwxyz\"",
+ *v8::String::Utf8Value(CompileRun("JSON.stringify(slice)")));
+}
+
+
TEST(CachedHashOverflow) {
// We incorrectly allowed strings to be tagged as array indices even if their
// values didn't fit in the hash field.
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/mjsunit/allocation-folding.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698