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

Side by Side Diff: test/mjsunit/harmony/arrow-rest-params.js

Issue 1300103005: [parser] disallow language mode directive in body of function with non-simple parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: flag implications don't work in test suite? Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/mjsunit/harmony/default-parameters.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-rest-parameters --harmony-arrow-functions 5 // Flags: --harmony-rest-parameters --harmony-arrow-functions
6 6
7 (function testRestIndex() { 7 (function testRestIndex() {
8 assertEquals(5, ((...args) => args.length)(1,2,3,4,5)); 8 assertEquals(5, ((...args) => args.length)(1,2,3,4,5));
9 assertEquals(4, ((a, ...args) => args.length)(1,2,3,4,5)); 9 assertEquals(4, ((a, ...args) => args.length)(1,2,3,4,5));
10 assertEquals(3, ((a, b, ...args) => args.length)(1,2,3,4,5)); 10 assertEquals(3, ((a, b, ...args) => args.length)(1,2,3,4,5));
11 assertEquals(2, ((a, b, c, ...args) => args.length)(1,2,3,4,5)); 11 assertEquals(2, ((a, b, c, ...args) => args.length)(1,2,3,4,5));
12 assertEquals(1, ((a, b, c, d, ...args) => args.length)(1,2,3,4,5)); 12 assertEquals(1, ((a, b, c, d, ...args) => args.length)(1,2,3,4,5));
13 assertEquals(0, ((a, b, c, d, e, ...args) => args.length)(1,2,3,4,5)); 13 assertEquals(0, ((a, b, c, d, e, ...args) => args.length)(1,2,3,4,5));
14 })(); 14 })();
15 15
16 // strictTest and sloppyTest should be called with descending natural 16 // strictTest and sloppyTest should be called with descending natural
17 // numbers, as in: 17 // numbers, as in:
18 // 18 //
19 // strictTest(6,5,4,3,2,1) 19 // strictTest(6,5,4,3,2,1)
20 // 20 //
21 var strictTest = (a, b, ...c) => { 21 var strictTest = (() => {
22 "use strict"; 22 "use strict";
23 assertEquals(Array, c.constructor); 23 return (a, b, ...c) => {
24 assertTrue(Array.isArray(c)); 24 assertEquals(Array, c.constructor);
25 assertTrue(Array.isArray(c));
25 26
26 var expectedLength = (a === undefined) ? 0 : a - 2; 27 var expectedLength = (a === undefined) ? 0 : a - 2;
27 assertEquals(expectedLength, c.length); 28 assertEquals(expectedLength, c.length);
28 29
29 for (var i = 2; i < a; ++i) { 30 for (var i = 2; i < a; ++i) {
30 assertEquals(c[i - 2], a - i); 31 assertEquals(c[i - 2], a - i);
31 } 32 }
32 } 33 };
34 })();
33 35
34 var sloppyTest = (a, b, ...c) => { 36 var sloppyTest = (a, b, ...c) => {
35 assertEquals(Array, c.constructor); 37 assertEquals(Array, c.constructor);
36 assertTrue(Array.isArray(c)); 38 assertTrue(Array.isArray(c));
37 39
38 var expectedLength = (a === undefined) ? 0 : a - 2; 40 var expectedLength = (a === undefined) ? 0 : a - 2;
39 assertEquals(expectedLength, c.length); 41 assertEquals(expectedLength, c.length);
40 42
41 for (var i = 2; i < a; ++i) { 43 for (var i = 2; i < a; ++i) {
42 assertEquals(c[i - 2], a - i); 44 assertEquals(c[i - 2], a - i);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 })(); 135 })();
134 136
135 137
136 (function testUnmappedArguments() { 138 (function testUnmappedArguments() {
137 // Normal functions make their arguments object unmapped, but arrow 139 // Normal functions make their arguments object unmapped, but arrow
138 // functions don't have an arguments object anyway. Check that the 140 // functions don't have an arguments object anyway. Check that the
139 // right thing happens for arguments in arrow functions with rest 141 // right thing happens for arguments in arrow functions with rest
140 // parameters. 142 // parameters.
141 assertSame(arguments, ((...rest) => arguments)()); 143 assertSame(arguments, ((...rest) => arguments)());
142 })(); 144 })();
OLDNEW
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/mjsunit/harmony/default-parameters.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698