Add contract for 'use'
#KT-35216 Fixed
This commit is contained in:
committed by
Ilya Gorbunov
parent
043eddb432
commit
941de655c4
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin.jdk7.test
|
||||
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class AutoCloseableContractsTest {
|
||||
@Test
|
||||
fun shouldHaveBlockExactlyOnceContract() {
|
||||
class TestAutoCloseable : AutoCloseable {
|
||||
override fun close() {
|
||||
}
|
||||
}
|
||||
|
||||
val i: Int
|
||||
TestAutoCloseable().use {
|
||||
i = 1
|
||||
}
|
||||
assertEquals(1, i)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user