-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathNoParamAssertionsTest.kt
29 lines (24 loc) · 1.02 KB
/
NoParamAssertionsTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
* Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package kotlinx.coroutines
import kotlinx.coroutines.*
import org.junit.Test
import kotlin.test.*
class NoParamAssertionsTest : TestBase() {
// These tests verify that we haven't omitted "-Xno-param-assertions" and "-Xno-receiver-assertions"
@Test
fun testNoReceiverAssertion() {
val function: (ThreadLocal<Int>, Int) -> ThreadContextElement<Int> = ThreadLocal<Int>::asContextElement
@Suppress("UNCHECKED_CAST")
val unsafeCasted = function as ((ThreadLocal<Int>?, Int) -> ThreadContextElement<Int>)
unsafeCasted(null, 42)
}
@Test
fun testNoParamAssertion() {
val function: (ThreadLocal<Any>, Any) -> ThreadContextElement<Any> = ThreadLocal<Any>::asContextElement
@Suppress("UNCHECKED_CAST")
val unsafeCasted = function as ((ThreadLocal<Any?>?, Any?) -> ThreadContextElement<Any>)
unsafeCasted(ThreadLocal.withInitial { Any() }, null)
}
}