Merge branch 'master' into idea13

This commit is contained in:
Erokhin Stanislav
2013-07-09 19:52:06 +04:00
1228 changed files with 38971 additions and 4361 deletions
-16
View File
@@ -43,22 +43,6 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<configuration>
</configuration>
<executions>
<execution>
<phase>package</phase>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
+1
View File
@@ -5,6 +5,7 @@ import kotlin.test.*
import java.util.*
import org.junit.Test as test
// TODO: Write test generator for testing `Map` implementations.
class MapJsTest {
//TODO: replace `array(...).toList()` to `listOf(...)`
val KEYS = array("zero", "one", "two", "three").toList()
@@ -4,6 +4,17 @@ import kotlin.test.assertEquals
import org.junit.Test as test
import java.lang as j
import java.lang.Integer.MAX_VALUE as MaxI
import java.lang.Integer.MIN_VALUE as MinI
import java.lang.Byte.MAX_VALUE as MaxB
import java.lang.Byte.MIN_VALUE as MinB
import java.lang.Short.MAX_VALUE as MaxS
import java.lang.Short.MIN_VALUE as MinS
import java.lang.Long.MAX_VALUE as MaxL
import java.lang.Long.MIN_VALUE as MinL
import java.lang.Character.MAX_VALUE as MaxC
import java.lang.Character.MIN_VALUE as MinC
// Test data for codegen is generated from this class. If you change it, rerun GenerateTests
public class RangeIterationTest {
private fun <N> doTest(
@@ -280,4 +291,94 @@ public class RangeIterationTest {
doTest(j.Double.NaN downTo j.Double.NaN, j.Double.NaN, j.Double.NaN, -1.0, listOf())
doTest(j.Float.NaN downTo j.Float.NaN, j.Float.NaN, j.Float.NaN, -1.0.toFloat(), listOf())
}
}
test fun maxValueToMaxValue() {
doTest(MaxI..MaxI, MaxI, MaxI, 1, listOf(MaxI))
doTest(MaxB..MaxB, MaxB, MaxB, 1, listOf(MaxB))
doTest(MaxS..MaxS, MaxS, MaxS, 1, listOf(MaxS))
doTest(MaxL..MaxL, MaxL, MaxL, 1.toLong(), listOf(MaxL))
doTest(MaxC..MaxC, MaxC, MaxC, 1, listOf(MaxC))
}
test fun maxValueMinusTwoToMaxValue() {
doTest((MaxI - 2)..MaxI, MaxI - 2, MaxI, 1, listOf(MaxI - 2, MaxI - 1, MaxI))
doTest((MaxB - 2).toByte()..MaxB, (MaxB - 2).toByte(), MaxB, 1, listOf((MaxB - 2).toByte(), (MaxB - 1).toByte(), MaxB))
doTest((MaxS - 2).toShort()..MaxS, (MaxS - 2).toShort(), MaxS, 1, listOf((MaxS - 2).toShort(), (MaxS - 1).toShort(), MaxS))
doTest((MaxL - 2).toLong()..MaxL, (MaxL - 2).toLong(), MaxL, 1.toLong(), listOf((MaxL - 2).toLong(), (MaxL - 1).toLong(), MaxL))
doTest((MaxC - 2).toChar()..MaxC, (MaxC - 2).toChar(), MaxC, 1, listOf((MaxC - 2).toChar(), (MaxC - 1).toChar(), MaxC))
}
test fun maxValueToMinValue() {
doTest(MaxI..MinI, MaxI, MinI, 1, listOf())
doTest(MaxB..MinB, MaxB, MinB, 1, listOf())
doTest(MaxS..MinS, MaxS, MinS, 1, listOf())
doTest(MaxL..MinL, MaxL, MinL, 1.toLong(), listOf())
doTest(MaxC..MinC, MaxC, MinC, 1, listOf())
}
test fun progressionMaxValueToMaxValue() {
doTest(MaxI..MaxI step 1, MaxI, MaxI, 1, listOf(MaxI))
doTest(MaxB..MaxB step 1, MaxB, MaxB, 1, listOf(MaxB))
doTest(MaxS..MaxS step 1, MaxS, MaxS, 1, listOf(MaxS))
doTest(MaxL..MaxL step 1, MaxL, MaxL, 1.toLong(), listOf(MaxL))
doTest(MaxC..MaxC step 1, MaxC, MaxC, 1, listOf(MaxC))
}
test fun progressionMaxValueMinusTwoToMaxValue() {
doTest((MaxI - 2)..MaxI step 2, MaxI - 2, MaxI, 2, listOf(MaxI - 2, MaxI))
doTest((MaxB - 2).toByte()..MaxB step 2, (MaxB - 2).toByte(), MaxB, 2, listOf((MaxB - 2).toByte(), MaxB))
doTest((MaxS - 2).toShort()..MaxS step 2, (MaxS - 2).toShort(), MaxS, 2, listOf((MaxS - 2).toShort(), MaxS))
doTest((MaxL - 2).toLong()..MaxL step 2, (MaxL - 2).toLong(), MaxL, 2.toLong(), listOf((MaxL - 2).toLong(), MaxL))
doTest((MaxC - 2).toChar()..MaxC step 2, (MaxC - 2).toChar(), MaxC, 2, listOf((MaxC - 2).toChar(), MaxC))
}
test fun progressionMaxValueToMinValue() {
doTest(MaxI..MinI step 1, MaxI, MinI, 1, listOf())
doTest(MaxB..MinB step 1, MaxB, MinB, 1, listOf())
doTest(MaxS..MinS step 1, MaxS, MinS, 1, listOf())
doTest(MaxL..MinL step 1, MaxL, MinL, 1.toLong(), listOf())
doTest(MaxC..MinC step 1, MaxC, MinC, 1, listOf())
}
test fun progressionMinValueToMinValue() {
doTest(MinI..MinI step 1, MinI, MinI, 1, listOf(MinI))
doTest(MinB..MinB step 1, MinB, MinB, 1, listOf(MinB))
doTest(MinS..MinS step 1, MinS, MinS, 1, listOf(MinS))
doTest(MinL..MinL step 1, MinL, MinL, 1.toLong(), listOf(MinL))
doTest(MinC..MinC step 1, MinC, MinC, 1, listOf(MinC))
}
test fun inexactToMaxValue() {
doTest((MaxI - 5)..MaxI step 3, MaxI - 5, MaxI, 3, listOf(MaxI - 5, MaxI - 2))
doTest((MaxB - 5).toByte()..MaxB step 3, (MaxB - 5).toByte(), MaxB, 3, listOf((MaxB - 5).toByte(), (MaxB - 2).toByte()))
doTest((MaxS - 5).toShort()..MaxS step 3, (MaxS - 5).toShort(), MaxS, 3, listOf((MaxS - 5).toShort(), (MaxS - 2).toShort()))
doTest((MaxL - 5).toLong()..MaxL step 3, (MaxL - 5).toLong(), MaxL, 3.toLong(), listOf((MaxL - 5).toLong(), (MaxL - 2).toLong()))
doTest((MaxC - 5).toChar()..MaxC step 3, (MaxC - 5).toChar(), MaxC, 3, listOf((MaxC - 5).toChar(), (MaxC - 2).toChar()))
}
test fun progressionDownToMinValue() {
doTest((MinI + 2) downTo MinI step 1, MinI + 2, MinI, -1, listOf(MinI + 2, MinI + 1, MinI))
doTest((MinB + 2).toByte() downTo MinB step 1, (MinB + 2).toByte(), MinB, -1, listOf((MinB + 2).toByte(), (MinB + 1).toByte(), MinB))
doTest((MinS + 2).toShort() downTo MinS step 1, (MinS + 2).toShort(), MinS, -1, listOf((MinS + 2).toShort(), (MinS + 1).toShort(), MinS))
doTest((MinL + 2).toLong() downTo MinL step 1, (MinL + 2).toLong(), MinL, -1.toLong(), listOf((MinL + 2).toLong(), (MinL + 1).toLong(), MinL))
doTest((MinC + 2).toChar() downTo MinC step 1, (MinC + 2).toChar(), MinC, -1, listOf((MinC + 2).toChar(), (MinC + 1).toChar(), MinC))
}
test fun inexactDownToMinValue() {
doTest((MinI + 5) downTo MinI step 3, MinI + 5, MinI, -3, listOf(MinI + 5, MinI + 2))
doTest((MinB + 5).toByte() downTo MinB step 3, (MinB + 5).toByte(), MinB, -3, listOf((MinB + 5).toByte(), (MinB + 2).toByte()))
doTest((MinS + 5).toShort() downTo MinS step 3, (MinS + 5).toShort(), MinS, -3, listOf((MinS + 5).toShort(), (MinS + 2).toShort()))
doTest((MinL + 5).toLong() downTo MinL step 3, (MinL + 5).toLong(), MinL, -3.toLong(), listOf((MinL + 5).toLong(), (MinL + 2).toLong()))
doTest((MinC + 5).toChar() downTo MinC step 3, (MinC + 5).toChar(), MinC, -3, listOf((MinC + 5).toChar(), (MinC + 2).toChar()))
}
}
@@ -19,13 +19,21 @@ class DelegationTest(): DelegationTestBase() {
doTest(TestNotNullVar("a", "b"))
}
fun testObservablePropertyInChangeSupport() {
doTest(TestObservablePropertyInChangeSupport())
}
fun testObservableProperty() {
doTest(TestObservableProperty())
}
fun testVetoableProperty() {
doTest(TestVetoableProperty())
}
}
public class TestNotNullVar<T>(val a1: String, val b1: T): WithBox {
var a: String by Delegates.notNull<String>()
var a: String by Delegates.notNull()
var b by Delegates.notNull<T>()
override fun box(): String {
@@ -37,7 +45,7 @@ public class TestNotNullVar<T>(val a1: String, val b1: T): WithBox {
}
}
class TestObservableProperty: WithBox, ChangeSupport() {
class TestObservablePropertyInChangeSupport: WithBox, ChangeSupport() {
var b by property(init = 2)
var c by property(3)
@@ -60,3 +68,34 @@ class TestObservableProperty: WithBox, ChangeSupport() {
return "OK"
}
}
class TestObservableProperty: WithBox {
var result = false
var b by Delegates.observable(1, {(pd, o, n) -> result = true})
override fun box(): String {
b = 4
if (b != 4) return "fail: b != 4"
if (!result) return "fail: result should be true"
return "OK"
}
}
class TestVetoableProperty: WithBox {
var result = false
var b by Delegates.vetoable(A(true), {(pd, o, n) -> result = n.p == true; result})
override fun box(): String {
val firstValue = A(true)
b = firstValue
if (b != firstValue) return "fail1: b should be firstValue = A(true)"
if (!result) return "fail2: result should be true"
b = A(false)
if (b != firstValue) return "fail3: b should be firstValue = A(true)"
if (result) return "fail4: result should be false"
return "OK"
}
class A(val p: Boolean)
}
@@ -66,8 +66,8 @@ class TestMapValWithDifferentTypes(): WithBox {
class TestMapVarWithDifferentTypes(): WithBox {
val map: HashMap<String, Any?> = hashMapOf("a" to "a", "b" to 1, "c" to A(1), "d" to "d")
var a by Delegates.mapVar<String>(map)
var b by Delegates.mapVar<Int>(map)
var a: String by Delegates.mapVar(map)
var b: Int by Delegates.mapVar(map)
var c by Delegates.mapVar<Any>(map)
var d by Delegates.mapVar<String?>(map)
@@ -100,7 +100,7 @@ class TestNullableKey: WithBox {
class TestMapPropertyString(): WithBox {
val map = hashMapOf("a" to "a", "b" to "b", "c" to "c":Any?)
val a by Delegates.mapVal<String>(map)
val a: String by Delegates.mapVal(map)
var b by Delegates.mapVar<String>(map)
val c by Delegates.mapVal<String>(map)
@@ -115,9 +115,9 @@ class TestMapPropertyString(): WithBox {
class TestMapValWithDefault(): WithBox {
val map = hashMapOf<String, String>()
val a by Delegates.mapVal<String>(map, default = { ref, desc -> "aDefault" })
val b by FixedMapVal<TestMapValWithDefault, String, String>(map, default = { ref, desc -> "bDefault" }, key = {"b"})
val c by FixedMapVal<TestMapValWithDefault, String, String>(map, default = { ref, desc -> "cDefault" }, key = { desc -> desc.name })
val a: String by Delegates.mapVal(map, default = { ref, desc -> "aDefault" })
val b: String by FixedMapVal(map, default = { (ref: TestMapValWithDefault, desc: String) -> "bDefault" }, key = {"b"})
val c: String by FixedMapVal(map, default = { (ref: TestMapValWithDefault, desc: String) -> "cDefault" }, key = { desc -> desc.name })
override fun box(): String {
if (a != "aDefault") return "fail at 'a'"
@@ -130,8 +130,8 @@ class TestMapValWithDefault(): WithBox {
class TestMapVarWithDefault(): WithBox {
val map = hashMapOf<String, Any?>()
var a: String by Delegates.mapVar(map, default = {ref, desc -> "aDefault" })
var b: String by FixedMapVar<Any?, String, String>(map, default = {ref, desc -> "bDefault" }, key = {"b"})
var c: String by FixedMapVar<Any?, String, String>(map, default = {ref, desc -> "cDefault" }, key = { desc -> desc.name })
var b: String by FixedMapVar(map, default = {(ref: Any?, desc: String) -> "bDefault" }, key = {"b"})
var c: String by FixedMapVar(map, default = {(ref: Any?, desc: String) -> "cDefault" }, key = { desc -> desc.name })
override fun box(): String {
if (a != "aDefault") return "fail at 'a'"