Skip to content

Commit

Permalink
#3132: moved from AtCompositeTest.TO_ADD_MESSAGE to AtCompositeTest.F…
Browse files Browse the repository at this point in the history
…AILED_ASSERT_MESSAGE_SUPPLIER in tests
  • Loading branch information
ZacParize committed May 14, 2024
1 parent 0c0ed41 commit 73bdb9c
Show file tree
Hide file tree
Showing 43 changed files with 207 additions and 202 deletions.
12 changes: 6 additions & 6 deletions eo-runtime/src/test/java/EOorg/EOeolang/CagesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void initializesObjectForTheFirstTime() {
final int locator = Cages.INSTANCE.init(phi);
Assertions.assertDoesNotThrow(
() -> Cages.INSTANCE.get(locator),
AtCompositeTest.TO_ADD_MESSAGE
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get()
);
}

Expand All @@ -58,7 +58,7 @@ void rencagesTheSameObject() {
Cages.INSTANCE.init(phi);
Assertions.assertDoesNotThrow(
() -> Cages.INSTANCE.init(phi),
AtCompositeTest.TO_ADD_MESSAGE
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get()
);
}

Expand All @@ -69,7 +69,7 @@ void encagesObjectWithLocator() {
final int locator = Cages.INSTANCE.init(first);
Cages.INSTANCE.encage(locator, second);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
Cages.INSTANCE.get(locator).hashCode(),
Matchers.equalTo(second.hashCode())
);
Expand All @@ -81,7 +81,7 @@ void failsToEncageObjectIfIsWasInitialized() {
Assertions.assertThrows(
ExFailure.class,
() -> Cages.INSTANCE.encage(phi.hashCode(), phi),
AtCompositeTest.TO_ADD_MESSAGE
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get()
);
}

Expand All @@ -91,7 +91,7 @@ void failsToEncageObjectOfDifferentForma() {
Assertions.assertThrows(
ExFailure.class,
() -> Cages.INSTANCE.encage(locator, new Data.ToPhi(5L)),
AtCompositeTest.TO_ADD_MESSAGE
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get()
);
}

Expand All @@ -100,7 +100,7 @@ void failsToGetObjectIfWasNotInitialized() {
Assertions.assertThrows(
ExFailure.class,
() -> Cages.INSTANCE.get(new PhFake().hashCode()),
AtCompositeTest.TO_ADD_MESSAGE
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get()
);
}
}
2 changes: 1 addition & 1 deletion eo-runtime/src/test/java/EOorg/EOeolang/EOas_phiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class EOas_phiTest {
@Test
void printsAndReturns() {
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(
new PhWith(
new EOas_phi(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void concatenatesBytes() {
"as-string"
);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(phi).take(String.class),
Matchers.equalTo("привет mr. ㄤㄠ!")
);
Expand Down
22 changes: 11 additions & 11 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ final class EOcageTest {
void encagesViaApplication() {
final Phi cage = EOcageTest.encaged(new Data.ToPhi(1L));
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(cage).take(Long.class),
Matchers.equalTo(1L)
);
Expand All @@ -75,7 +75,7 @@ void encagesAndFrees() {
final Phi cage = EOcageTest.encaged(new Data.ToPhi(1L));
EOcageTest.encageTo(cage, new Data.ToPhi(2L));
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(cage).take(Long.class),
Matchers.equalTo(2L)
);
Expand All @@ -90,7 +90,7 @@ void overwritesCagedObject() {
)
);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(new PhMethod(cage, "x")).take(Long.class),
Matchers.equalTo(1L)
);
Expand All @@ -102,7 +102,7 @@ void overwritesCagedObject() {
)
);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(new PhMethod(cage, "x")).take(Long.class),
Matchers.equalTo(2L)
);
Expand All @@ -114,7 +114,7 @@ void encagesObjectOnCopy() {
final Phi second = first.copy();
EOcageTest.encageTo(second, new Data.ToPhi(2L));
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(first).take(Long.class),
Matchers.equalTo(2L)
);
Expand All @@ -124,13 +124,13 @@ void encagesObjectOnCopy() {
void writesAndRewritesPrimitive() {
final Phi cage = EOcageTest.encaged(new Data.ToPhi(1L));
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(cage).take(Long.class),
Matchers.equalTo(1L)
);
EOcageTest.encageTo(cage, new Data.ToPhi(5L));
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(cage).take(Long.class),
Matchers.equalTo(5L)
);
Expand All @@ -142,7 +142,7 @@ void doesNotWritePrimitivesFormedDifferently() {
Assertions.assertThrows(
EOerror.ExError.class,
() -> EOcageTest.encageTo(cage, new Data.ToPhi("Hello world")),
AtCompositeTest.TO_ADD_MESSAGE
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get()
);
}

Expand All @@ -158,7 +158,7 @@ void doesNotWriteBoundedMethod() {
Assertions.assertThrows(
EOerror.ExError.class,
() -> EOcageTest.encageTo(cage, ten),
AtCompositeTest.TO_ADD_MESSAGE
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get()
);
}

Expand All @@ -170,7 +170,7 @@ void writesBoundedCopyOfTheSameBase() {
EOcageTest.encaged(dummy),
new PhWith(new PhCopy(dummy), "x", new Data.ToPhi("Hello world"))
),
AtCompositeTest.TO_ADD_MESSAGE
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get()
);
}

Expand Down Expand Up @@ -230,7 +230,7 @@ void doesNotThrowIfDataizesConcurrently() {
);
final int threads = 500;
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new SumOf(
new Threads<>(
threads,
Expand Down
4 changes: 2 additions & 2 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOerrorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void makesToxicObject() {
new Data.ToPhi("intentional error")
)
).take(),
AtCompositeTest.TO_ADD_MESSAGE
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get()
);
}

Expand All @@ -79,7 +79,7 @@ void getsReadableError(final Object cnst) {
}
assert error != null;
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
error.toString(),
Matchers.containsString(
new VerboseBytesAsStringTest.ArgumentsUtils().toString(cnst)
Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/java/EOorg/EOeolang/EOintEOeqTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void comparesWithAnotherNumber() {
0, right
);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(eql).take(Boolean.class),
Matchers.equalTo(false)
);
Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/test/java/EOorg/EOeolang/EOintEOltTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void comparesWithAnotherNumber() {
final Phi less = left.take("lt");
less.put(0, right);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(less).take(Boolean.class),
Matchers.equalTo(false)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void subtractsNumber() {
0, right
);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(sub).take(Long.class),
Matchers.equalTo(29L)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void negatesNumber() {
final Phi left = new Data.ToPhi(42L);
final Phi neg = new PhMethod(left, "neg");
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(neg).take(Long.class),
Matchers.equalTo(-42L)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void addsNumbers() {
final Phi add = left.take("plus");
add.put(0, right);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(add).take(Long.class),
Matchers.equalTo(55L)
);
Expand Down
6 changes: 3 additions & 3 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOintTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void hasDifferentHashes() {
final Phi left = new Data.ToPhi(42L);
final Phi right = new Data.ToPhi(42L);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
left.hashCode(),
Matchers.not(Matchers.equalTo(right.hashCode()))
);
Expand All @@ -58,7 +58,7 @@ void hasDifferentHashes() {
void hasHashEvenWithoutData() {
final Phi phi = new EOint();
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
phi.hashCode(),
Matchers.greaterThan(0)
);
Expand All @@ -69,7 +69,7 @@ void hasDifferentHash() {
final Phi raw = new EOint();
final Phi initialized = new Data.ToPhi(0L);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
raw.hashCode(),
Matchers.not(initialized.hashCode())
);
Expand Down
26 changes: 13 additions & 13 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOio/EOstdinTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class EOstdinTest {
@AfterAll
static void restoreSystemInput() {
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
System.in,
Matchers.equalTo(EOstdinTest.DEFAULT_STDIN)
);
Expand Down Expand Up @@ -91,7 +91,7 @@ void dataizesNextLineOneLine(final StdIn stdin) {
final Phi phi = new PhMethod(new PhCopy(new EOstdin()), "next-line");
final String actual = new Dataized(phi).take(String.class);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
actual,
Matchers.equalTo(expected)
);
Expand All @@ -104,7 +104,7 @@ void dataizesStdinOneLine(final StdIn stdin) {
final Phi phi = new PhCopy(new EOstdin());
final String actual = new Dataized(phi).take(String.class);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
actual,
Matchers.equalTo(expected)
);
Expand All @@ -117,7 +117,7 @@ void dataizesNextLineMultiLine(final StdIn stdin) {
final Phi phi = new PhMethod(new PhCopy(new EOstdin()), "next-line");
final String actual = new Dataized(phi).take(String.class);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
actual,
Matchers.equalTo(expected)
);
Expand All @@ -132,7 +132,7 @@ void dataizesNextLineEmpty(final StdIn stdin) {
() -> new Dataized(phi).take(String.class)
);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(error.enclosure()).take(String.class),
Matchers.containsString(
"There is no line in the standard input stream to consume"
Expand All @@ -144,7 +144,7 @@ void dataizesNextLineEmpty(final StdIn stdin) {
@Test
void dataizesEmptyStdin(final StdIn stdin) {
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
new Dataized(new EOstdin()).take(String.class),
Matchers.equalTo(System.lineSeparator())
);
Expand All @@ -159,7 +159,7 @@ void dataizesStdinMultiLine(final StdIn stdin) {
final Phi phi = new PhCopy(new EOstdin());
final String actual = new Dataized(phi).take(String.class);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
actual,
Matchers.equalTo(first + second + third)
);
Expand All @@ -174,21 +174,21 @@ void dataizesStdinFewOneLine(final StdIn stdin) {
Phi phi = new PhMethod(new PhCopy(new EOstdin()), "next-line");
String actual = new Dataized(phi).take(String.class);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
actual,
Matchers.equalTo(first)
);
phi = new PhMethod(new PhCopy(new EOstdin()), "next-line");
actual = new Dataized(phi).take(String.class);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
actual,
Matchers.equalTo(second)
);
phi = new PhMethod(new PhCopy(new EOstdin()), "next-line");
actual = new Dataized(phi).take(String.class);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
actual,
Matchers.equalTo(third)
);
Expand All @@ -202,21 +202,21 @@ void dataizesStdinEmptyLineBetweenNonEmpty(final StdIn stdin) {
Phi phi = new PhMethod(new PhCopy(new EOstdin()), "next-line");
String actual = new Dataized(phi).take(String.class);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
actual,
Matchers.equalTo(first)
);
phi = new PhMethod(new PhCopy(new EOstdin()), "next-line");
actual = new Dataized(phi).take(String.class);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
actual,
Matchers.equalTo("")
);
phi = new PhMethod(new PhCopy(new EOstdin()), "next-line");
actual = new Dataized(phi).take(String.class);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
AtCompositeTest.FAILED_ASSERT_MESSAGE_SUPPLIER.get(),
actual,
Matchers.equalTo(third)
);
Expand Down
Loading

0 comments on commit 73bdb9c

Please sign in to comment.