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

Where blocks should support destructuring assignments #1036

Open
Vampire opened this issue Sep 21, 2019 · 1 comment

Comments

@Vampire
Copy link
Contributor

commented Sep 21, 2019

This is a valid test that works as expected:

def foo() {
    given:
        testee.restrictions.clear()
        testee.addAllRestrictions(restrictions)

    expect:
        testee.getRestriction(clazz).is(restriction)

    where:
        [restrictions, validCombination] << [
                [restriction1, restriction2, restriction3].permutations(),
                [
                        [Restriction1, restriction1],
                        [Restriction2, restriction2],
                        [Restriction3, restriction3]
                ]
        ].combinations()
        clazz = validCombination[0]
        restriction = validCombination[1]
}

It would be nice if instead this would be supported too:

def foo() {
    given:
        testee.restrictions.clear()
        testee.addAllRestrictions(restrictions)

    expect:
        testee.getRestriction(clazz).is(restriction)

    where:
        [restrictions, validCombination] << [
                [restriction1, restriction2, restriction3].permutations(),
                [
                        [Restriction1, restriction1],
                        [Restriction2, restriction2],
                        [Restriction3, restriction3]
                ]
        ].combinations()
        (clazz, restriction) = validCombination
}

But this version fails to compile with where-blocks may only contain parameterizations.

@Vampire

This comment has been minimized.

Copy link
Contributor Author

commented Sep 21, 2019

Even more amazing would of course be support for

def foo() {
    given:
        testee.restrictions.clear()
        testee.addAllRestrictions(restrictions)

    expect:
        testee.getRestriction(clazz).is(restriction)

    where:
        [restrictions, [clazz, restriction]] << [
                [restriction1, restriction2, restriction3].permutations(),
                [
                        [Restriction1, restriction1],
                        [Restriction2, restriction2],
                        [Restriction3, restriction3]
                ]
        ].combinations()
}

but this also fails to compile with where-blocks may only contain parameterizations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.