Skip to content

Commit

Permalink
polished
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 8, 2025
1 parent 686463c commit 2c575d1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
22 changes: 12 additions & 10 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOmallocTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ final class EOmallocTest {
@Test
void freesMemory() {
final Dummy dummy = new Dummy();
final Phi phi = EOmallocTest.allocated(
new Data.ToPhi(1L),
dummy
);
new Dataized(phi).take();
new Dataized(
EOmallocTest.allocated(
new Data.ToPhi(1L),
dummy
)
).take();
Assertions.assertThrows(
ExAbstract.class,
() -> Heaps.INSTANCE.free((int) dummy.id),
Expand All @@ -67,13 +68,14 @@ void freesMemory() {
@Test
void freesMemoryIfErrorIsOccurred() {
final ErrorDummy dummy = new ErrorDummy();
final Phi phi = EOmallocTest.allocated(
new Data.ToPhi(1L),
dummy
);
Assertions.assertThrows(
ExAbstract.class,
() -> new Dataized(phi).take(),
() -> new Dataized(
EOmallocTest.allocated(
new Data.ToPhi(1L),
dummy
)
).take(),
AtCompositeTest.TO_ADD_MESSAGE
);
Assertions.assertThrows(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private static int randomPort() {
@Execution(ExecutionMode.SAME_THREAD)
final class WindowsSocketTest {
@RepeatedIfExceptionsTest(repeats = 3)
void connectsToLocalServerViaSyscall() throws IOException, InterruptedException {
void connectsToLocalServerViaSyscall() throws IOException {
final RandomServer server = new RandomServer().started();
final int started = this.startup();
try {
Expand Down
16 changes: 5 additions & 11 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOnumberTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

import org.eolang.AtCompositeTest;
import org.eolang.Data;
import org.eolang.Phi;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
Expand All @@ -46,33 +45,28 @@ final class EOnumberTest {

@Test
void hasDifferentHashes() {
final Phi left = new Data.ToPhi(42L);
final Phi right = new Data.ToPhi(42L);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
left.hashCode(),
Matchers.not(Matchers.equalTo(right.hashCode()))
new Data.ToPhi(42L).hashCode(),
Matchers.not(Matchers.equalTo(new Data.ToPhi(42L).hashCode()))
);
}

@Test
void hasHashEvenWithoutData() {
final Phi phi = new EOnumber();
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
phi.hashCode(),
new EOnumber().hashCode(),
Matchers.greaterThan(0)
);
}

@Test
void hasDifferentHash() {
final Phi raw = new EOnumber();
final Phi initialized = new Data.ToPhi(0L);
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
raw.hashCode(),
Matchers.not(initialized.hashCode())
new EOnumber().hashCode(),
Matchers.not(new Data.ToPhi(0L).hashCode())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@ void opensTcpSocket() {
@Test
void closesTcpSocket() {
this.startupsWSA();
final int socket = this.createsSocket();
MatcherAssert.assertThat(
"Winsock library should successfully close a TCP socket, but it didn't",
this.closesSocket(socket),
this.closesSocket(this.createsSocket()),
Matchers.not(Matchers.equalTo(Winsock.SOCKET_ERROR))
);
this.cleanupsWSA();
Expand Down

0 comments on commit 2c575d1

Please sign in to comment.