aherbert commented on PR #336:
URL: 
https://github.com/apache/commons-collections/pull/336#issuecomment-1253402931

   Changing the implementation to pass a test is the wrong solution. This 
compromises the implementation. You should change the test. Either:
   
   - The toArray result is expected to match the iterator order. Add both to a 
list and use assertEquals.
   - The toArray result is expected to output the same items as the iterator. 
Add both to a set and use assertEquals.
   
   The test should have a behaviour flag to be overridden by implementing test 
cases:
   
   ```Java
   /**
    * Flag to indicate the collection makes no ordering guarantees for the 
iterator. If this is not used
    * then the behaviour is assumed to be ordered and the output order of the 
iterator is matched by
    * the toArray method.
    */
   protected static final int UNORDERED = 0x1;
   
   /**
    * Return a flag specifying the behaviour of the collection.
    * This is used to change the assertions used by specific tests.
    *
    * @return the behaviour
    */
   protected abstract int getBehaviour();
   ```
   Update the test to handle both cases:
   ```Java
   if ((getBehaviour() & UNORDERED) != 0) {
       // Not expected to be ordered
   } else {
       // Order must match
   }
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to