Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spock breaks start-exclusive ranges #1956

Closed
spartanhooah opened this issue May 17, 2024 · 1 comment · Fixed by #1958
Closed

Spock breaks start-exclusive ranges #1956

spartanhooah opened this issue May 17, 2024 · 1 comment · Fixed by #1958
Labels

Comments

@spartanhooah
Copy link

spartanhooah commented May 17, 2024

Describe the bug

When creating a Groovy range like 0<..5 which should exclude the first number, a Spock test will not exclude the first number.

To Reproduce

class RangeTest extends Specification {
    def "test range"() {
        expect:
        (0<..5).first() == 1
    }
}

Expected behavior

A range constructed as a<..b will start at the next value after a.

Actual behavior

A range constructed as a<..b starts at a.

Java version

17

Buildtool version

Gradle 8.3

What operating system are you using

Mac

Dependencies

org.spockframework:spock-core:2.4-M4-groovy-4.0

Additional context

No response

@leonard84
Copy link
Member

leonard84 commented May 17, 2024

Another reproducer compared to plain groovy.

import spock.lang.*

class ASpec extends Specification {
  def "test range"() {
        expect:
        (0..5) == [0, 1, 2, 3, 4, 5]
        (0<..5) == [1, 2, 3, 4, 5]
        (0..<5) == [0, 1, 2, 3, 4]
        (0<..<5) == [1, 2, 3, 4]
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants