Commit 02c47fb8 authored by Ross Mcilroy's avatar Ross Mcilroy Committed by Commit Bot

[cleanup] Replace calls to deprecated String::Concat and ToInt32 from tests.

BUG=v8:7754

Change-Id: Id04fddb65c7943e9cb394c700eda45c6c6f7ebfd
Reviewed-on: https://chromium-review.googlesource.com/1147746
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54660}
parent cc6bcbce
...@@ -911,7 +911,8 @@ TEST(ExternalStringWithDisposeHandling) { ...@@ -911,7 +911,8 @@ TEST(ExternalStringWithDisposeHandling) {
THREADED_TEST(StringConcat) { THREADED_TEST(StringConcat) {
{ {
LocalContext env; LocalContext env;
v8::HandleScope scope(env->GetIsolate()); v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
const char* one_byte_string_1 = "function a_times_t"; const char* one_byte_string_1 = "function a_times_t";
const char* two_byte_string_1 = "wo_plus_b(a, b) {return "; const char* two_byte_string_1 = "wo_plus_b(a, b) {return ";
const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + "; const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + ";
...@@ -928,19 +929,19 @@ THREADED_TEST(StringConcat) { ...@@ -928,19 +929,19 @@ THREADED_TEST(StringConcat) {
.ToLocalChecked(); .ToLocalChecked();
i::DeleteArray(two_byte_source); i::DeleteArray(two_byte_source);
Local<String> source = String::Concat(env->GetIsolate(), left, right); Local<String> source = String::Concat(isolate, left, right);
right = String::NewExternalOneByte( right = String::NewExternalOneByte(
env->GetIsolate(), env->GetIsolate(),
new TestOneByteResource(i::StrDup(one_byte_extern_1))) new TestOneByteResource(i::StrDup(one_byte_extern_1)))
.ToLocalChecked(); .ToLocalChecked();
source = String::Concat(env->GetIsolate(), source, right); source = String::Concat(isolate, source, right);
right = String::NewExternalTwoByte( right = String::NewExternalTwoByte(
env->GetIsolate(), env->GetIsolate(),
new TestResource(AsciiToTwoByteString(two_byte_extern_1))) new TestResource(AsciiToTwoByteString(two_byte_extern_1)))
.ToLocalChecked(); .ToLocalChecked();
source = String::Concat(env->GetIsolate(), source, right); source = String::Concat(isolate, source, right);
right = v8_str(one_byte_string_2); right = v8_str(one_byte_string_2);
source = String::Concat(env->GetIsolate(), source, right); source = String::Concat(isolate, source, right);
two_byte_source = AsciiToTwoByteString(two_byte_string_2); two_byte_source = AsciiToTwoByteString(two_byte_string_2);
right = String::NewFromTwoByte(env->GetIsolate(), two_byte_source, right = String::NewFromTwoByte(env->GetIsolate(), two_byte_source,
...@@ -948,12 +949,12 @@ THREADED_TEST(StringConcat) { ...@@ -948,12 +949,12 @@ THREADED_TEST(StringConcat) {
.ToLocalChecked(); .ToLocalChecked();
i::DeleteArray(two_byte_source); i::DeleteArray(two_byte_source);
source = String::Concat(env->GetIsolate(), source, right); source = String::Concat(isolate, source, right);
right = String::NewExternalTwoByte( right = String::NewExternalTwoByte(
env->GetIsolate(), env->GetIsolate(),
new TestResource(AsciiToTwoByteString(two_byte_extern_2))) new TestResource(AsciiToTwoByteString(two_byte_extern_2)))
.ToLocalChecked(); .ToLocalChecked();
source = String::Concat(env->GetIsolate(), source, right); source = String::Concat(isolate, source, right);
Local<Script> script = v8_compile(source); Local<Script> script = v8_compile(source);
Local<Value> value = script->Run(env.local()).ToLocalChecked(); Local<Value> value = script->Run(env.local()).ToLocalChecked();
CHECK(value->IsNumber()); CHECK(value->IsNumber());
...@@ -26235,15 +26236,16 @@ TEST(InvalidCodeCacheData) { ...@@ -26235,15 +26236,16 @@ TEST(InvalidCodeCacheData) {
TEST(StringConcatOverflow) { TEST(StringConcatOverflow) {
v8::V8::Initialize(); v8::V8::Initialize();
v8::HandleScope scope(CcTest::isolate()); v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
RandomLengthOneByteResource* r = RandomLengthOneByteResource* r =
new RandomLengthOneByteResource(i::String::kMaxLength); new RandomLengthOneByteResource(i::String::kMaxLength);
v8::Local<v8::String> str = v8::Local<v8::String> str =
v8::String::NewExternalOneByte(CcTest::isolate(), r).ToLocalChecked(); v8::String::NewExternalOneByte(isolate, r).ToLocalChecked();
CHECK(!str.IsEmpty()); CHECK(!str.IsEmpty());
v8::TryCatch try_catch(CcTest::isolate()); v8::TryCatch try_catch(isolate);
v8::Local<v8::String> result = v8::Local<v8::String> result = v8::String::Concat(isolate, str, str);
v8::String::Concat(CcTest::isolate(), str, str); v8::String::Concat(CcTest::isolate(), str, str);
CHECK(result.IsEmpty()); CHECK(result.IsEmpty());
CHECK(!try_catch.HasCaught()); CHECK(!try_catch.HasCaught());
} }
......
...@@ -248,14 +248,16 @@ TEST(LiveEditPatchFunctions) { ...@@ -248,14 +248,16 @@ TEST(LiveEditPatchFunctions) {
PatchFunctions(context, "function foo() { return 1; }", PatchFunctions(context, "function foo() { return 1; }",
"function foo() { return 42; }"); "function foo() { return 42; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
42); 42);
// It is expected, we do not reevaluate top level function. // It is expected, we do not reevaluate top level function.
PatchFunctions(context, "var a = 1; function foo() { return a; }", PatchFunctions(context, "var a = 1; function foo() { return a; }",
"var a = 3; function foo() { return a; }"); "var a = 3; function foo() { return a; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
1); 1);
// Throw exception since var b is not defined in original source. // Throw exception since var b is not defined in original source.
...@@ -270,14 +272,16 @@ TEST(LiveEditPatchFunctions) { ...@@ -270,14 +272,16 @@ TEST(LiveEditPatchFunctions) {
PatchFunctions(context, "var a = 1; function foo() { return a; }", PatchFunctions(context, "var a = 1; function foo() { return a; }",
"var b = 4; function foo() { var b = 5; return b; }"); "var b = 4; function foo() { var b = 5; return b; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
5); 5);
PatchFunctions(context, "var a = 1; function foo() { return a; }", PatchFunctions(context, "var a = 1; function foo() { return a; }",
"var b = 4; function foo() { var a = 6; return a; }"); "var b = 4; function foo() { var a = 6; return a; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
6); 6);
...@@ -292,7 +296,8 @@ TEST(LiveEditPatchFunctions) { ...@@ -292,7 +296,8 @@ TEST(LiveEditPatchFunctions) {
PatchFunctions(context, "var a = 1; function foo() { return a; }", PatchFunctions(context, "var a = 1; function foo() { return a; }",
"var b = 1; var a = 2; function foo() { return a; }"); "var b = 1; var a = 2; function foo() { return a; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
1); 1);
...@@ -307,14 +312,16 @@ TEST(LiveEditPatchFunctions) { ...@@ -307,14 +312,16 @@ TEST(LiveEditPatchFunctions) {
PatchFunctions(context, "function foo() { var a = 1; return a; }", PatchFunctions(context, "function foo() { var a = 1; return a; }",
"function foo() { var b = 1; return b; }"); "function foo() { var b = 1; return b; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
1); 1);
PatchFunctions(context, "var a = 3; function foo() { var a = 1; return a; }", PatchFunctions(context, "var a = 3; function foo() { var a = 1; return a; }",
"function foo() { var b = 1; return a; }"); "function foo() { var b = 1; return a; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
3); 3);
...@@ -330,14 +337,16 @@ TEST(LiveEditPatchFunctions) { ...@@ -330,14 +337,16 @@ TEST(LiveEditPatchFunctions) {
PatchFunctions(context, "function fooArgs(a1, b1) { return a1 + b1; }", PatchFunctions(context, "function fooArgs(a1, b1) { return a1 + b1; }",
"function fooArgs(a2, b2, c2) { return a2 + b2 + c2; }"); "function fooArgs(a2, b2, c2) { return a2 + b2 + c2; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "fooArgs(1,2,3)") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "fooArgs(1,2,3)")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
6); 6);
PatchFunctions(context, "function fooArgs(a1, b1) { return a1 + b1; }", PatchFunctions(context, "function fooArgs(a1, b1) { return a1 + b1; }",
"function fooArgs(a1, b1, c1) { return a1 + b1 + c1; }"); "function fooArgs(a1, b1, c1) { return a1 + b1 + c1; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "fooArgs(1,2,3)") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "fooArgs(1,2,3)")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
6); 6);
...@@ -347,7 +356,8 @@ TEST(LiveEditPatchFunctions) { ...@@ -347,7 +356,8 @@ TEST(LiveEditPatchFunctions) {
"%OptimizeFunctionOnNextCall(foo); foo(1,2);", "%OptimizeFunctionOnNextCall(foo); foo(1,2);",
"function foo(a, b) { return a * b; };"); "function foo(a, b) { return a * b; };");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo(5,7)") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo(5,7)")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
35); 35);
i::FLAG_allow_natives_syntax = false; i::FLAG_allow_natives_syntax = false;
...@@ -359,7 +369,8 @@ TEST(LiveEditPatchFunctions) { ...@@ -359,7 +369,8 @@ TEST(LiveEditPatchFunctions) {
"function foo(a,b) { function op(a,b) { return a * b } return op(a,b); " "function foo(a,b) { function op(a,b) { return a * b } return op(a,b); "
"}"); "}");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo(8,9)") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo(8,9)")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
72); 72);
...@@ -368,7 +379,8 @@ TEST(LiveEditPatchFunctions) { ...@@ -368,7 +379,8 @@ TEST(LiveEditPatchFunctions) {
"class Foo { constructor(a,b) { this.data = a + b; } };", "class Foo { constructor(a,b) { this.data = a + b; } };",
"class Foo { constructor(a,b) { this.data = a * b; } };"); "class Foo { constructor(a,b) { this.data = a * b; } };");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "new Foo(4,5).data") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "new Foo(4,5).data")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
20); 20);
// Change inner functions. // Change inner functions.
...@@ -379,7 +391,8 @@ TEST(LiveEditPatchFunctions) { ...@@ -379,7 +391,8 @@ TEST(LiveEditPatchFunctions) {
"function f(evt) { function f2() { return 1; } return f2() + f3(); " "function f(evt) { function f2() { return 1; } return f2() + f3(); "
"function f3() { return 2; } } function f4() {}"); "function f3() { return 2; } } function f4() {}");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f()") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f()")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
3); 3);
// Change usage of outer scope. // Change usage of outer scope.
...@@ -424,21 +437,24 @@ TEST(LiveEditPatchFunctions) { ...@@ -424,21 +437,24 @@ TEST(LiveEditPatchFunctions) {
// TODO(kozyatinskiy): should work when we remove (. // TODO(kozyatinskiy): should work when we remove (.
PatchFunctions(context, "f = () => 2", "f = a => a"); PatchFunctions(context, "f = () => 2", "f = a => a");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f(3)") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f(3)")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
2); 2);
// Replace function with not a function. // Replace function with not a function.
PatchFunctions(context, "f = () => 2", "f = a == 2"); PatchFunctions(context, "f = () => 2", "f = a == 2");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f(3)") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f(3)")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
2); 2);
// TODO(kozyatinskiy): should work when we put function into (...). // TODO(kozyatinskiy): should work when we put function into (...).
PatchFunctions(context, "f = a => 2", "f = (a => 5)()"); PatchFunctions(context, "f = a => 2", "f = (a => 5)()");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f()") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f()")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
2); 2);
...@@ -457,11 +473,13 @@ TEST(LiveEditPatchFunctions) { ...@@ -457,11 +473,13 @@ TEST(LiveEditPatchFunctions) {
"f()\n"); "f()\n");
// TODO(kozyatinskiy): ditto. // TODO(kozyatinskiy): ditto.
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f2()") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f2()")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
5); 5);
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f()") CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f()")
->ToInt32(env->GetIsolate()) ->ToInt32(context)
.ToLocalChecked()
->Value(), ->Value(),
3); 3);
} }
......
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