sampig / spock

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

Multi-line asserts with // comments failing with syntax error #325

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This simple spec:

class MyUnitTestSpec extends spock.lang.Specification {
    def "sample test"() {
        expect:
        [] == [
            'a',
            //
            'b',
        ]
    }
}

fails with 

| Running 1 spock test... 1 of 1
| Failure:  sample test(MyUnitTestSpec)
|  org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
failed:
Spec expression: 1: unexpected token:  @ line 1, column 23.
   [] == [ 'a', // 'b', ]
                         ^

1 error

    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:309)
    at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:106)
    at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:148)
    at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:119)
    at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:131)
    at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:359)
    at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:142)
    at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:108)
    at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236)
    at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138)
    at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138)
    at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:24)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:117)
    at grails.plugin.spock.test.GrailsSpecTestType.doRun(GrailsSpecTestType.groovy:73)
    at _GrailsTest_groovy.run_closure4(_GrailsTest_groovy:290)
    at _GrailsTest_groovy.run_closure2(_GrailsTest_groovy:248)
    at _GrailsTest_groovy.run_closure1_closure21(_GrailsTest_groovy:195)
    at _GrailsTest_groovy.run_closure1(_GrailsTest_groovy:184)
    at TestApp.run_closure1(TestApp.groovy:82)
| Completed 1 spock test, 1 failed in 146ms

Environment:
Grails 2.1.0
spock-core-0.7-groovy-2.0.jar
spock-grails-support-0.7-groovy-2.0.jar
groovy-all-2.0.5.jar

Original issue reported on code.google.com by fsalexm...@gmail.com on 12 Aug 2013 at 1:24

GoogleCodeExporter commented 9 years ago
It's a known limitation that applies to some (not all) multi-line conditions.

Original comment by pnied...@gmail.com on 12 Aug 2013 at 1:41