Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 4bd99a6d9e940abd97ba243ecb383a119f4854f3..09125e1407c1ae84921005737437dc74f79ddf0d 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -404,6 +404,10 @@ THREADED_TEST(ScriptUsingStringResource) { |
CHECK(source->IsExternal()); |
CHECK_EQ(resource, |
static_cast<TestResource*>(source->GetExternalStringResource())); |
+ String::Encoding encoding = String::UNKNOWN_ENCODING; |
+ CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
+ source->GetExternalStringResourceBase(&encoding)); |
+ CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
CHECK_EQ(0, dispose_count); |
} |
@@ -419,9 +423,16 @@ THREADED_TEST(ScriptUsingAsciiStringResource) { |
{ |
v8::HandleScope scope; |
LocalContext env; |
- Local<String> source = |
- String::NewExternal(new TestAsciiResource(i::StrDup(c_source), |
- &dispose_count)); |
+ TestAsciiResource* resource = new TestAsciiResource(i::StrDup(c_source), |
+ &dispose_count); |
+ Local<String> source = String::NewExternal(resource); |
+ CHECK(source->IsExternalAscii()); |
+ CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
+ source->GetExternalAsciiStringResource()); |
+ String::Encoding encoding = String::UNKNOWN_ENCODING; |
+ CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
+ source->GetExternalStringResourceBase(&encoding)); |
+ CHECK_EQ(String::ASCII_ENCODING, encoding); |
Local<Script> script = Script::Compile(source); |
Local<Value> value = script->Run(); |
CHECK(value->IsNumber()); |
@@ -445,6 +456,11 @@ THREADED_TEST(ScriptMakingExternalString) { |
// Trigger GCs so that the newly allocated string moves to old gen. |
HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now |
HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now |
+ CHECK_EQ(source->IsExternal(), false); |
+ CHECK_EQ(source->IsExternalAscii(), false); |
+ String::Encoding encoding = String::UNKNOWN_ENCODING; |
+ CHECK_EQ(NULL, source->GetExternalStringResourceBase(&encoding)); |
+ CHECK_EQ(String::ASCII_ENCODING, encoding); |
bool success = source->MakeExternal(new TestResource(two_byte_source, |
&dispose_count)); |
CHECK(success); |