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

Return same instance instead of wrapping Iterator results when possible #5

Open
danieldietrich opened this issue Jan 10, 2017 · 0 comments

Comments

@danieldietrich
Copy link
Contributor

  1. Remove the method useIsEqualToInsteadOfIsSameAs() from unit tests and test for isSameAs()
  2. fix broken unit tests

Example: take(0)

// AbstractTraversableTest
@Test
public void shouldTakeNoneOnNil() {
    if (useIsEqualToInsteadOfIsSameAs()) {
        assertThat(empty().take(1)).isEqualTo(empty());
    } else {
        assertThat(empty().take(1)).isSameAs(empty());
    }
}
// PriorityQueue (current)
@Override
public PriorityQueue<T> take(int n) {
    return ofAll(comparator, iterator().take(n));
}

// PriorityQueue (time and mem saver)
@Override
public PriorityQueue<T> take(int n) {
    if (n <= 0) {
        return this;
    } else if (n >= size()) {
        return empty(comparator());
    } else {
        return ofAll(comparator, iterator().take(n));
    }
}

This was only an example. We have many similar occurrences.

NataliiaPrivezentseva referenced this issue in NataliiaPrivezentseva/vavr Nov 17, 2017
…ents(), shouldNotRemoveAllNonMatchedElementsFromNonNil(), and shouldRemoveNonExistingElements() methods, added annotation @SuppressWarnings(deprecation) (#1807)
danieldietrich referenced this issue in vavr-io/vavr Nov 23, 2017
#2170)

* Eliminated method useIsEqualToInsteadOfIsSameAs() from AbstractSeqTest class and prepared code for elimination this method from related classes: ArrayTest, HashSetTest, ListTest, QueueTest, StreamTest and VectorTest

* Revert "Eliminated method useIsEqualToInsteadOfIsSameAs() from AbstractSeqTest class and prepared code for elimination this method from related classes: ArrayTest, HashSetTest, ListTest, QueueTest, StreamTest and VectorTest"

This reverts commit 0b053df in order to
delete multiple unnecessary changes.

* Eliminated useIsEqualToInsteadOfIsSameAs() from AbstractSeqTest class and updated test code to reflect this change

* Used reject(Predicate) instead of removeAll(Predicate) in shouldRemoveExistingElements() and shouldRemoveNonExistingElements() methods

* Used reject(Predicate) instead of removeAll(Predicate) in shouldNotRemoveAllNonMatchedElementsFromNonNil() method

* Returned back method removeAll(Predicate) in shouldRemoveExistingElements(), shouldNotRemoveAllNonMatchedElementsFromNonNil(), and shouldRemoveNonExistingElements() methods, added annotation @SuppressWarnings(deprecation) (#1807)
NataliiaPrivezentseva referenced this issue in NataliiaPrivezentseva/vavr Dec 8, 2017
danieldietrich referenced this issue in vavr-io/vavr Jan 13, 2019
#2170)

* Eliminated method useIsEqualToInsteadOfIsSameAs() from AbstractSeqTest class and prepared code for elimination this method from related classes: ArrayTest, HashSetTest, ListTest, QueueTest, StreamTest and VectorTest

* Revert "Eliminated method useIsEqualToInsteadOfIsSameAs() from AbstractSeqTest class and prepared code for elimination this method from related classes: ArrayTest, HashSetTest, ListTest, QueueTest, StreamTest and VectorTest"

This reverts commit 0b053df in order to
delete multiple unnecessary changes.

* Eliminated useIsEqualToInsteadOfIsSameAs() from AbstractSeqTest class and updated test code to reflect this change

* Used reject(Predicate) instead of removeAll(Predicate) in shouldRemoveExistingElements() and shouldRemoveNonExistingElements() methods

* Used reject(Predicate) instead of removeAll(Predicate) in shouldNotRemoveAllNonMatchedElementsFromNonNil() method

* Returned back method removeAll(Predicate) in shouldRemoveExistingElements(), shouldNotRemoveAllNonMatchedElementsFromNonNil(), and shouldRemoveNonExistingElements() methods, added annotation @SuppressWarnings(deprecation) (#1807)
danieldietrich referenced this issue in vavr-io/vavr Jan 13, 2019
#2170)

* Eliminated method useIsEqualToInsteadOfIsSameAs() from AbstractSeqTest class and prepared code for elimination this method from related classes: ArrayTest, HashSetTest, ListTest, QueueTest, StreamTest and VectorTest

* Revert "Eliminated method useIsEqualToInsteadOfIsSameAs() from AbstractSeqTest class and prepared code for elimination this method from related classes: ArrayTest, HashSetTest, ListTest, QueueTest, StreamTest and VectorTest"

This reverts commit 0b053df in order to
delete multiple unnecessary changes.

* Eliminated useIsEqualToInsteadOfIsSameAs() from AbstractSeqTest class and updated test code to reflect this change

* Used reject(Predicate) instead of removeAll(Predicate) in shouldRemoveExistingElements() and shouldRemoveNonExistingElements() methods

* Used reject(Predicate) instead of removeAll(Predicate) in shouldNotRemoveAllNonMatchedElementsFromNonNil() method

* Returned back method removeAll(Predicate) in shouldRemoveExistingElements(), shouldNotRemoveAllNonMatchedElementsFromNonNil(), and shouldRemoveNonExistingElements() methods, added annotation @SuppressWarnings(deprecation) (#1807)
danieldietrich referenced this issue in vavr-io/vavr Jan 16, 2019
#2170)

* Eliminated method useIsEqualToInsteadOfIsSameAs() from AbstractSeqTest class and prepared code for elimination this method from related classes: ArrayTest, HashSetTest, ListTest, QueueTest, StreamTest and VectorTest

* Revert "Eliminated method useIsEqualToInsteadOfIsSameAs() from AbstractSeqTest class and prepared code for elimination this method from related classes: ArrayTest, HashSetTest, ListTest, QueueTest, StreamTest and VectorTest"

This reverts commit 0b053df in order to
delete multiple unnecessary changes.

* Eliminated useIsEqualToInsteadOfIsSameAs() from AbstractSeqTest class and updated test code to reflect this change

* Used reject(Predicate) instead of removeAll(Predicate) in shouldRemoveExistingElements() and shouldRemoveNonExistingElements() methods

* Used reject(Predicate) instead of removeAll(Predicate) in shouldNotRemoveAllNonMatchedElementsFromNonNil() method

* Returned back method removeAll(Predicate) in shouldRemoveExistingElements(), shouldNotRemoveAllNonMatchedElementsFromNonNil(), and shouldRemoveNonExistingElements() methods, added annotation @SuppressWarnings(deprecation) (#1807)
@danieldietrich danieldietrich transferred this issue from vavr-io/vavr Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant