rest-index.js (1282B)
1 // Copyright (C) 2014 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 es6id: 14.1 5 description: > 6 rest index 7 ---*/ 8 assert.sameValue( 9 (function(...args) { return args.length; })(1,2,3,4,5), 10 5, 11 "`(function(...args) { return args.length; })(1,2,3,4,5)` returns `5`" 12 ); 13 assert.sameValue( 14 (function(a, ...args) { return args.length; })(1,2,3,4,5), 15 4, 16 "`(function(a, ...args) { return args.length; })(1,2,3,4,5)` returns `4`" 17 ); 18 assert.sameValue( 19 (function(a, b, ...args) { return args.length; })(1,2,3,4,5), 20 3, 21 "`(function(a, b, ...args) { return args.length; })(1,2,3,4,5)` returns `3`" 22 ); 23 assert.sameValue( 24 (function(a, b, c, ...args) { return args.length; })(1,2,3,4,5), 25 2, 26 "`(function(a, b, c, ...args) { return args.length; })(1,2,3,4,5)` returns `2`" 27 ); 28 assert.sameValue( 29 (function(a, b, c, d, ...args) { return args.length; })(1,2,3,4,5), 30 1, 31 "`(function(a, b, c, d, ...args) { return args.length; })(1,2,3,4,5)` returns `1`" 32 ); 33 assert.sameValue( 34 (function(a, b, c, d, e, ...args) { return args.length; })(1,2,3,4,5), 35 0, 36 "`(function(a, b, c, d, e, ...args) { return args.length; })(1,2,3,4,5)` returns `0`" 37 ); 38 39 reportCompare(0, 0);