Once again: Fixed some lifetime/ownership issues in cctest

   * Fixed lifetime issue in cctest/test-heap-profiler/HeapSnapshotJSONSerialization.

   * Fixed ownership issue in cctest/test-api/ContainsOnlyOneByte.

R=ulan@chromium.org

Review URL: https://codereview.chromium.org/142553005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18978 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 27c385bf
......@@ -18951,8 +18951,9 @@ TEST(ContainsOnlyOneByte) {
}
string_contents[length-1] = 0;
// Simple case.
Handle<String> string;
string = String::NewExternal(isolate, new TestResource(string_contents));
Handle<String> string =
String::NewExternal(isolate,
new TestResource(string_contents, NULL, false));
CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte());
// Counter example.
string = String::NewFromTwoByte(isolate, string_contents);
......@@ -18969,7 +18970,9 @@ TEST(ContainsOnlyOneByte) {
balanced = String::Concat(balanced, right);
Handle<String> cons_strings[] = {left, balanced, right};
Handle<String> two_byte =
String::NewExternal(isolate, new TestResource(string_contents));
String::NewExternal(isolate,
new TestResource(string_contents, NULL, false));
USE(two_byte); USE(cons_strings);
for (size_t i = 0; i < ARRAY_SIZE(cons_strings); i++) {
// Base assumptions.
string = cons_strings[i];
......@@ -18990,7 +18993,8 @@ TEST(ContainsOnlyOneByte) {
int shift = 8 + (i % 7);
string_contents[alignment + i] = 1 << shift;
string = String::NewExternal(
isolate, new TestResource(string_contents + alignment));
isolate,
new TestResource(string_contents + alignment, NULL, false));
CHECK_EQ(size, string->Length());
CHECK(!string->ContainsOnlyOneByte());
string_contents[alignment + i] = 0x41;
......
......@@ -746,9 +746,9 @@ TEST(HeapSnapshotJSONSerialization) {
stream.WriteTo(json);
// Verify that snapshot string is valid JSON.
AsciiResource json_res(json);
AsciiResource* json_res = new AsciiResource(json);
v8::Local<v8::String> json_string =
v8::String::NewExternal(env->GetIsolate(), &json_res);
v8::String::NewExternal(env->GetIsolate(), json_res);
env->Global()->Set(v8_str("json_snapshot"), json_string);
v8::Local<v8::Value> snapshot_parse_result = CompileRun(
"var parsed = JSON.parse(json_snapshot); true;");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment