[ 
https://issues.apache.org/jira/browse/GROOVY-8537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16429825#comment-16429825
 ] 

ASF GitHub Bot commented on GROOVY-8537:
----------------------------------------

GitHub user rvprasad opened a pull request:

    https://github.com/apache/groovy/pull/682

    GroovyCollections.combinations(Iterable) exhibits incorrect (asymmetric) 
behavior.

    The fix ensures no combination is returned if any of the input iterables to
    GroovyCollections.combinations() is empty.
    
    https://issues.apache.org/jira/browse/GROOVY-8537

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/rvprasad/groovy GROOVY-8537

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/682.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #682
    
----
commit 8e6d955f7a519dbeac737b77930d7007d9681912
Author: Venkatesh-Prasad Ranganath <rvprasad@...>
Date:   2018-04-08T17:45:18Z

    Fixes issue GROOVY-8537
    
    Ensures no combination is returned if any of the input iterables to
    GroovyCollections.combinations() is empty.

----


> GroovyCollections.combinations(Iterable) exhibits incorrect (asymmetric) 
> behavior
> ---------------------------------------------------------------------------------
>
>                 Key: GROOVY-8537
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8537
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk
>    Affects Versions: 2.4.15
>            Reporter: Venkatesh-Prasad Ranganath
>            Priority: Major
>              Labels: easyfix
>
> h4. *Issue*
> When GroovyCollections.combinations() is invoked on a collection of iterables 
> with at least one empty iterable, the expected return value is an empty list 
> of combinations.
> Instead, in version 2.4.15 (and I am guessing in earlier versions at least 
> since 2.2.0), the return value of combinations() is sensitive to the order of 
> iterables in the input collection.  Here are two instances of such behavior.
> h4. Repro
> {{groovy:000> assert [[1,3], []].combinations() == [[], 
> [1,3]].combinations()}}
>  {{ERROR org.codehaus.groovy.runtime.powerassert.PowerAssertionError:}}
>  {{assert [[1,3], []].combinations() == [[], [1,3]].combinations()}}
>  {{                   |              |              |}}
>  {{                   []             false          [[1], [3]]}}
>  
> {{groovy:000> assert [[1,3], [2], []].combinations() == [[1,3], [], 
> [2]].combinations()}}
>  {{ERROR org.codehaus.groovy.runtime.powerassert.PowerAssertionError:}}
>  {{assert [[1,3], [2], []].combinations() == [[1,3], [], [2]].combinations()}}
>  {{                        |              |                   |}}
>  {{                        []             false               [[2]]}}
> h4. *Fix*
> Add a short-circuiting check at the start of combinations(Iterable) method to 
> return an empty list of combination if any of the input iterables are empty.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to