re-enabled compiling to JS test cases now we've fixed the compilation of the latest comparator based standard library code
This commit is contained in:
@@ -10,10 +10,6 @@ public trait Comparator<T> {
|
||||
fun compare(obj1 : T, obj2 : T) : Int;
|
||||
}
|
||||
|
||||
library("comparator")
|
||||
public fun comparator<T>(f : (T, T) -> Int) : Comparator<T> = js.noImpl
|
||||
|
||||
|
||||
library
|
||||
public trait Iterator<T> {
|
||||
open fun next() : T = js.noImpl
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package kotlin
|
||||
|
||||
import java.util.*
|
||||
|
||||
library("comparator")
|
||||
public fun comparator<T>(f : (T, T) -> Int) : Comparator<T> = js.noImpl
|
||||
@@ -36,15 +36,10 @@ import java.util.Set;
|
||||
*/
|
||||
public class StdLibTestToJSTest extends StdLibTestSupport {
|
||||
public void testGenerateTestCase() throws Exception {
|
||||
|
||||
/*
|
||||
TODO temporary disabled test
|
||||
|
||||
generateJavaScriptFiles(EcmaVersion.all(),
|
||||
"libraries/stdlib/test",
|
||||
"ListTest.kt",
|
||||
"StringTest.kt",
|
||||
"js/SimpleTest.kt");
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,14 +36,10 @@ import java.util.Set;
|
||||
public class StdLibToJSTest extends StdLibTestSupport {
|
||||
|
||||
public void testCompileJavaScriptFiles() throws Exception {
|
||||
|
||||
/*
|
||||
TODO temporary disabled test
|
||||
generateJavaScriptFiles(EcmaVersion.all(),
|
||||
"libraries/stdlib/src",
|
||||
"kotlin/Preconditions.kt",
|
||||
"kotlin/dom/Dom.kt",
|
||||
"kotlin/support/AbstractIterator.kt");
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public abstract class Config {
|
||||
"/core/javautil.kt",
|
||||
"/core/javalang.kt",
|
||||
"/core/javaio.kt",
|
||||
"/core/kotlin.kt",
|
||||
"/core/date.kt",
|
||||
"/core/core.kt",
|
||||
"/core/math.kt",
|
||||
@@ -101,6 +102,7 @@ public abstract class Config {
|
||||
"/kotlin/JLangIterablesLazy.kt",
|
||||
"/kotlin/JLangIterablesSpecial.kt",
|
||||
"/kotlin/support/AbstractIterator.kt",
|
||||
//"/kotlin/Ordering.kt",
|
||||
"/kotlin/Strings.kt",
|
||||
"/kotlin/test/Test.kt"
|
||||
);
|
||||
|
||||
+3
-8
@@ -52,15 +52,13 @@
|
||||
<module>tools/runtime</module>
|
||||
<module>tools/kotlin-maven-plugin</module>
|
||||
<module>tools/kotlin-js-library</module>
|
||||
<!--
|
||||
TODO temporary disabled until the Ordering.kt#comparator() works in JS
|
||||
|
||||
<module>tools/kotlin-js-tests</module>
|
||||
-->
|
||||
|
||||
<!--
|
||||
TODO temporary disabled until the java.util.Collections.emptyList() works in JS
|
||||
TODO temporary disabled until KT-2314 fixed
|
||||
|
||||
<module>tools/kotlin-js-tests-junit</module>
|
||||
|
||||
-->
|
||||
<module>tools/kdoc</module>
|
||||
<module>tools/kdoc-maven-plugin</module>
|
||||
@@ -75,11 +73,8 @@
|
||||
|
||||
<module>examples/kotlin-java-example</module>
|
||||
|
||||
<!--
|
||||
TODO disabled while I fix a JS issue
|
||||
<module>examples/js-example</module>
|
||||
<module>examples/browser-example</module>
|
||||
-->
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Collection
|
||||
import java.util.List
|
||||
import java.util.AbstractList
|
||||
import java.util.Iterator
|
||||
import java.util.Comparator
|
||||
|
||||
/**
|
||||
* Count the number of elements in collection.
|
||||
@@ -71,19 +72,6 @@ public fun <T> java.lang.Iterable<T>.last() : T {
|
||||
return last;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies all elements into a [[List]] and sorts it by value of compare_function(element)
|
||||
*
|
||||
* E.g. arrayList("two" to 2, "one" to 1).sortBy({it._2}) returns list sorted by second element of tuple
|
||||
*
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt sortBy
|
||||
*/
|
||||
public inline fun <in T, R: Comparable<in R>> java.lang.Iterable<T>.sortBy(f: (T) -> R): java.util.List<T> {
|
||||
val sortedList = this.toList()
|
||||
java.util.Collections.sort(sortedList, comparator {(x, y) -> f(x).compareTo(f(y))})
|
||||
return sortedList
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if collection contains given item.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package kotlin
|
||||
|
||||
import java.util.AbstractList
|
||||
import java.util.Collection
|
||||
import java.util.Comparator
|
||||
import java.util.Iterator
|
||||
import java.util.List
|
||||
|
||||
// TODO this function is here as it breaks the JS compiler; lets move back to JLangIterablesSpecial when it works again :)
|
||||
|
||||
/**
|
||||
* Copies all elements into a [[List]] and sorts it by value of compare_function(element)
|
||||
*
|
||||
* E.g. arrayList("two" to 2, "one" to 1).sortBy({it._2}) returns list sorted by second element of tuple
|
||||
*
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt sortBy
|
||||
*/
|
||||
public inline fun <in T, R: Comparable<in R>> java.lang.Iterable<T>.sortBy(f: (T) -> R): java.util.List<T> {
|
||||
val sortedList = this.toList()
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) ->
|
||||
val xr = f(x)
|
||||
val yr = f(y)
|
||||
xr.compareTo(yr)
|
||||
}
|
||||
java.util.Collections.sort(sortedList, sortBy)
|
||||
return sortedList
|
||||
}
|
||||
Reference in New Issue
Block a user