Create tests for trailing comma on arguments list

This commit is contained in:
Leonardo Balter 2017-03-14 16:24:26 -04:00
parent aa2c69960d
commit 41370bcb99
No known key found for this signature in database
GPG Key ID: 4191D7EB5EC82FF7
18 changed files with 473 additions and 0 deletions

View File

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/cls-decl-gen-meth-static-
name: class declaration generator method
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
class C {
static *method(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
}
}
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

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/cls-decl-gen-meth-
name: class declaration generator method
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
class C {
*method(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
}
}
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

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/cls-decl-meth-static-
name: static class declaration method
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
class C {
static method(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
}
}
C.method(/*{ args }*/);
// Stores a reference `ref` for case evaluation
var ref = C.method;
assert.sameValue(callCount, 1, 'method invoked exactly once');

View File

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/cls-decl-meth-
name: class declaration method
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
class C {
method(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
}
}
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

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/cls-expr-gen-meth-static-
name: static class expression generator method
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
var C = class {
static *method(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
}
};
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

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/cls-expr-gen-meth-
name: class expression generator method
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
var C = class {
*method(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
}
};
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

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/cls-expr-meth-static-
name: static class expression method
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
var C = class {
static method(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
}
};
C.method(/*{ args }*/);
// Stores a reference `ref` for case evaluation
var ref = C.method;
assert.sameValue(callCount, 1, 'method invoked exactly once');

View File

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/cls-expr-meth-
name: class expression method
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
var C = class {
method(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
}
};
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

@ -0,0 +1,25 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/func-decl-
name: function declaration
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
// Stores a reference `ref` for case evaluation
function ref(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
}
ref(/*{ args }*/);
assert.sameValue(callCount, 1, 'function invoked exactly once');

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/func-expr-
name: function expression
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
// Stores a reference `ref` for case evaluation
var ref;
ref = function(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
};
ref(/*{ args }*/);
assert.sameValue(callCount, 1, 'function invoked exactly once');

View File

@ -0,0 +1,25 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/gen-func-decl-
name: generator function declaration
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
// Stores a reference `ref` for case evaluation
function* ref(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
}
ref(/*{ args }*/).next();
assert.sameValue(callCount, 1, 'generator function invoked exactly once');

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/gen-func-expr-
name: generator function expression
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
// Stores a reference `ref` for case evaluation
var ref;
ref = function*(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
};
ref(/*{ args }*/).next();
assert.sameValue(callCount, 1, 'generator function invoked exactly once');

View File

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/gen-meth-
name: generator method
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
var obj = {
*method(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
}
};
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

@ -0,0 +1,29 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/arguments-object/meth-
name: method
esid: sec-arguments-exotic-objects
info: |
9.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the
characteristics of the function definition, its arguments object is either an ordinary object
or an arguments exotic object.
---*/
var callCount = 0;
var obj = {
method(/*{ params }*/) {
/*{ body }*/
callCount = callCount + 1;
}
};
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,21 @@
// 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 arguments.length, using multiple args
template: default
esid: prod-Arguments
info: |
Trailing comma in the arguments list
12.3 Left-Hand-Side Expressions
Arguments[Yield, Await] : ( ArgumentList[?Yield, ?Await] , )
---*/
//- args
42, 'TC39',
//- body
assert.sameValue(arguments.length, 2);
assert.sameValue(arguments[0], 42);
assert.sameValue(arguments[1], 'TC39');

View File

@ -0,0 +1,20 @@
// 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 after null should not increase the arguments.length
template: default
esid: prod-Arguments
info: |
Trailing comma in the arguments list
12.3 Left-Hand-Side Expressions
Arguments[Yield, Await] : ( ArgumentList[?Yield, ?Await] , )
---*/
//- args
42, null,
//- body
assert.sameValue(arguments.length, 2);
assert.sameValue(arguments[0], 42);
assert.sameValue(arguments[1], null);

View File

@ -0,0 +1,20 @@
// 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 arguments.length, using a single arg
template: default
esid: prod-Arguments
info: |
Trailing comma in the arguments list
12.3 Left-Hand-Side Expressions
Arguments[Yield, Await] : ( ArgumentList[?Yield, ?Await] , )
---*/
//- args
42,
//- body
assert.sameValue(arguments.length, 1);
assert.sameValue(arguments[0], 42);

View File

@ -0,0 +1,20 @@
// 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 after undefined should not increase the arguments.length
template: default
esid: prod-Arguments
info: |
Trailing comma in the arguments list
12.3 Left-Hand-Side Expressions
Arguments[Yield, Await] : ( ArgumentList[?Yield, ?Await] , )
---*/
//- args
42, undefined,
//- body
assert.sameValue(arguments.length, 2);
assert.sameValue(arguments[0], 42);
assert.sameValue(arguments[1], undefined);