• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3  */
4 package kotlinx.coroutines
5 
6 import kotlinx.coroutines.*
7 import org.junit.Test
8 import kotlin.test.*
9 
10 
11 class NoParamAssertionsTest : TestBase() {
12     // These tests verify that we haven't omitted "-Xno-param-assertions" and "-Xno-receiver-assertions"
13 
14     @Test
testNoReceiverAssertionnull15     fun testNoReceiverAssertion() {
16         val function: (ThreadLocal<Int>, Int) -> ThreadContextElement<Int> = ThreadLocal<Int>::asContextElement
17         @Suppress("UNCHECKED_CAST")
18         val unsafeCasted = function as ((ThreadLocal<Int>?, Int) -> ThreadContextElement<Int>)
19         unsafeCasted(null, 42)
20     }
21 
22     @Test
testNoParamAssertionnull23     fun testNoParamAssertion() {
24         val function: (ThreadLocal<Any>, Any) -> ThreadContextElement<Any> = ThreadLocal<Any>::asContextElement
25         @Suppress("UNCHECKED_CAST")
26         val unsafeCasted = function as ((ThreadLocal<Any?>?, Any?) -> ThreadContextElement<Any>)
27         unsafeCasted(ThreadLocal.withInitial { Any() }, null)
28     }
29 }
30