From 41370bcb994d564b9b3ea35734ed1a6939e1bc9a Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Tue, 14 Mar 2017 16:24:26 -0400 Subject: [PATCH] Create tests for trailing comma on arguments list --- .../default/cls-decl-gen-meth-static.template | 29 +++++++++++++++++++ .../default/cls-decl-gen-meth.template | 29 +++++++++++++++++++ .../default/cls-decl-meth-static.template | 29 +++++++++++++++++++ src/arguments/default/cls-decl-meth.template | 29 +++++++++++++++++++ .../default/cls-expr-gen-meth-static.template | 29 +++++++++++++++++++ .../default/cls-expr-gen-meth.template | 29 +++++++++++++++++++ .../default/cls-expr-meth-static.template | 29 +++++++++++++++++++ src/arguments/default/cls-expr-meth.template | 29 +++++++++++++++++++ src/arguments/default/func-decl.template | 25 ++++++++++++++++ src/arguments/default/func-expr.template | 26 +++++++++++++++++ src/arguments/default/gen-func-decl.template | 25 ++++++++++++++++ src/arguments/default/gen-func-expr.template | 26 +++++++++++++++++ src/arguments/default/gen-meth.template | 29 +++++++++++++++++++ src/arguments/default/meth.template | 29 +++++++++++++++++++ .../trailing-comma-multiple-args.case | 21 ++++++++++++++ src/arguments/trailing-comma-null.case | 20 +++++++++++++ src/arguments/trailing-comma-single-args.case | 20 +++++++++++++ src/arguments/trailing-comma-undefined.case | 20 +++++++++++++ 18 files changed, 473 insertions(+) create mode 100644 src/arguments/default/cls-decl-gen-meth-static.template create mode 100644 src/arguments/default/cls-decl-gen-meth.template create mode 100644 src/arguments/default/cls-decl-meth-static.template create mode 100644 src/arguments/default/cls-decl-meth.template create mode 100644 src/arguments/default/cls-expr-gen-meth-static.template create mode 100644 src/arguments/default/cls-expr-gen-meth.template create mode 100644 src/arguments/default/cls-expr-meth-static.template create mode 100644 src/arguments/default/cls-expr-meth.template create mode 100644 src/arguments/default/func-decl.template create mode 100644 src/arguments/default/func-expr.template create mode 100644 src/arguments/default/gen-func-decl.template create mode 100644 src/arguments/default/gen-func-expr.template create mode 100644 src/arguments/default/gen-meth.template create mode 100644 src/arguments/default/meth.template create mode 100644 src/arguments/trailing-comma-multiple-args.case create mode 100644 src/arguments/trailing-comma-null.case create mode 100644 src/arguments/trailing-comma-single-args.case create mode 100644 src/arguments/trailing-comma-undefined.case diff --git a/src/arguments/default/cls-decl-gen-meth-static.template b/src/arguments/default/cls-decl-gen-meth-static.template new file mode 100644 index 0000000000..e57381376d --- /dev/null +++ b/src/arguments/default/cls-decl-gen-meth-static.template @@ -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'); diff --git a/src/arguments/default/cls-decl-gen-meth.template b/src/arguments/default/cls-decl-gen-meth.template new file mode 100644 index 0000000000..d24c31401f --- /dev/null +++ b/src/arguments/default/cls-decl-gen-meth.template @@ -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'); diff --git a/src/arguments/default/cls-decl-meth-static.template b/src/arguments/default/cls-decl-meth-static.template new file mode 100644 index 0000000000..ea045e283a --- /dev/null +++ b/src/arguments/default/cls-decl-meth-static.template @@ -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'); diff --git a/src/arguments/default/cls-decl-meth.template b/src/arguments/default/cls-decl-meth.template new file mode 100644 index 0000000000..b7f09f8ddb --- /dev/null +++ b/src/arguments/default/cls-decl-meth.template @@ -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'); diff --git a/src/arguments/default/cls-expr-gen-meth-static.template b/src/arguments/default/cls-expr-gen-meth-static.template new file mode 100644 index 0000000000..1fefb34eef --- /dev/null +++ b/src/arguments/default/cls-expr-gen-meth-static.template @@ -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'); diff --git a/src/arguments/default/cls-expr-gen-meth.template b/src/arguments/default/cls-expr-gen-meth.template new file mode 100644 index 0000000000..0781417d6e --- /dev/null +++ b/src/arguments/default/cls-expr-gen-meth.template @@ -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'); diff --git a/src/arguments/default/cls-expr-meth-static.template b/src/arguments/default/cls-expr-meth-static.template new file mode 100644 index 0000000000..57dfc2293c --- /dev/null +++ b/src/arguments/default/cls-expr-meth-static.template @@ -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'); diff --git a/src/arguments/default/cls-expr-meth.template b/src/arguments/default/cls-expr-meth.template new file mode 100644 index 0000000000..99d5c56878 --- /dev/null +++ b/src/arguments/default/cls-expr-meth.template @@ -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'); diff --git a/src/arguments/default/func-decl.template b/src/arguments/default/func-decl.template new file mode 100644 index 0000000000..271dac0075 --- /dev/null +++ b/src/arguments/default/func-decl.template @@ -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'); diff --git a/src/arguments/default/func-expr.template b/src/arguments/default/func-expr.template new file mode 100644 index 0000000000..58fc722859 --- /dev/null +++ b/src/arguments/default/func-expr.template @@ -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'); diff --git a/src/arguments/default/gen-func-decl.template b/src/arguments/default/gen-func-decl.template new file mode 100644 index 0000000000..b9e7fdcc9c --- /dev/null +++ b/src/arguments/default/gen-func-decl.template @@ -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'); diff --git a/src/arguments/default/gen-func-expr.template b/src/arguments/default/gen-func-expr.template new file mode 100644 index 0000000000..70baf6f7a7 --- /dev/null +++ b/src/arguments/default/gen-func-expr.template @@ -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'); diff --git a/src/arguments/default/gen-meth.template b/src/arguments/default/gen-meth.template new file mode 100644 index 0000000000..a459aecf61 --- /dev/null +++ b/src/arguments/default/gen-meth.template @@ -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'); diff --git a/src/arguments/default/meth.template b/src/arguments/default/meth.template new file mode 100644 index 0000000000..5cbe571841 --- /dev/null +++ b/src/arguments/default/meth.template @@ -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'); diff --git a/src/arguments/trailing-comma-multiple-args.case b/src/arguments/trailing-comma-multiple-args.case new file mode 100644 index 0000000000..6fec35a0cc --- /dev/null +++ b/src/arguments/trailing-comma-multiple-args.case @@ -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'); diff --git a/src/arguments/trailing-comma-null.case b/src/arguments/trailing-comma-null.case new file mode 100644 index 0000000000..1eb48aa0f3 --- /dev/null +++ b/src/arguments/trailing-comma-null.case @@ -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); diff --git a/src/arguments/trailing-comma-single-args.case b/src/arguments/trailing-comma-single-args.case new file mode 100644 index 0000000000..33eceeb586 --- /dev/null +++ b/src/arguments/trailing-comma-single-args.case @@ -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); diff --git a/src/arguments/trailing-comma-undefined.case b/src/arguments/trailing-comma-undefined.case new file mode 100644 index 0000000000..c8cd3ec3ba --- /dev/null +++ b/src/arguments/trailing-comma-undefined.case @@ -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);