Skip to content

Commit

Permalink
Add tests for trailing commas in functions which have no arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Sep 6, 2016
1 parent 0e7a336 commit f5a6d81
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/tests-trailing-commas-in-func.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,3 +778,19 @@ testFail("(class {static foo(...a,) {}})", "Comma is not permitted after the res
testFail("export default function foo(...a,) { }", "Comma is not permitted after the rest element (1:32)", {ecmaVersion: 8, sourceType: "module"})
testFail("export default (function foo(...a,) { })", "Comma is not permitted after the rest element (1:33)", {ecmaVersion: 8, sourceType: "module"})
testFail("export function foo(...a,) { }", "Comma is not permitted after the rest element (1:24)", {ecmaVersion: 8, sourceType: "module"})

//------------------------------------------------------------------------------
// disallow empty

testFail("function foo(,) { }", "Unexpected token (1:13)", {ecmaVersion: 8})
testFail("(function(,) { })", "Unexpected token (1:10)", {ecmaVersion: 8})
testFail("(,) => a", "Unexpected token (1:1)", {ecmaVersion: 8})
testFail("async (,) => a", "Unexpected token (1:7)", {ecmaVersion: 8})
testFail("({foo(,) {}})", "Unexpected token (1:6)", {ecmaVersion: 8})
testFail("class A {foo(,) {}}", "Unexpected token (1:13)", {ecmaVersion: 8})
testFail("class A {static foo(,) {}}", "Unexpected token (1:20)", {ecmaVersion: 8})
testFail("(class {foo(,) {}})", "Unexpected token (1:12)", {ecmaVersion: 8})
testFail("(class {static foo(,) {}})", "Unexpected token (1:19)", {ecmaVersion: 8})
testFail("export default function foo(,) { }", "Unexpected token (1:28)", {ecmaVersion: 8, sourceType: "module"})
testFail("export default (function foo(,) { })", "Unexpected token (1:29)", {ecmaVersion: 8, sourceType: "module"})
testFail("export function foo(,) { }", "Unexpected token (1:20)", {ecmaVersion: 8, sourceType: "module"})

0 comments on commit f5a6d81

Please sign in to comment.