You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by mureinik <gi...@git.apache.org> on 2018/02/27 17:29:08 UTC

[GitHub] commons-lang pull request #316: Remove inequality check from shuffle tests

GitHub user mureinik opened a pull request:

    https://github.com/apache/commons-lang/pull/316

    Remove inequality check from shuffle tests

    The `ArrayUtils.shuffle` methods could conceivably shuffle an array in a way that leaves the shuffled array equal to the original array, and thus asserting that the shuffled array differs from the original
    array in the test only passes statistically.
    
    The chance of this happening increases as an inverse of the number of distinct values in the array. E.g., in the edge case of an array where all the elements are equal to each other, shuffling the array has a 100% chance of producing an array that's equal to the original array. A less extreme case is the case of
    `ArrayUtilsTest#testShuffleBoolean` that shuffles an array that contains ten elements, but only two distinct values (true and false) has been seen to fail in Travis CI [1].
    
    This patch removes this problematic assertion and leaves only the tests on the content of the array.
    
    [1] https://travis-ci.org/apache/commons-lang/jobs/346806985

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

    $ git pull https://github.com/mureinik/commons-lang shuffle-tests

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

    https://github.com/apache/commons-lang/pull/316.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 #316
    
----
commit fa1664f0abc5105e44e97fe8802b05965670dc67
Author: Allon Mureinik <am...@...>
Date:   2018-02-27T17:16:34Z

    Remove inequality check from shuffle tests
    
    The ArrayUtils.shuffle methods could conceivably shuffle an array in
    a way that leaves the shuffled array equal to the original array, and
    thus asserting that the shuffled array differs from the original
    array in the test only passes statistically.
    
    The chance of this happening increases as an inverse of the number of
    distinct values in the array. E.g., in the edge case of an array
    where all the elements are equal to each other, shuffling the array
    has a 100% chance of producing an array that's equal to the original
    array. A less extreme case is the case of
    ArrayUtilsTest#testShuffleBoolean that shuffles an array that contains
    ten elements, but only two distinct values (true and false) has been
    seen to fail in Travis CI [1].
    
    This patch removes this problematic assertion and leaves only the
    tests on the content of the array.
    
    [1] https://travis-ci.org/apache/commons-lang/jobs/346806985

----


---

[GitHub] commons-lang pull request #316: Remove inequality check from shuffle tests

Posted by mureinik <gi...@git.apache.org>.
Github user mureinik closed the pull request at:

    https://github.com/apache/commons-lang/pull/316


---

[GitHub] commons-lang issue #316: Remove inequality check from shuffle tests

Posted by coveralls <gi...@git.apache.org>.
Github user coveralls commented on the issue:

    https://github.com/apache/commons-lang/pull/316
  
    
    [![Coverage Status](https://coveralls.io/builds/15722581/badge)](https://coveralls.io/builds/15722581)
    
    Coverage remained the same at 95.263% when pulling **fa1664f0abc5105e44e97fe8802b05965670dc67 on mureinik:shuffle-tests** into **415eb9ebb755cea4753d6191b166b88192de5b41 on apache:master**.



---