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) {
THREADED_TEST(StringConcat) {
{
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* 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) + ";
......@@ -928,19 +929,19 @@ THREADED_TEST(StringConcat) {
.ToLocalChecked();
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(
env->GetIsolate(),
new TestOneByteResource(i::StrDup(one_byte_extern_1)))
.ToLocalChecked();
source = String::Concat(env->GetIsolate(), source, right);
source = String::Concat(isolate, source, right);
right = String::NewExternalTwoByte(
env->GetIsolate(),
new TestResource(AsciiToTwoByteString(two_byte_extern_1)))
.ToLocalChecked();
source = String::Concat(env->GetIsolate(), source, right);
source = String::Concat(isolate, source, right);
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);
right = String::NewFromTwoByte(env->GetIsolate(), two_byte_source,
......@@ -948,12 +949,12 @@ THREADED_TEST(StringConcat) {
.ToLocalChecked();
i::DeleteArray(two_byte_source);
source = String::Concat(env->GetIsolate(), source, right);
source = String::Concat(isolate, source, right);
right = String::NewExternalTwoByte(
env->GetIsolate(),
new TestResource(AsciiToTwoByteString(two_byte_extern_2)))
.ToLocalChecked();
source = String::Concat(env->GetIsolate(), source, right);
source = String::Concat(isolate, source, right);
Local<Script> script = v8_compile(source);
Local<Value> value = script->Run(env.local()).ToLocalChecked();
CHECK(value->IsNumber());
......@@ -26235,15 +26236,16 @@ TEST(InvalidCodeCacheData) {
TEST(StringConcatOverflow) {
v8::V8::Initialize();
v8::HandleScope scope(CcTest::isolate());
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
RandomLengthOneByteResource* r =
new RandomLengthOneByteResource(i::String::kMaxLength);
v8::Local<v8::String> str =
v8::String::NewExternalOneByte(CcTest::isolate(), r).ToLocalChecked();
v8::String::NewExternalOneByte(isolate, r).ToLocalChecked();
CHECK(!str.IsEmpty());
v8::TryCatch try_catch(CcTest::isolate());
v8::Local<v8::String> result =
v8::String::Concat(CcTest::isolate(), str, str);
v8::TryCatch try_catch(isolate);
v8::Local<v8::String> result = v8::String::Concat(isolate, str, str);
v8::String::Concat(CcTest::isolate(), str, str);
CHECK(result.IsEmpty());
CHECK(!try_catch.HasCaught());
}
......
......@@ -248,14 +248,16 @@ TEST(LiveEditPatchFunctions) {
PatchFunctions(context, "function foo() { return 1; }",
"function foo() { return 42; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
42);
// It is expected, we do not reevaluate top level function.
PatchFunctions(context, "var a = 1; function foo() { return a; }",
"var a = 3; function foo() { return a; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
1);
// Throw exception since var b is not defined in original source.
......@@ -270,14 +272,16 @@ TEST(LiveEditPatchFunctions) {
PatchFunctions(context, "var a = 1; function foo() { return a; }",
"var b = 4; function foo() { var b = 5; return b; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
5);
PatchFunctions(context, "var a = 1; function foo() { return a; }",
"var b = 4; function foo() { var a = 6; return a; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
6);
......@@ -292,7 +296,8 @@ TEST(LiveEditPatchFunctions) {
PatchFunctions(context, "var a = 1; function foo() { return a; }",
"var b = 1; var a = 2; function foo() { return a; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
1);
......@@ -307,14 +312,16 @@ TEST(LiveEditPatchFunctions) {
PatchFunctions(context, "function foo() { var a = 1; return a; }",
"function foo() { var b = 1; return b; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
1);
PatchFunctions(context, "var a = 3; function foo() { var a = 1; return a; }",
"function foo() { var b = 1; return a; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
3);
......@@ -330,14 +337,16 @@ TEST(LiveEditPatchFunctions) {
PatchFunctions(context, "function fooArgs(a1, b1) { return a1 + b1; }",
"function fooArgs(a2, b2, c2) { return a2 + b2 + c2; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "fooArgs(1,2,3)")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
6);
PatchFunctions(context, "function fooArgs(a1, b1) { return a1 + b1; }",
"function fooArgs(a1, b1, c1) { return a1 + b1 + c1; }");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "fooArgs(1,2,3)")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
6);
......@@ -347,7 +356,8 @@ TEST(LiveEditPatchFunctions) {
"%OptimizeFunctionOnNextCall(foo); foo(1,2);",
"function foo(a, b) { return a * b; };");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo(5,7)")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
35);
i::FLAG_allow_natives_syntax = false;
......@@ -359,7 +369,8 @@ TEST(LiveEditPatchFunctions) {
"function foo(a,b) { function op(a,b) { return a * b } return op(a,b); "
"}");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo(8,9)")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
72);
......@@ -368,7 +379,8 @@ TEST(LiveEditPatchFunctions) {
"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")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
20);
// Change inner functions.
......@@ -379,7 +391,8 @@ TEST(LiveEditPatchFunctions) {
"function f(evt) { function f2() { return 1; } return f2() + f3(); "
"function f3() { return 2; } } function f4() {}");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f()")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
3);
// Change usage of outer scope.
......@@ -424,21 +437,24 @@ TEST(LiveEditPatchFunctions) {
// TODO(kozyatinskiy): should work when we remove (.
PatchFunctions(context, "f = () => 2", "f = a => a");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f(3)")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
2);
// Replace function with not a function.
PatchFunctions(context, "f = () => 2", "f = a == 2");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f(3)")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
2);
// TODO(kozyatinskiy): should work when we put function into (...).
PatchFunctions(context, "f = a => 2", "f = (a => 5)()");
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f()")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
2);
......@@ -457,11 +473,13 @@ TEST(LiveEditPatchFunctions) {
"f()\n");
// TODO(kozyatinskiy): ditto.
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f2()")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
5);
CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f()")
->ToInt32(env->GetIsolate())
->ToInt32(context)
.ToLocalChecked()
->Value(),
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