hakandilek / spock

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

Chained assignment of mock service fails to compile #161

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In a Spec extending grails.plugin.spock.ControllerSpec, attempt to chain 
assignment of a Mock() to the controller field and then a local variable.

eg
    AccountService accountService = controller.accountService = Mock()

This gives a Spock compilation failure.  The stack trace is below.

The equivalent statements
    AccountService accountService = Mock()
    controller.accountService = accountService
work correctly.

This is using the spock-0.5-groovy-1.7-SNAPSHOT plugin with the geb-0.4 plugin 
and Grails 1.3.5, which uses groovy 1.7.5.

Stack trace:
Unexpected error during compilation of spec 'app.TransactionControllerSpec'. 
Maybe you have used invalid Spock syntax? Anyway, please file a bug report at 
http://issues.spockframework.org.
java.lang.NullPointerException
    at org.spockframework.compiler.AstUtil.getType(AstUtil.java:275)
    at org.spockframework.compiler.AstUtil.expandBuiltinMemberAssignment(AstUtil.java:260)
    at org.spockframework.compiler.DeepStatementRewriter.visitBinaryExpression(DeepStatementRewriter.java:142)
    at org.spockframework.compiler.DeepStatementRewriter.visitDeclarationExpression(DeepStatementRewriter.java:135)
    at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:53)
    at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:69)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:195)
    at org.spockframework.compiler.DeepStatementRewriter.visitExpressionStatement(DeepStatementRewriter.java:73)
    at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
    at org.spockframework.compiler.StatementReplacingVisitorSupport.replace(StatementReplacingVisitorSupport.java:44)
    at org.spockframework.compiler.StatementReplacingVisitorSupport.replaceAll(StatementReplacingVisitorSupport.java:59)
    at org.spockframework.compiler.DeepStatementRewriter.visitBlock(DeepStatementRewriter.java:60)
    at org.spockframework.compiler.SpecRewriter.visitAnyBlock(SpecRewriter.java:400)
    at org.spockframework.compiler.model.AnonymousBlock.accept(AnonymousBlock.java:32)
    at org.spockframework.compiler.model.Method.accept(Method.java:70)
    at org.spockframework.compiler.model.Spec.accept(Spec.java:102)
    at org.spockframework.compiler.SpockTransform$ActualTransform.processSpec(SpockTransform.java:76)
    at org.spockframework.compiler.SpockTransform$ActualTransform.visit(SpockTransform.java:63)
    at org.spockframework.compiler.SpockTransform.visit(SpockTransform.java:46)
    at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:302)
    at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:814)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:511)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:487)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:464)
    at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:43)
    at org.jetbrains.groovy.compiler.rt.GroovycRunner.main(GroovycRunner.java:128)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:75)

Original issue reported on code.google.com by booco...@gmail.com on 17 Dec 2010 at 6:43

GoogleCodeExporter commented 9 years ago

Original comment by pnied...@gmail.com on 17 Dec 2010 at 9:11

GoogleCodeExporter commented 9 years ago

Original comment by pnied...@gmail.com on 20 Feb 2012 at 12:18

GoogleCodeExporter commented 9 years ago

Original comment by pnied...@gmail.com on 4 Oct 2012 at 6:51

GoogleCodeExporter commented 9 years ago

Original comment by pnied...@gmail.com on 1 Mar 2015 at 11:45