Fix tests: "infix modifier required" and "operator modifier required" errors
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ fun sort(list: MutableList<String>, comparator: (String, String) -> Int) {
|
||||
})
|
||||
}
|
||||
|
||||
fun compare(s1: String, s2: String) = s1 compareTo s2
|
||||
fun compare(s1: String, s2: String) = s1.compareTo(s2)
|
||||
|
||||
fun box(): String {
|
||||
val l = ArrayList(Arrays.asList("d", "b", "c", "e", "a"))
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ class A {
|
||||
}
|
||||
|
||||
object NumberDecrypter {
|
||||
fun getValue(instance: Any?, data: KProperty<*>) = when (data.name) {
|
||||
operator fun getValue(instance: Any?, data: KProperty<*>) = when (data.name) {
|
||||
"four" -> 4
|
||||
"two" -> 2
|
||||
else -> throw AssertionError()
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@ var result: String by Delegate
|
||||
object Delegate {
|
||||
var value = "lol"
|
||||
|
||||
fun getValue(instance: Any?, data: KProperty<*>): String {
|
||||
operator fun getValue(instance: Any?, data: KProperty<*>): String {
|
||||
return value
|
||||
}
|
||||
|
||||
fun setValue(instance: Any?, data: KProperty<*>, newValue: String) {
|
||||
operator fun setValue(instance: Any?, data: KProperty<*>, newValue: String) {
|
||||
value = newValue
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ val <T> Value<T>.additionalText by DVal(Value<T>::text) //works
|
||||
val <T> Value<T>.additionalValue by DVal(Value<T>::value) //not work
|
||||
|
||||
class DVal<T, R, P: KProperty1<T, R>>(val kmember: P) {
|
||||
fun getValue(t: T, p: KProperty<*>): R {
|
||||
operator fun getValue(t: T, p: KProperty<*>): R {
|
||||
return kmember.get(t)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ val String.id: String
|
||||
fun box(): String {
|
||||
val pr = String::id
|
||||
|
||||
if (pr["123"] != "123") return "Fail value: ${pr["123"]}"
|
||||
if (pr.get("123") != "123") return "Fail value: ${pr.get("123")}"
|
||||
|
||||
if (pr.name != "id") return "Fail name: ${pr.name}"
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -10,9 +10,9 @@ var Int.foo: Int
|
||||
|
||||
fun box(): String {
|
||||
val pr = Int::foo
|
||||
if (pr.get(42) != 42) return "Fail 1: ${pr[42]}"
|
||||
if (pr.get(42) != 42) return "Fail 1: ${pr.get(42)}"
|
||||
pr.set(200, 39)
|
||||
if (pr.get(-239) != 0) return "Fail 2: ${pr[-239]}"
|
||||
if (pr.get(-239) != 0) return "Fail 2: ${pr.get(-239)}"
|
||||
if (storage != 239) return "Fail 3: $storage"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ fun box(): String {
|
||||
val o = Box("lorem")
|
||||
val prop = Box::value
|
||||
|
||||
if (prop.get(o) != "lorem") return "Fail 1: ${prop[o]}"
|
||||
if (prop.get(o) != "lorem") return "Fail 1: ${prop.get(o)}"
|
||||
prop.set(o, "ipsum")
|
||||
if (prop.get(o) != "ipsum") return "Fail 2: ${prop[o]}"
|
||||
if (prop.get(o) != "ipsum") return "Fail 2: ${prop.get(o)}"
|
||||
if (o.value != "ipsum") return "Fail 3: ${o.value}"
|
||||
o.value = "dolor"
|
||||
if (prop.get(o) != "dolor") return "Fail 4: ${prop.get(o)}"
|
||||
|
||||
Reference in New Issue
Block a user