Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Unified Diff: test/mjsunit/arguments-extra-commas.js

Issue 2094463002: Allow trailing commas in function parameter lists (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add mjsunit test for arguments.length with trailing commas Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/flag-definitions.h ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/arguments-extra-commas.js
diff --git a/test/mjsunit/compiler/escape-analysis-deopt-5.js b/test/mjsunit/arguments-extra-commas.js
similarity index 63%
copy from test/mjsunit/compiler/escape-analysis-deopt-5.js
copy to test/mjsunit/arguments-extra-commas.js
index e70f0b1221bd9ab9b33c72da70db4a38897fe34b..a1c5f3a41e0dbde318cc8ba4ee73ac51a974c3b3 100644
--- a/test/mjsunit/compiler/escape-analysis-deopt-5.js
+++ b/test/mjsunit/arguments-extra-commas.js
@@ -25,17 +25,36 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --allow-natives-syntax --turbo-escape
-
-function f() {
- var x = new Array(2);
- x[0] = 23.1234;
- x[1] = 25.1234;
- %DeoptimizeNow();
- return x[0];
-}
-
-assertEquals(f(), 23.1234);
-assertEquals(f(), 23.1234);
-%OptimizeFunctionOnNextCall(f);
-assertEquals(f(), 23.1234);
+// Flags: --harmony-trailing-commas-in-parameters
+
+
+function f1(a) { return arguments.length; }
+function f2(a,b) { return arguments.length; }
+function f3(a,b,c) { return arguments.length; }
+function g1(a,) { return arguments.length; }
+function g2(a,b,) { return arguments.length; }
+function g3(a,b,c,) { return arguments.length; }
+
+[f1, f2, f3].forEach(function(f) {
adamk 2016/06/28 21:10:51 Sorry, I meant the "length" property on functions
+ assertEquals(0, f());
+
+ assertEquals(1, f(1));
+ assertEquals(2, f(1,2));
+ assertEquals(3, f(1,2,3));
+ assertEquals(4, f(1,2,3,4));
+ assertEquals(5, f(1,2,3,4,5));
+
+ assertEquals(1, f(1,));
+ assertEquals(2, f(1,2,));
+ assertEquals(3, f(1,2,3,));
+ assertEquals(4, f(1,2,3,4,));
+ assertEquals(5, f(1,2,3,4,5,));
+
+ assertEquals(0, f(...[]));
+ assertEquals(3, f(...[1, 2, 3]));
+ assertEquals(3, f(...[1,], 2, ...[3,]));
+
+ assertEquals(0, f(...[],));
+ assertEquals(3, f(...[1, 2, 3],));
+ assertEquals(3, f(...[1,], 2, ...[3,],));
+});
« src/flag-definitions.h ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698