Skip to content

Tests for trailing commas in function arg lists#733

Merged
tcare merged 1 commit into
tc39:masterfrom
jeffmo:master
Jul 28, 2016
Merged

Tests for trailing commas in function arg lists#733
tcare merged 1 commit into
tc39:masterfrom
jeffmo:master

Conversation

@jeffmo

@jeffmo jeffmo commented Jul 26, 2016

Copy link
Copy Markdown
Member

Adds tests for the proposal as described here:
http://jeffmo.github.io/es-trailing-function-commas/

cc @bterlson @ljharb

@caitp

caitp commented Jul 26, 2016

Copy link
Copy Markdown
Contributor

Looks like there are some good tests missing

  • negative tests for , following rest parameters
  • testing arrow functions, generators, methods, etc

it also might be a bit confusing to mix the Arguments trailing commas and FormalParameters trailing commas tests in the same file, but I don't have that much of an opinion on that

@leobalter

Copy link
Copy Markdown
Member

we also need to structure these tests under the existing folders for the functions forms including those listed by @caitp

@jeffmo

jeffmo commented Jul 26, 2016

Copy link
Copy Markdown
Member Author

Looks like there are some good tests missing

Good catch! Will add

we also need to structure these tests under the existing folders for the functions forms

Can you point me to which directories this would be? I wasn't sure if there was a better place for these (or if I named the test file in an acceptable way?)

@leobalter

Copy link
Copy Markdown
Member

sure!

  • test/language/expressions/{function,generators,arrow-function}
  • test/language/rest-parameters
  • test/language/statements/{function,generators}
  • test/language/expressions/object/method-definition
  • test/language/statements/class/definition
  • test/language/{expressions,statements}/async-function (see Add tests for async functions #479)
  • test/built-ins/{Function,GeneratorFunction,AsyncFunction}

It looks like a lot of tests, but they might be easier if you use the test generation tool available within the repo.

@tcare

tcare commented Jul 27, 2016

Copy link
Copy Markdown
Member

Would you mind adding some tests making sure the arguments object is unaffected?

// 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 argument lists

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generator function*?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar for other descriptions, which should be a bit more descriptive about the individual test's high level purpose

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I've updated the generator descriptions to include "generator".

What level of clarity are you looking for for other descriptions though? The current descriptions seem pretty clear to me, but happy to add additional context where necessary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it doesn't have to be as detailed as Mike's tests for example, but something like #735 is a good example.

In this particular case documenting the type of function and/or why the test is interesting (e.g. rest) would be helpful.

assert.sameValue(
((a,) => {}).length,
1,
"Arrow function with 1 arg + trailing comma reports incorrect .length1"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"length1" (typo -- willfix)

@jeffmo jeffmo force-pushed the master branch 2 times, most recently from 5eee695 to e4ab353 Compare July 28, 2016 18:36
@jeffmo

jeffmo commented Jul 28, 2016

Copy link
Copy Markdown
Member Author

Ok, I've gone through the descriptions and tried to be more specific. Let me know what you think

@tcare

tcare commented Jul 28, 2016

Copy link
Copy Markdown
Member

Looks good! Thanks for the update. Would @caitp or @leobalter mind doing a second signoff?

@caitp

caitp commented Jul 28, 2016

Copy link
Copy Markdown
Contributor

Rubberstamp --- I think there are good tests here, which are not tested for all the variants. I am a fan of exhaustive tests, but it is a lot of effort I guess =)

@tcare

tcare commented Jul 28, 2016

Copy link
Copy Markdown
Member

I'll merge this for now - @jeffmo feel free to add more tests if you agree with @caitp :)

@tcare tcare merged commit b785fdf into tc39:master Jul 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants