Remove StdLibArraysTest and include collections/ArraysTest.kt into StdLibTestToJSTest smoke tests instead.

Move helper methods, so they are available in JS semantics tests.
This commit is contained in:
Ilya Gorbunov
2015-07-28 07:22:52 +03:00
parent 521e0b679d
commit 63110dcdf8
4 changed files with 17 additions and 41 deletions
@@ -1,26 +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 org.jetbrains.kotlin.js.test.semantics;
import junit.framework.Test;
@SuppressWarnings("JUnitTestCaseWithNoTests")
public final class StdLibArraysTest extends JsUnitTestBase {
public static Test suite() throws Exception {
return createTestSuiteForFile("libraries/stdlib/test/collections/ArraysTest.kt");
}
}
@@ -39,6 +39,7 @@ public class StdLibTestToJSTest extends StdLibQUnitTestSupport {
"dom/DomTest.kt",
"collections/SequenceTest.kt",
"collections/IterableTests.kt",
"collections/ArraysTest.kt",
"language/RangeTest.kt",
"language/RangeIterationTest.kt"
);
@@ -658,18 +658,3 @@ class CollectionTest {
assertEquals("[1, a, null, ${Long.MAX_VALUE.toString()}]", listOf(1, "a", null, Long.MAX_VALUE).toString())
}
}
fun <T> Iterable<T>.assertSorted(isInOrder: (T, T) -> Boolean): Unit { this.iterator().assertSorted(isInOrder) }
fun <T> Iterator<T>.assertSorted(isInOrder: (T, T) -> Boolean) {
if (!hasNext()) return
var index = 0
var prev = next()
while (hasNext()) {
index += 1
val next = next()
assertTrue(isInOrder(prev, next), "Not in order at position $index, element[${index-1}]: $prev, element[$index]: $next")
prev = next
}
return
}
@@ -350,3 +350,19 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
}
}
fun <T> Iterable<T>.assertSorted(isInOrder: (T, T) -> Boolean): Unit { this.iterator().assertSorted(isInOrder) }
fun <T> Iterator<T>.assertSorted(isInOrder: (T, T) -> Boolean) {
if (!hasNext()) return
var index = 0
var prev = next()
while (hasNext()) {
index += 1
val next = next()
assertTrue(isInOrder(prev, next), "Not in order at position $index, element[${index-1}]: $prev, element[$index]: $next")
prev = next
}
return
}