Forgus / spock

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

@Unroll expressions include trailing parenthesis #268

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
A spec like the following started having an error in the unrolled names when 
updating from Spock 0.5 to 0.6.  The names in 0.6 look like:

max(1, #Error:b) == 2
max(5, #Error:b) == 5

whereas in 0.5 they are as expected:

max(1, 2) == 2
max(5, 3) == 5

    @Unroll
    def "max(#a, #b) == #max"() {

        expect:
        Math.max(a, b) == max

        where:
        a   | b    | max
        1   | 2    | 2
        5   | 3    | 5
    }

What version of Spock and Groovy are you using? 0.6 1.8.6

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

I guess this is from the added support of zero-arg method calls.  The trailing 
parenthesis is included in the expression, preventing the data name from being 
found.

A work-around is to put a space in front of the parenthesis.

A fix might be to change the UnrollNameProvider.EXPRESSION_PATTERN to something 
like "#([a-zA-Z_\\$]([\\w\\$\\.]|\\(\\))*)"

Original issue reported on code.google.com by jdbeu...@gmail.com on 27 Sep 2012 at 3:20

GoogleCodeExporter commented 8 years ago
Of course, in 0.5, the expressions were in the Unroll value.  Also, actually, 
I'm using Grails 1.3.7, so Groovy 1.7, but I don't think it makes any 
difference.  I looked at all 3 Spock branches and did not see any fix.

Original comment by jdbeu...@gmail.com on 27 Sep 2012 at 3:29

GoogleCodeExporter commented 8 years ago

Original comment by pnied...@gmail.com on 28 Sep 2012 at 4:22