Merge ReversedViews tests in one file as they can all run now in JS.
Make SynchronizedLazyValTest jvm-only.
This commit is contained in:
@@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package test.collections
|
|
||||||
|
|
||||||
import kotlin.test.assertEquals
|
|
||||||
import org.junit.Test as test
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We need this test to run only on JVM because we have no mutability support by sub-list implementation for JavaScript
|
|
||||||
*/
|
|
||||||
class ReversedViewsJVMTest {
|
|
||||||
|
|
||||||
@test fun testMutableSubList() {
|
|
||||||
val original = arrayListOf(1, 2, 3, 4)
|
|
||||||
val reversedSubList = original.asReversed().subList(1, 3)
|
|
||||||
|
|
||||||
assertEquals(listOf(3, 2), reversedSubList)
|
|
||||||
reversedSubList.clear()
|
|
||||||
assertEquals(emptyList<Int>(), reversedSubList)
|
|
||||||
assertEquals(listOf(1, 4), original)
|
|
||||||
|
|
||||||
reversedSubList.add(100)
|
|
||||||
assertEquals(listOf(100), reversedSubList)
|
|
||||||
assertEquals(listOf(1, 100, 4), original)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -64,6 +64,20 @@ class ReversedViewsTest {
|
|||||||
assertEquals(listOf(9, 8, 7), reversed.subList(1, 4))
|
assertEquals(listOf(9, 8, 7), reversed.subList(1, 4))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test fun testMutableSubList() {
|
||||||
|
val original = arrayListOf(1, 2, 3, 4)
|
||||||
|
val reversedSubList = original.asReversed().subList(1, 3)
|
||||||
|
|
||||||
|
assertEquals(listOf(3, 2), reversedSubList)
|
||||||
|
reversedSubList.clear()
|
||||||
|
assertEquals(emptyList<Int>(), reversedSubList)
|
||||||
|
assertEquals(listOf(1, 4), original)
|
||||||
|
|
||||||
|
reversedSubList.add(100)
|
||||||
|
assertEquals(listOf(100), reversedSubList)
|
||||||
|
assertEquals(listOf(1, 100, 4), original)
|
||||||
|
}
|
||||||
|
|
||||||
@test fun testMutableSimple() {
|
@test fun testMutableSimple() {
|
||||||
assertEquals(listOf(3, 2, 1), mutableListOf(1, 2, 3).asReversed())
|
assertEquals(listOf(3, 2, 1), mutableListOf(1, 2, 3).asReversed())
|
||||||
assertEquals(listOf(3, 2, 1), mutableListOf(1, 2, 3).asReversed().toList())
|
assertEquals(listOf(3, 2, 1), mutableListOf(1, 2, 3).asReversed().toList())
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class LazyValTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmVersion
|
||||||
class SynchronizedLazyValTest {
|
class SynchronizedLazyValTest {
|
||||||
@Volatile var result = 0
|
@Volatile var result = 0
|
||||||
val a by lazy(this) {
|
val a by lazy(this) {
|
||||||
@@ -24,7 +25,7 @@ class SynchronizedLazyValTest {
|
|||||||
|
|
||||||
@test fun doTest() {
|
@test fun doTest() {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
// thread { a } // not available in js // TODO: Make this test JVM-only
|
kotlin.concurrent.thread { a } // not available in js
|
||||||
result = 1
|
result = 1
|
||||||
a
|
a
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user