-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
130 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.softwaremill.jox; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
import static com.softwaremill.jox.Select.*; | ||
import static com.softwaremill.jox.TestUtil.*; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class SelectTest { | ||
@Test | ||
public void testSelectDefault() throws InterruptedException { | ||
// given | ||
Channel<String> ch1 = new Channel<>(1); | ||
Channel<String> ch2 = new Channel<>(1); | ||
|
||
// when | ||
String received = select(ch1.receiveClause(), ch2.receiveClause(), defaultClause("x")); | ||
|
||
// then | ||
assertEquals("x", received); | ||
} | ||
|
||
@Test | ||
public void testDoNotSelectDefault() throws InterruptedException { | ||
// given | ||
Channel<String> ch1 = new Channel<>(1); | ||
Channel<String> ch2 = new Channel<>(1); | ||
ch2.send("a"); | ||
|
||
// when | ||
String received = select(ch1.receiveClause(), ch2.receiveClause(), defaultClause("x")); | ||
|
||
// then | ||
assertEquals("a", received); | ||
} | ||
|
||
@Test | ||
public void testDefaultCanOnlyBeLast() throws InterruptedException { | ||
// given | ||
Channel<String> ch1 = new Channel<>(1); | ||
Channel<String> ch2 = new Channel<>(1); | ||
|
||
// when | ||
try { | ||
select(ch1.receiveClause(), defaultClause("x"), ch2.receiveClause()); | ||
fail("Select should have failed"); | ||
} catch (IllegalArgumentException e) { | ||
// then ok | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3b25e95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.20
.com.softwaremill.jox.SelectBenchmark.two_channels_iterative
305.68983421198413
ns/op249.15165528650795
ns/op1.23
com.softwaremill.jox.RendezvousKotlinBenchmark.sendReceiveUsingDefaultDispatcher
202.55439544793646
ns/op141.0767834504762
ns/op1.44
This comment was automatically generated by workflow using github-action-benchmark.
CC: @adamw