13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
+ @file:Suppress(" NAMED_ARGUMENTS_NOT_ALLOWED" ) // KT-21913
16
17
17
18
package kotlinx.coroutines.experimental.selects
18
19
19
20
import kotlinx.coroutines.experimental.*
20
21
import kotlinx.coroutines.experimental.channels.*
21
22
import kotlinx.coroutines.experimental.intrinsics.*
22
- import org.junit.*
23
- import org.junit.Assert.*
24
23
import kotlin.coroutines.experimental.*
24
+ import kotlin.test.*
25
25
26
26
class SelectRendezvousChannelTest : TestBase () {
27
+
27
28
@Test
28
- fun testSelectSendSuccess () = runBlocking< Unit > {
29
+ fun testSelectSendSuccess () = runTest {
29
30
expect(1 )
30
31
val channel = RendezvousChannel <String >()
31
32
launch(coroutineContext) {
@@ -44,7 +45,7 @@ class SelectRendezvousChannelTest : TestBase() {
44
45
}
45
46
46
47
@Test
47
- fun testSelectSendSuccessWithDefault () = runBlocking< Unit > {
48
+ fun testSelectSendSuccessWithDefault () = runTest {
48
49
expect(1 )
49
50
val channel = RendezvousChannel <String >()
50
51
launch(coroutineContext) {
@@ -66,7 +67,7 @@ class SelectRendezvousChannelTest : TestBase() {
66
67
}
67
68
68
69
@Test
69
- fun testSelectSendWaitWithDefault () = runBlocking< Unit > {
70
+ fun testSelectSendWaitWithDefault () = runTest {
70
71
expect(1 )
71
72
val channel = RendezvousChannel <String >()
72
73
select<Unit > {
@@ -92,7 +93,7 @@ class SelectRendezvousChannelTest : TestBase() {
92
93
}
93
94
94
95
@Test
95
- fun testSelectSendWait () = runBlocking< Unit > {
96
+ fun testSelectSendWait () = runTest {
96
97
expect(1 )
97
98
val channel = RendezvousChannel <String >()
98
99
launch(coroutineContext) {
@@ -110,7 +111,7 @@ class SelectRendezvousChannelTest : TestBase() {
110
111
}
111
112
112
113
@Test
113
- fun testSelectReceiveSuccess () = runBlocking< Unit > {
114
+ fun testSelectReceiveSuccess () = runTest {
114
115
expect(1 )
115
116
val channel = RendezvousChannel <String >()
116
117
launch(coroutineContext) {
@@ -130,7 +131,7 @@ class SelectRendezvousChannelTest : TestBase() {
130
131
}
131
132
132
133
@Test
133
- fun testSelectReceiveSuccessWithDefault () = runBlocking< Unit > {
134
+ fun testSelectReceiveSuccessWithDefault () = runTest {
134
135
expect(1 )
135
136
val channel = RendezvousChannel <String >()
136
137
launch(coroutineContext) {
@@ -153,7 +154,7 @@ class SelectRendezvousChannelTest : TestBase() {
153
154
}
154
155
155
156
@Test
156
- fun testSelectReceiveWaitWithDefault () = runBlocking< Unit > {
157
+ fun testSelectReceiveWaitWithDefault () = runTest {
157
158
expect(1 )
158
159
val channel = RendezvousChannel <String >()
159
160
select<Unit > {
@@ -179,7 +180,7 @@ class SelectRendezvousChannelTest : TestBase() {
179
180
}
180
181
181
182
@Test
182
- fun testSelectReceiveWait () = runBlocking< Unit > {
183
+ fun testSelectReceiveWait () = runTest {
183
184
expect(1 )
184
185
val channel = RendezvousChannel <String >()
185
186
launch(coroutineContext) {
@@ -197,8 +198,8 @@ class SelectRendezvousChannelTest : TestBase() {
197
198
finish(6 )
198
199
}
199
200
200
- @Test(expected = ClosedReceiveChannelException :: class )
201
- fun testSelectReceiveClosed () = runBlocking< Unit > {
201
+ @Test
202
+ fun testSelectReceiveClosed () = runTest(expected = { it is ClosedReceiveChannelException }) {
202
203
expect(1 )
203
204
val channel = RendezvousChannel <String >()
204
205
channel.close()
@@ -211,8 +212,8 @@ class SelectRendezvousChannelTest : TestBase() {
211
212
expectUnreached()
212
213
}
213
214
214
- @Test(expected = ClosedReceiveChannelException :: class )
215
- fun testSelectReceiveWaitClosed () = runBlocking< Unit > {
215
+ @Test
216
+ fun testSelectReceiveWaitClosed () = runTest(expected = {it is ClosedReceiveChannelException }) {
216
217
expect(1 )
217
218
val channel = RendezvousChannel <String >()
218
219
launch(coroutineContext) {
@@ -230,9 +231,9 @@ class SelectRendezvousChannelTest : TestBase() {
230
231
}
231
232
232
233
@Test
233
- fun testSelectSendResourceCleanup () = runBlocking< Unit > {
234
+ fun testSelectSendResourceCleanup () = runTest {
234
235
val channel = RendezvousChannel <Int >()
235
- val n = 10_000_000 * stressTestMultiplier
236
+ val n = 1_000
236
237
expect(1 )
237
238
repeat(n) { i ->
238
239
select {
@@ -244,9 +245,9 @@ class SelectRendezvousChannelTest : TestBase() {
244
245
}
245
246
246
247
@Test
247
- fun testSelectReceiveResourceCleanup () = runBlocking< Unit > {
248
+ fun testSelectReceiveResourceCleanup () = runTest {
248
249
val channel = RendezvousChannel <Int >()
249
- val n = 10_000_000 * stressTestMultiplier
250
+ val n = 1_000
250
251
expect(1 )
251
252
repeat(n) { i ->
252
253
select {
@@ -258,7 +259,7 @@ class SelectRendezvousChannelTest : TestBase() {
258
259
}
259
260
260
261
@Test
261
- fun testSelectAtomicFailure () = runBlocking< Unit > {
262
+ fun testSelectAtomicFailure () = runTest {
262
263
val c1 = RendezvousChannel <Int >()
263
264
val c2 = RendezvousChannel <Int >()
264
265
expect(1 )
@@ -289,7 +290,7 @@ class SelectRendezvousChannelTest : TestBase() {
289
290
}
290
291
291
292
@Test
292
- fun testSelectWaitDispatch () = runBlocking< Unit > {
293
+ fun testSelectWaitDispatch () = runTest {
293
294
val c = RendezvousChannel <Int >()
294
295
expect(1 )
295
296
launch(coroutineContext) {
@@ -323,4 +324,4 @@ class SelectRendezvousChannelTest : TestBase() {
323
324
if (! trySelect(null )) return
324
325
block.startCoroutineUndispatched(this )
325
326
}
326
- }
327
+ }
0 commit comments