spockframework / spockframework/spock

Expectations on named parameters not wrapped with Map literal give compilation error

Open
#480 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Module-Core Type-Defect
Dominant language
Java
Stars
3.6k
Forks
483
PR merge metrics
No merged PRs in 30d

Description

Originally reported on Google Code with ID 358

Mocked collaborator. Expectation set on a method with named parameters. Named parameters
must be wrapped with Map literal (although not required by Groovy). If not, compilation
error occurs.

Doesn't work:
1 * collaborator.method(param1: 1, param2: 2)

Compilation error compiling [unit] tests: unknown kind of argument list: org.codehaus.groovy.ast.expr.TupleExpression@1066d85f[org.codehaus.groovy.ast.expr.NamedArgumentListExpression@50074d62[org.codehaus.groovy.ast.expr.MapEntryExpression@f6985fa(key:
ConstantExpression[param1], value: ConstantExpression[1]), org.codehaus.groovy.ast.expr.MapEntryExpression@58dae7fd(key:
ConstantExpression[param2], value: ConstantExpression[2])]] (Use --stacktrace to see
the full trace)

Works:
1 * collaborator.method([param1: 1, param2: 2])

Please see the attached test case for the full source code.

Reported by mgryszko on 2014-04-07 14:14:22


- _Attachment: [ExpectationsOnNamedParametersSpec.groovy](https://storage.googleapis.com/google-code-attachments/spock/issue-358/comment-0/ExpectationsOnNamedParametersSpec.groovy)_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached ExpectationsOnNamedParametersSpec.groovy test case and reproduce the compilation error for unwrapped named parameters. Trace the expectation argument handling from that failing example; done means the unwrapped syntax compiles and behaves like the Map-wrapped form.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, java
Domain
compilers, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.