thenirajpandey / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

Multi-assignment statement in "setup" block does not compile #373

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have a "setup" block in my test with the following code:
        def (parentGroupId, childGroupId1, childGroupId2) = createGroupWithAssociations()

The method being invoked returns a List of three items. When I try to run the 
test I get the following compilation error:
    java.lang.ClassCastException: org.codehaus.groovy.ast.expr.ArgumentListExpression cannot be cast to org.codehaus.groovy.ast.expr.VariableExpression
        at org.codehaus.groovy.ast.expr.DeclarationExpression.getVariableExpression(DeclarationExpression.java:100)
        at org.spockframework.compiler.SpecRewriter.moveVariableDeclarations(SpecRewriter.java:538)
...

See attachment for full stacktrace.

When I rewrite the code so that it doesn't use Groovy's multi-assignment, the 
test compiles and passes fine:
        def groupIds = createGroupWithAssociations()
        def parentGroupId = groupIds[0]
        def childGroupId1 = groupIds[1]
        def childGroupId2 = groupIds[2]

Using Grails 2.3.8 and thus:
=> spock-core:0.7-groovy-2.0
=> groovy-all:2.1.9

Please provide any additional information below. You can also assign
labels.

Original issue reported on code.google.com by vpazi...@gmail.com on 14 Aug 2014 at 9:55

Attachments: