Commit 3cfd80d6 authored by jwolfe's avatar jwolfe Committed by Commit bot

Adjust whitespace to make tests oblivious to --harmony-function-tostring

See discussion in https://codereview.chromium.org/2156303002/#msg8

With the new --harmony-function-tostring behavior, these tests would
fail without this change. This change makes the tests pass regardless
of whether or not --harmony-function-tostring is used.

All of these changes are simply inserting a space after the "function"
keyword to match the current function toString behavior. When
--harmony-function-tostring is enabled, the toString behavior matches
the spacing used in the function declaration. With the declaration
matching the current formatting, the toString behavior becomes
unaffected by --harmony-function-tostring.

BUG=v8:4958
LOG=n

Review-Url: https://codereview.chromium.org/2161413002
Cr-Commit-Position: refs/heads/master@{#37959}
parent 88707c98
...@@ -32,7 +32,7 @@ TEST(SimpleCall2) { ...@@ -32,7 +32,7 @@ TEST(SimpleCall2) {
TEST(ConstCall) { TEST(ConstCall) {
FunctionTester T("(function(foo,a) { return foo(a,3); })"); FunctionTester T("(function(foo,a) { return foo(a,3); })");
FunctionTester U("(function(a,b) { return a + b; })"); FunctionTester U("(function (a,b) { return a + b; })");
T.CheckCall(T.Val(6), U.function, T.Val(3)); T.CheckCall(T.Val(6), U.function, T.Val(3));
T.CheckCall(T.Val(6.1), U.function, T.Val(3.1)); T.CheckCall(T.Val(6.1), U.function, T.Val(3.1));
...@@ -44,7 +44,7 @@ TEST(ConstCall) { ...@@ -44,7 +44,7 @@ TEST(ConstCall) {
TEST(ConstCall2) { TEST(ConstCall2) {
FunctionTester T("(function(foo,a) { return foo(a,\"3\"); })"); FunctionTester T("(function(foo,a) { return foo(a,\"3\"); })");
FunctionTester U("(function(a,b) { return a + b; })"); FunctionTester U("(function (a,b) { return a + b; })");
T.CheckCall(T.Val("33"), U.function, T.Val(3)); T.CheckCall(T.Val("33"), U.function, T.Val(3));
T.CheckCall(T.Val("3.13"), U.function, T.Val(3.1)); T.CheckCall(T.Val("3.13"), U.function, T.Val(3.1));
......
...@@ -357,10 +357,10 @@ ...@@ -357,10 +357,10 @@
(function testNameNotReflectedInToString() { (function testNameNotReflectedInToString() {
var f = function() {}; var f = function () {};
var g = function*() {}; var g = function* () {};
var obj = { var obj = {
['h']: function() {}, ['h']: function () {},
i: () => {} i: () => {}
}; };
assertEquals('function () {}', f.toString()); assertEquals('function () {}', f.toString());
......
...@@ -348,7 +348,7 @@ assertEquals("start:5 resume:throw1 resume:throw2", log.join(" ")); ...@@ -348,7 +348,7 @@ assertEquals("start:5 resume:throw1 resume:throw2", log.join(" "));
async function foo() {} async function foo() {}
assertEquals("async function foo() {}", foo.toString()); assertEquals("async function foo() {}", foo.toString());
assertEquals("async function () {}", async function() {}.toString()); assertEquals("async function () {}", async function () {}.toString());
assertEquals("async x => x", (async x => x).toString()); assertEquals("async x => x", (async x => x).toString());
assertEquals("async x => { return x }", (async x => { return x }).toString()); assertEquals("async x => { return x }", (async x => { return x }).toString());
class AsyncMethod { async foo() { } } class AsyncMethod { async foo() { } }
......
...@@ -200,10 +200,10 @@ assertFalse(math_mirror.property("E").canDelete()); ...@@ -200,10 +200,10 @@ assertFalse(math_mirror.property("E").canDelete());
// Test objects with JavaScript accessors. // Test objects with JavaScript accessors.
o = {} o = {}
o.__defineGetter__('a', function(){return 'a';}); o.__defineGetter__('a', function (){return 'a';});
o.__defineSetter__('b', function(){}); o.__defineSetter__('b', function (){});
o.__defineGetter__('c', function(){throw 'c';}); o.__defineGetter__('c', function (){throw 'c';});
o.__defineSetter__('c', function(){throw 'c';}); o.__defineSetter__('c', function (){throw 'c';});
testObjectMirror(o, 'Object', 'Object'); testObjectMirror(o, 'Object', 'Object');
mirror = debug.MakeMirror(o); mirror = debug.MakeMirror(o);
// a has getter but no setter. // a has getter but no setter.
......
...@@ -28,7 +28,7 @@ description( ...@@ -28,7 +28,7 @@ description(
function foo(o, p) { function foo(o, p) {
var x = o.f; var x = o.f;
if (p) if (p)
return function() { return x; } return function () { return x; }
else { else {
var a = x; var a = x;
var b = x; var b = x;
...@@ -36,7 +36,7 @@ function foo(o, p) { ...@@ -36,7 +36,7 @@ function foo(o, p) {
} }
} }
var o = {f:function() { return 32; }}; var o = {f:function () { return 32; }};
for (var i = 0; i < 100; ++i) { for (var i = 0; i < 100; ++i) {
var expected; var expected;
......
...@@ -29,7 +29,7 @@ function foo() { ...@@ -29,7 +29,7 @@ function foo() {
return x; return x;
} }
x = function() { }; x = function () { };
var expected = "\"function () { }\""; var expected = "\"function () { }\"";
......
...@@ -41,7 +41,7 @@ function testGlobalAccess() { ...@@ -41,7 +41,7 @@ function testGlobalAccess() {
} }
function shouldBeSyntaxError(str) { function shouldBeSyntaxError(str) {
shouldThrow(str); shouldThrow(str);
shouldThrow("(function(){" + str + "})"); shouldThrow("(function (){" + str + "})");
} }
function testLineContinuation() { function testLineContinuation() {
"use stric\ "use stric\
......
...@@ -26,14 +26,14 @@ This test checks that functions re-string-ify in a way that is syntactically com ...@@ -26,14 +26,14 @@ This test checks that functions re-string-ify in a way that is syntactically com
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL (function(){return}).toString() should be function () {return;}. Was function (){return}. FAIL (function (){return}).toString() should be function () {return;}. Was function (){return}.
FAIL (function(){return }).toString() should be function () {return; }. Was function (){return }. FAIL (function (){return }).toString() should be function () {return; }. Was function (){return }.
FAIL (function(){return FAIL (function (){return
}).toString() should be function () {return; }).toString() should be function () {return;
}. Was function (){return }. Was function (){return
}. }.
FAIL (function(){}).toString() should be function () {}. Was function (){}. FAIL (function (){}).toString() should be function () {}. Was function (){}.
FAIL (function(){ }).toString() should be function () { }. Was function (){ }. FAIL (function (){ }).toString() should be function () { }. Was function (){ }.
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -26,8 +26,8 @@ description( ...@@ -26,8 +26,8 @@ description(
"compatible with concatenation." "compatible with concatenation."
); );
shouldBe("(function(){return}).toString()", "'function () {return;}'"); shouldBe("(function (){return}).toString()", "'function () {return;}'");
shouldBe("(function(){return }).toString()", "'function () {return; }'"); shouldBe("(function (){return }).toString()", "'function () {return; }'");
shouldBe("(function(){return" + "\n" + "}).toString()", "'function () {return;" + "\\n" + "}'"); shouldBe("(function (){return" + "\n" + "}).toString()", "'function () {return;" + "\\n" + "}'");
shouldBe("(function(){}).toString()", "'function () {}'"); shouldBe("(function (){}).toString()", "'function () {}'");
shouldBe("(function(){ }).toString()", "'function () { }'"); shouldBe("(function (){ }).toString()", "'function () { }'");
...@@ -25,19 +25,19 @@ description("KDE JS Test"); ...@@ -25,19 +25,19 @@ description("KDE JS Test");
// Tests for raising --- and non-raising exceptions on access to reference to undefined things... // Tests for raising --- and non-raising exceptions on access to reference to undefined things...
// Locals should throw on access if undefined.. // Locals should throw on access if undefined..
fnShouldThrow(function() { a = x; }, ReferenceError); fnShouldThrow(function () { a = x; }, ReferenceError);
// Read-modify-write versions of assignment should throw as well // Read-modify-write versions of assignment should throw as well
fnShouldThrow(function() { x += "foo"; }, ReferenceError); fnShouldThrow(function () { x += "foo"; }, ReferenceError);
// Other reference types should just return undefined... // Other reference types should just return undefined...
a = new Object(); a = new Object();
fnShouldNotThrow(function() { b = a.x; }); fnShouldNotThrow(function () { b = a.x; });
fnShouldNotThrow(function() { b = a['x']; }); fnShouldNotThrow(function () { b = a['x']; });
fnShouldNotThrow(function() { a['x'] += 'baz'; }); fnShouldNotThrow(function () { a['x'] += 'baz'; });
shouldBe("a['x']", '"undefinedbaz"'); shouldBe("a['x']", '"undefinedbaz"');
fnShouldNotThrow(function() { b = a.y; }); fnShouldNotThrow(function () { b = a.y; });
fnShouldNotThrow(function() { a.y += 'glarch'; }); fnShouldNotThrow(function () { a.y += 'glarch'; });
shouldBe("a['y']", '"undefinedglarch"'); shouldBe("a['y']", '"undefinedglarch"');
......
This diff is collapsed.
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