diff options
author | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-09-26 09:18:06 -0700 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-09-26 09:19:50 -0700 |
commit | 85898d196718ef2e2129ed98b8865ee4b2658f0b (patch) | |
tree | 5c7638115412a4229e0c25debe7caf62258a30db /deps/v8/test/cctest/test-strings.cc | |
parent | c79d5163e530892c62b08d8b814b588220c26ec8 (diff) | |
download | node-new-85898d196718ef2e2129ed98b8865ee4b2658f0b.tar.gz |
v8: upgrade to 3.20.17.13
fixes #6235
Diffstat (limited to 'deps/v8/test/cctest/test-strings.cc')
-rw-r--r-- | deps/v8/test/cctest/test-strings.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/deps/v8/test/cctest/test-strings.cc b/deps/v8/test/cctest/test-strings.cc index 310d93c04e..726188d917 100644 --- a/deps/v8/test/cctest/test-strings.cc +++ b/deps/v8/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. |