Move tests for params trailing comma to the test gen tool

This commit is contained in:
Leonardo Balter 2017-03-14 14:24:31 -04:00
parent c017b4280b
commit c37a242057
No known key found for this signature in database
GPG Key ID: 4191D7EB5EC82FF7
36 changed files with 140 additions and 289 deletions

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View 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');

View 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');

View 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,

View 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');

View File

@ -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!"
);

View File

@ -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,) => {});

View File

@ -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!"
);

View File

@ -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,) {});

View File

@ -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!"
);

View File

@ -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,) {});

View File

@ -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!"
);

View File

@ -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(...[],) {}
});

View File

@ -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,) {},
});

View File

@ -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,) => {})

View File

@ -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!"
);

View File

@ -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(...[],) {}
}

View File

@ -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,) {}
}

View File

@ -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!"
);

View File

@ -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,) {}

View File

@ -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!"
);

View File

@ -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,) {}