got more map code compiling to JS and running as unit tests

This commit is contained in:
James Strachan
2012-07-03 07:43:15 +01:00
parent 8637373aa2
commit 541f3d4e78
12 changed files with 276 additions and 48 deletions
+1 -1
View File
@@ -105,5 +105,5 @@ val <T> List<T>.head : T?
*/
val <T> List<T>.tail : List<T>
get() {
return drop(1)
return this.drop(1)
}
+2 -40
View File
@@ -1,15 +1,9 @@
package kotlin
import java.util.Collection
import java.util.ArrayList
import java.util.LinkedList
import java.util.Collection
import java.util.HashSet
import java.util.LinkedHashSet
import java.util.TreeSet
import java.util.SortedSet
import java.util.Comparator
import java.io.PrintWriter
import java.io.PrintStream
import java.util.LinkedList
/**
Helper to make jet.Iterator usable in for
@@ -59,22 +53,6 @@ Add iterated elements to java.util.HashSet
*/
public inline fun <T> Iterator<T>.toHashSet() : HashSet<T> = toCollection(HashSet<T>())
/**
* Add iterated elements to a [[LinkedHashSet]] to preserve insertion order
*/
public inline fun <T> Iterator<T>.toLinkedSet() : LinkedHashSet<T> = toCollection(LinkedHashSet<T>())
/**
* Add iterated elements to [[SortedSet]] to ensure iteration is in the order of the default comparator
* for the type
*/
public inline fun <T> Iterator<T>.toSortedSet() : SortedSet<T> = toCollection(TreeSet<T>())
/**
* Add iterated elements to [[SortedSet]] with the given *comparator* to ensure iteration is in the order of the given comparator
*/
public inline fun <T> Iterator<T>.toSortedSet(comparator: Comparator<T>) : SortedSet<T> = toCollection(TreeSet<T>(comparator))
/**
* Creates a tuple of type [[#(A,B)]] from this and *that* which can be useful for creating [[Map]] literals
@@ -99,19 +77,3 @@ public inline fun runnable(action: ()-> Unit): Runnable {
}
}
}
/**
* Allows a stack trace to be printed from Kotlin's [[Throwable]]
*/
public inline fun Throwable.printStackTrace(writer: PrintWriter): Unit {
val jlt = this as java.lang.Throwable
jlt.printStackTrace(writer)
}
/**
* Allows a stack trace to be printed from Kotlin's [[Throwable]]
*/
public inline fun Throwable.printStackTrace(stream: PrintStream): Unit {
val jlt = this as java.lang.Throwable
jlt.printStackTrace(stream)
}
@@ -0,0 +1,46 @@
package kotlin
import java.util.Collection
import java.util.ArrayList
import java.util.LinkedList
import java.util.HashSet
import java.util.LinkedHashSet
import java.util.TreeSet
import java.util.SortedSet
import java.util.Comparator
import java.io.PrintWriter
import java.io.PrintStream
/**
* Add iterated elements to a [[LinkedHashSet]] to preserve insertion order
*/
public inline fun <T> Iterator<T>.toLinkedSet() : LinkedHashSet<T> = toCollection(LinkedHashSet<T>())
/**
* Add iterated elements to [[SortedSet]] to ensure iteration is in the order of the default comparator
* for the type
*/
public inline fun <T> Iterator<T>.toSortedSet() : SortedSet<T> = toCollection(TreeSet<T>())
/**
* Add iterated elements to [[SortedSet]] with the given *comparator* to ensure iteration is in the order of the given comparator
*/
public inline fun <T> Iterator<T>.toSortedSet(comparator: Comparator<T>) : SortedSet<T> = toCollection(TreeSet<T>(comparator))
/**
* Allows a stack trace to be printed from Kotlin's [[Throwable]]
*/
public inline fun Throwable.printStackTrace(writer: PrintWriter): Unit {
val jlt = this as java.lang.Throwable
jlt.printStackTrace(writer)
}
/**
* Allows a stack trace to be printed from Kotlin's [[Throwable]]
*/
public inline fun Throwable.printStackTrace(stream: PrintStream): Unit {
val jlt = this as java.lang.Throwable
jlt.printStackTrace(stream)
}