mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 22:15:24 +02:00
Move tests for params trailing comma to the test gen tool
This commit is contained in:
parent
c017b4280b
commit
c37a242057
@ -38,11 +38,12 @@ info: |
|
||||
---*/
|
||||
|
||||
var callCount = 0;
|
||||
var f;
|
||||
f = (/*{ params }*/) => {
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref;
|
||||
ref = (/*{ params }*/) => {
|
||||
/*{ body }*/
|
||||
callCount = callCount + 1;
|
||||
};
|
||||
|
||||
f(/*{ args }*/);
|
||||
ref(/*{ args }*/);
|
||||
assert.sameValue(callCount, 1, 'arrow function invoked exactly once');
|
||||
|
@ -69,4 +69,7 @@ class C {
|
||||
|
||||
C.method(/*{ args }*/).next();
|
||||
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref = C.method;
|
||||
|
||||
assert.sameValue(callCount, 1, 'method invoked exactly once');
|
||||
|
@ -69,4 +69,7 @@ class C {
|
||||
|
||||
C.prototype.method(/*{ args }*/).next();
|
||||
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref = C.prototype.method;
|
||||
|
||||
assert.sameValue(callCount, 1, 'method invoked exactly once');
|
||||
|
@ -67,4 +67,7 @@ class C {
|
||||
|
||||
C.method(/*{ args }*/);
|
||||
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref = C.method;
|
||||
|
||||
assert.sameValue(callCount, 1, 'method invoked exactly once');
|
||||
|
@ -67,4 +67,7 @@ class C {
|
||||
|
||||
C.prototype.method(/*{ args }*/);
|
||||
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref = C.prototype.method;
|
||||
|
||||
assert.sameValue(callCount, 1, 'method invoked exactly once');
|
||||
|
@ -71,4 +71,7 @@ var C = class {
|
||||
|
||||
C.method(/*{ args }*/).next();
|
||||
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref = C.method;
|
||||
|
||||
assert.sameValue(callCount, 1, 'method invoked exactly once');
|
||||
|
@ -71,4 +71,7 @@ var C = class {
|
||||
|
||||
C.prototype.method(/*{ args }*/).next();
|
||||
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref = C.prototype.method;
|
||||
|
||||
assert.sameValue(callCount, 1, 'method invoked exactly once');
|
||||
|
@ -68,4 +68,7 @@ var C = class {
|
||||
|
||||
C.method(/*{ args }*/);
|
||||
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref = C.method;
|
||||
|
||||
assert.sameValue(callCount, 1, 'method invoked exactly once');
|
||||
|
@ -68,4 +68,7 @@ var C = class {
|
||||
|
||||
C.prototype.method(/*{ args }*/);
|
||||
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref = C.prototype.method;
|
||||
|
||||
assert.sameValue(callCount, 1, 'method invoked exactly once');
|
||||
|
@ -40,11 +40,12 @@ info: |
|
||||
---*/
|
||||
|
||||
var callCount = 0;
|
||||
function f(/*{ params }*/) {
|
||||
// Stores a reference `ref` for case evaluation
|
||||
function ref(/*{ params }*/) {
|
||||
/*{ body }*/
|
||||
callCount = callCount + 1;
|
||||
}
|
||||
|
||||
f(/*{ args }*/);
|
||||
ref(/*{ args }*/);
|
||||
|
||||
assert.sameValue(callCount, 1, 'function invoked exactly once');
|
||||
|
@ -39,12 +39,13 @@ info: |
|
||||
---*/
|
||||
|
||||
var callCount = 0;
|
||||
var f;
|
||||
f = function(/*{ params }*/) {
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref;
|
||||
ref = function(/*{ params }*/) {
|
||||
/*{ body }*/
|
||||
callCount = callCount + 1;
|
||||
};
|
||||
|
||||
f(/*{ args }*/);
|
||||
ref(/*{ args }*/);
|
||||
|
||||
assert.sameValue(callCount, 1, 'function invoked exactly once');
|
||||
|
@ -39,11 +39,12 @@ info: |
|
||||
---*/
|
||||
|
||||
var callCount = 0;
|
||||
function* f(/*{ params }*/) {
|
||||
// Stores a reference `ref` for case evaluation
|
||||
function* ref(/*{ params }*/) {
|
||||
/*{ body }*/
|
||||
callCount = callCount + 1;
|
||||
}
|
||||
|
||||
f(/*{ args }*/).next();
|
||||
ref(/*{ args }*/).next();
|
||||
|
||||
assert.sameValue(callCount, 1, 'generator function invoked exactly once');
|
||||
|
@ -39,12 +39,13 @@ info: |
|
||||
---*/
|
||||
|
||||
var callCount = 0;
|
||||
var f;
|
||||
f = function*(/*{ params }*/) {
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref;
|
||||
ref = function*(/*{ params }*/) {
|
||||
/*{ body }*/
|
||||
callCount = callCount + 1;
|
||||
};
|
||||
|
||||
f(/*{ args }*/).next();
|
||||
ref(/*{ args }*/).next();
|
||||
|
||||
assert.sameValue(callCount, 1, 'generator function invoked exactly once');
|
||||
|
@ -53,4 +53,7 @@ var obj = {
|
||||
|
||||
obj.method(/*{ args }*/).next();
|
||||
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref = obj.method;
|
||||
|
||||
assert.sameValue(callCount, 1, 'generator method invoked exactly once');
|
||||
|
@ -50,4 +50,7 @@ var obj = {
|
||||
|
||||
obj.method(/*{ args }*/);
|
||||
|
||||
// Stores a reference `ref` for case evaluation
|
||||
var ref = obj.method;
|
||||
|
||||
assert.sameValue(callCount, 1, 'method invoked exactly once');
|
||||
|
23
src/params/trailing-comma-dflt-param.case
Normal file
23
src/params/trailing-comma-dflt-param.case
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// Copyright (C) 2017 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
desc: A trailing comma should not increase the respective length, using default parameters
|
||||
template: default
|
||||
info: |
|
||||
Trailing comma in the parameters list
|
||||
|
||||
14.1 Function Definitions
|
||||
|
||||
FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] ,
|
||||
---*/
|
||||
|
||||
//- params
|
||||
a, b = 39,
|
||||
//- args
|
||||
42, undefined, 1
|
||||
//- body
|
||||
assert.sameValue(a, 42);
|
||||
assert.sameValue(b, 39);
|
||||
//- teardown
|
||||
assert.sameValue(ref.length, 1, 'length is properly set');
|
23
src/params/trailing-comma-multiple-param.case
Normal file
23
src/params/trailing-comma-multiple-param.case
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// Copyright (C) 2017 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
desc: A trailing comma should not increase the respective length, using multiple parameters
|
||||
template: default
|
||||
info: |
|
||||
Trailing comma in the parameters list
|
||||
|
||||
14.1 Function Definitions
|
||||
|
||||
FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] ,
|
||||
---*/
|
||||
|
||||
//- params
|
||||
a, b,
|
||||
//- args
|
||||
42, 39, 1
|
||||
//- body
|
||||
assert.sameValue(a, 42);
|
||||
assert.sameValue(b, 39);
|
||||
//- teardown
|
||||
assert.sameValue(ref.length, 2, 'length is properly set');
|
24
src/params/trailing-comma-rest-early-error.case
Normal file
24
src/params/trailing-comma-rest-early-error.case
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// Copyright (C) 2017 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
desc: It's a syntax error if a FunctionRestParameter is followed by a trailing comma
|
||||
template: syntax
|
||||
negative:
|
||||
phase: early
|
||||
type: SyntaxError
|
||||
info: |
|
||||
Trailing comma in the parameters list
|
||||
|
||||
14.1 Function Definitions
|
||||
|
||||
FormalParameters[Yield, Await] :
|
||||
[empty]
|
||||
FunctionRestParameter[?Yield, ?Await]
|
||||
FormalParameterList[?Yield, ?Await]
|
||||
FormalParameterList[?Yield, ?Await] ,
|
||||
FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await]
|
||||
---*/
|
||||
|
||||
//- params
|
||||
...a,
|
22
src/params/trailing-comma-single-param.case
Normal file
22
src/params/trailing-comma-single-param.case
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// Copyright (C) 2017 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
desc: A trailing comma should not increase the respective length, using a single parameter
|
||||
template: default
|
||||
info: |
|
||||
Trailing comma in the parameters list
|
||||
|
||||
14.1 Function Definitions
|
||||
|
||||
FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] ,
|
||||
---*/
|
||||
|
||||
//- params
|
||||
a,
|
||||
//- args
|
||||
42, 39
|
||||
//- body
|
||||
assert.sameValue(a, 42);
|
||||
//- teardown
|
||||
assert.sameValue(ref.length, 1, 'length is properly set');
|
@ -1,21 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Check that trailing commas don't affect the .length property of arrow
|
||||
functions.
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
((a,) => {}).length,
|
||||
1,
|
||||
"Arrow function with 1 arg + trailing comma reports incorrect .length!"
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
((a,b,) => {}).length,
|
||||
2,
|
||||
"Arrow function with 2 args + trailing comma reports incorrect .length!"
|
||||
);
|
@ -1,9 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Check that trailing commas are permitted in arrow function argument lists
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
((a,) => {});
|
||||
((a,b,) => {});
|
@ -1,21 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Check that trailing commas don't affect the .length property of
|
||||
function expressions.
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
(function(a,) {}).length,
|
||||
1,
|
||||
"Function expression with 1 arg + trailing comma reports incorrect .length!"
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
(function(a,b,) {}).length,
|
||||
2,
|
||||
"Function expression with 2 args + trailing comma reports incorrect .length!"
|
||||
);
|
@ -1,11 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Check that trailing commas are permitted in function expression
|
||||
argument lists.
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
var one = (0, function(a,) {});
|
||||
var two = (0, function(a,b,) {});
|
@ -1,21 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Check that trailing commas don't affect the .length property of generator
|
||||
function expressions.
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
(function*(a,) {}).length,
|
||||
1,
|
||||
"Generator expression with 1 arg + trailing comma reports incorrect .length!"
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
(function*(a,b,) {}).length,
|
||||
2,
|
||||
"Generator expression with 2 args + trailing comma reports incorrect .length!"
|
||||
);
|
@ -1,9 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Check that trailing commas are permitted in generator function argument lists
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
var one = (0, function*(a,) {});
|
||||
var two = (0, function*(a,b,) {});
|
@ -1,26 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Check that trailing commas don't affect the .length property of
|
||||
object methods.
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
|
||||
var obj = {
|
||||
one(a,) {},
|
||||
two(a,b,) {},
|
||||
};
|
||||
|
||||
assert.sameValue(
|
||||
obj.one.length,
|
||||
1,
|
||||
"Object method with 1 arg + trailing comma reports incorrect .length!"
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
obj.two.length,
|
||||
2,
|
||||
"Object method with 2 args + trailing comma reports incorrect .length!"
|
||||
);
|
@ -1,15 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Check that trailing commas are not permitted after rest params in
|
||||
object method parameter lists.
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
negative:
|
||||
phase: early
|
||||
type: SyntaxError
|
||||
---*/
|
||||
({
|
||||
m(...[],) {}
|
||||
});
|
@ -1,11 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Check that trailing commas are permitted in object method argument lists
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
({
|
||||
one(a,) {},
|
||||
two(a,b,) {},
|
||||
});
|
@ -1,14 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Check that trailing commas are not permitted permitted after rest
|
||||
arguments in arrow function argument lists.
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
negative:
|
||||
phase: early
|
||||
type: SyntaxError
|
||||
---*/
|
||||
|
||||
((...a,) => {})
|
@ -1,26 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Check that trailing commas don't affect the .length property of
|
||||
class methods.
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
|
||||
class C {
|
||||
one(a,) {}
|
||||
two(a,b,) {}
|
||||
};
|
||||
|
||||
assert.sameValue(
|
||||
C.prototype.one.length,
|
||||
1,
|
||||
"Class method with 1 arg + trailing comma reports incorrect .length!"
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
C.prototype.two.length,
|
||||
2,
|
||||
"Class method with 2 args + trailing comma reports incorrect .length!"
|
||||
);
|
@ -1,15 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Check that trailing commas are not permitted after rest args in
|
||||
class method parameter lists.
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
negative:
|
||||
phase: early
|
||||
type: SyntaxError
|
||||
---*/
|
||||
class C {
|
||||
m(...[],) {}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Check that trailing commas are permitted in class method argument lists
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
class C {
|
||||
one(a,) {}
|
||||
two(a,b,) {}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Check that trailing commas don't affect the .length property of
|
||||
function declarations.
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
|
||||
function one(a,) {}
|
||||
function two(a,b,) {}
|
||||
|
||||
assert.sameValue(
|
||||
one.length,
|
||||
1,
|
||||
"Function expression with 1 arg + trailing comma reports incorrect .length!"
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
two.length,
|
||||
2,
|
||||
"Function expression with 2 args + trailing comma reports incorrect .length!"
|
||||
);
|
@ -1,9 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Check that trailing commas are permitted in function declaration argument lists
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
function one(a,) {}
|
||||
function two(a,b,) {}
|
@ -1,24 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Check that trailing commas don't affect the .length property of
|
||||
generator function declarations.
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
|
||||
function* one(a,) {}
|
||||
function* two(a,b,) {}
|
||||
|
||||
assert.sameValue(
|
||||
one.length,
|
||||
1,
|
||||
"Function expression with 1 arg + trailing comma reports incorrect .length!"
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
two.length,
|
||||
2,
|
||||
"Function expression with 2 args + trailing comma reports incorrect .length!"
|
||||
);
|
@ -1,9 +0,0 @@
|
||||
// Copyright (C) 2016 Jeff Morrison. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: Check that trailing commas are permitted in generator function argument lists
|
||||
info: http://jeffmo.github.io/es-trailing-function-commas/
|
||||
author: Jeff Morrison <lbljeffmo@gmail.com>
|
||||
---*/
|
||||
function* one(a,) {}
|
||||
function* two(a,b,) {}
|
Loading…
x
Reference in New Issue
Block a user