Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed May 1, 2020
2 parents 2441756 + 5512df0 commit edf9fe8
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 92 deletions.
38 changes: 22 additions & 16 deletions src/test/java/org/cactoos/scalar/AndInThreadsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.hamcrest.Matchers;
import org.hamcrest.collection.IsIterableContainingInAnyOrder;
import org.junit.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.MatcherOf;
import org.llorllale.cactoos.matchers.ScalarHasValue;

Expand All @@ -53,31 +54,34 @@ public final class AndInThreadsTest {

@Test
public void allTrue() throws Exception {
MatcherAssert.assertThat(
new Assertion<>(
"Each object must be True",
new AndInThreads(
new True(),
new True(),
new True()
),
new ScalarHasValue<>(true)
);
).affirm();
}

@Test
public void oneFalse() throws Exception {
MatcherAssert.assertThat(
new Assertion<>(
"One object must be False",
new AndInThreads(
new True(),
new False(),
new True()
),
new ScalarHasValue<>(false)
);
).affirm();
}

@Test
public void allFalse() throws Exception {
MatcherAssert.assertThat(
new Assertion<>(
"Each object must be False",
new AndInThreads(
new IterableOf<Scalar<Boolean>>(
new False(),
Expand All @@ -86,31 +90,33 @@ public void allFalse() throws Exception {
)
),
new ScalarHasValue<>(false)
);
).affirm();
}

@Test
public void emptyIterator() throws Exception {
MatcherAssert.assertThat(
new Assertion<>(
"Iterator must be empty",
new AndInThreads(new IterableOf<Scalar<Boolean>>()),
new ScalarHasValue<>(true)
);
).affirm();
}

@Test
public void iteratesList() {
final List<String> list = new Synced<>(new ListOf<>());
MatcherAssert.assertThat(
"Can't iterate a list with a procedure",
new Assertion<>(
"Must iterate a list with a procedure",
new AndInThreads(
new Mapped<String, Scalar<Boolean>>(
new FuncOf<>(list::add, () -> true),
new IterableOf<>("hello", "world")
)
),
new ScalarHasValue<>(true)
);
MatcherAssert.assertThat(
).affirm();
new Assertion<>(
"Iterable must contain elements in any order",
list,
new IsIterableContainingInAnyOrder<String>(
new ListOf<Matcher<? super String>>(
Expand All @@ -126,16 +132,16 @@ public void iteratesList() {
)
)
)
);
).affirm();
}

@Test
public void iteratesEmptyList() {
final List<String> list = new Synced<>(
new ArrayList<>(2)
);
MatcherAssert.assertThat(
"Can't iterate a list",
new Assertion<>(
"Must iterate an empty list",
new AndInThreads(
new Mapped<String, Scalar<Boolean>>(
new FuncOf<>(list::add, () -> true), new IterableOf<>()
Expand All @@ -151,7 +157,7 @@ public void iteratesEmptyList() {
)
)
)
);
).affirm();
}

@Test
Expand Down
21 changes: 13 additions & 8 deletions src/test/java/org/cactoos/scalar/AndTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.cactoos.iterable.IterableOf;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.ScalarHasValue;

/**
Expand All @@ -40,31 +41,34 @@ public final class AndTest {

@Test
public void allTrue() throws Exception {
MatcherAssert.assertThat(
new Assertion<>(
"Each object must be True",
new And(
new True(),
new True(),
new True()
),
new ScalarHasValue<>(true)
);
).affirm();
}

@Test
public void oneFalse() throws Exception {
MatcherAssert.assertThat(
new Assertion<>(
"One object must be False",
new And(
new True(),
new False(),
new True()
),
new ScalarHasValue<>(false)
);
).affirm();
}

@Test
public void allFalse() throws Exception {
MatcherAssert.assertThat(
new Assertion<>(
"Each object must be False",
new And(
new IterableOf<Scalar<Boolean>>(
new False(),
Expand All @@ -73,15 +77,16 @@ public void allFalse() throws Exception {
)
),
new ScalarHasValue<>(false)
);
).affirm();
}

@Test
public void emptyIterator() throws Exception {
MatcherAssert.assertThat(
new Assertion<>(
"Iterator must be empty",
new And(new IterableOf<Scalar<Boolean>>()),
new ScalarHasValue<>(true)
);
).affirm();
}

@Test
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/cactoos/scalar/AndWithIndexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import java.util.LinkedList;
import java.util.List;
import org.cactoos.func.BiFuncOf;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.MatcherOf;
import org.llorllale.cactoos.matchers.ScalarHasValue;

Expand All @@ -44,8 +44,8 @@ public final class AndWithIndexTest {
@Test
public void iteratesListWithIndex() {
final List<String> list = new LinkedList<>();
MatcherAssert.assertThat(
"Can't iterate a list with a procedure",
new Assertion<>(
"Must iterate a list with a procedure",
new AndWithIndex(
new BiFuncOf<>(
(text, index) -> list.add(index, text),
Expand All @@ -61,6 +61,6 @@ public void iteratesListWithIndex() {
)
)
)
);
).affirm();
}
}
Loading

2 comments on commit edf9fe8

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on edf9fe8 May 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1343-b5541bca disappeared from src/test/java/org/cactoos/scalar/package-info.java, that's why I closed #1362. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on edf9fe8 May 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1362-b5541bca discovered in src/test/java/org/cactoos/scalar/package-info.java and submitted as #1367. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.