Commit 0bd428ff authored by Josh Wolfe's avatar Josh Wolfe Committed by Commit Bot

[api] Fix harmony formatting for CompileFunctionInContext

Add newline at the start of the function body.

BUG=v8:6190, v8:4958
R=littledan@chromium.org, adamk@chromium.org, caitp@igalia.com

Change-Id: I10db088ac9807a503382fd5080ad955e418d8b45
Reviewed-on: https://chromium-review.googlesource.com/466566Reviewed-by: 's avatarCaitlin Potter <caitp@igalia.com>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Josh Wolfe <jwolfe@igalia.com>
Cr-Commit-Position: refs/heads/master@{#44352}
parent 44b5be04
......@@ -2298,7 +2298,7 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
if (i::FLAG_harmony_function_tostring) {
// Append linefeed and signal that text beyond the linefeed is not part of
// the formal parameters.
brackets = factory->NewStringFromStaticChars("\n) {");
brackets = factory->NewStringFromStaticChars("\n) {\n");
parameters_end_pos = source_string->length() + 1;
} else {
brackets = factory->NewStringFromStaticChars("){");
......@@ -2309,8 +2309,8 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
} else {
if (i::FLAG_harmony_function_tostring) {
source_string =
factory->NewStringFromStaticChars("(function anonymous(\n) {");
parameters_end_pos = source_string->length() - 3;
factory->NewStringFromStaticChars("(function anonymous(\n) {\n");
parameters_end_pos = source_string->length() - 4;
} else {
source_string = factory->NewStringFromStaticChars("(function(){");
}
......
......@@ -605,7 +605,8 @@ TEST(CompileFunctionInContextHarmonyFunctionToString) {
fun->ToString(env.local()).ToLocalChecked();
v8::Local<v8::String> expected = v8_str(
"function anonymous(event\n"
") {return event\n"
") {\n"
"return event\n"
"}");
CHECK(expected->Equals(env.local(), result).FromJust());
}
......@@ -630,7 +631,8 @@ TEST(CompileFunctionInContextHarmonyFunctionToString) {
fun->ToString(env.local()).ToLocalChecked();
v8::Local<v8::String> expected = v8_str(
"function anonymous(\n"
") {return 0\n"
") {\n"
"return 0\n"
"}");
CHECK(expected->Equals(env.local(), result).FromJust());
}
......
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