Fix tests: "infix modifier required" and "operator modifier required" errors
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
fun Array<String>.get(index1: Int, index2: Int) = this[index1 + index2]
|
||||
fun Array<String>.set(index1: Int, index2: Int, elem: String) {
|
||||
operator fun Array<String>.get(index1: Int, index2: Int) = this[index1 + index2]
|
||||
operator fun Array<String>.set(index1: Int, index2: Int, elem: String) {
|
||||
this[index1 + index2] = elem
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fun Array<String>.get(index1: Int, index2: Int) = this[index1 + index2]
|
||||
fun Array<String>.set(index1: Int, index2: Int, elem: String) {
|
||||
operator fun Array<String>.get(index1: Int, index2: Int) = this[index1 + index2]
|
||||
operator fun Array<String>.set(index1: Int, index2: Int, elem: String) {
|
||||
this[index1 + index2] = elem
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ fun box(): String {
|
||||
val s = arrayOf("live", "long")
|
||||
val t: Array<String> = s.clone()
|
||||
if (!equals(s, t)) return "Fail string"
|
||||
if (s identityEquals t) return "Fail string identity"
|
||||
if (s.identityEquals(t)) return "Fail string identity"
|
||||
|
||||
val ss = arrayOf(s, s)
|
||||
val tt: Array<Array<String>> = ss.clone()
|
||||
if (!equals(ss, tt)) return "Fail string[]"
|
||||
if (ss identityEquals tt) return "Fail string[] identity"
|
||||
if (ss.identityEquals(tt)) return "Fail string[] identity"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -3,35 +3,35 @@ import java.util.Arrays.equals
|
||||
fun box(): String {
|
||||
val i = intArrayOf(1, 2)
|
||||
if (!equals(i, i.clone())) return "Fail int"
|
||||
if (i.clone() identityEquals i) return "Fail int identity"
|
||||
if (i.clone().identityEquals(i)) return "Fail int identity"
|
||||
|
||||
val j = longArrayOf(1L, 2L)
|
||||
if (!equals(j, j.clone())) return "Fail long"
|
||||
if (j.clone() identityEquals j) return "Fail long identity"
|
||||
if (j.clone().identityEquals(j)) return "Fail long identity"
|
||||
|
||||
val s = shortArrayOf(1.toShort(), 2.toShort())
|
||||
if (!equals(s, s.clone())) return "Fail short"
|
||||
if (s.clone() identityEquals s) return "Fail short identity"
|
||||
if (s.clone().identityEquals(s)) return "Fail short identity"
|
||||
|
||||
val b = byteArrayOf(1.toByte(), 2.toByte())
|
||||
if (!equals(b, b.clone())) return "Fail byte"
|
||||
if (b.clone() identityEquals b) return "Fail byte identity"
|
||||
if (b.clone().identityEquals(b)) return "Fail byte identity"
|
||||
|
||||
val c = charArrayOf('a', 'b')
|
||||
if (!equals(c, c.clone())) return "Fail char"
|
||||
if (c.clone() identityEquals c) return "Fail char identity"
|
||||
if (c.clone().identityEquals(c)) return "Fail char identity"
|
||||
|
||||
val d = doubleArrayOf(1.0, -1.0)
|
||||
if (!equals(d, d.clone())) return "Fail double"
|
||||
if (d.clone() identityEquals d) return "Fail double identity"
|
||||
if (d.clone().identityEquals(d)) return "Fail double identity"
|
||||
|
||||
val f = floatArrayOf(1f, -1f)
|
||||
if (!equals(f, f.clone())) return "Fail float"
|
||||
if (f.clone() identityEquals f) return "Fail float identity"
|
||||
if (f.clone().identityEquals(f)) return "Fail float identity"
|
||||
|
||||
val z = booleanArrayOf(true, false)
|
||||
if (!equals(z, z.clone())) return "Fail boolean"
|
||||
if (z.clone() identityEquals z) return "Fail boolean identity"
|
||||
if (z.clone().identityEquals(z)) return "Fail boolean identity"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
fun box(): String {
|
||||
val array = intArrayOf(11, 12, 13)
|
||||
val p = array get 0
|
||||
val p = array.get(0)
|
||||
if (p != 11) return "fail 1: $p"
|
||||
|
||||
val stringArray = arrayOf("OK", "FAIL")
|
||||
return stringArray get 0
|
||||
return stringArray.get(0)
|
||||
}
|
||||
@@ -17,15 +17,15 @@ class MyIterator<T>(val array : ReadOnlyArray<T>) : javaUtilIterator<T> {
|
||||
}
|
||||
|
||||
interface ReadOnlyArray<out T> : ISized, Iterable<T> {
|
||||
fun get(index : Int) : T
|
||||
operator fun get(index : Int) : T
|
||||
|
||||
override fun iterator() : Iterator<T> = MyIterator<T>(this)
|
||||
}
|
||||
|
||||
interface WriteOnlyArray<in T> : ISized {
|
||||
fun set(index : Int, value : T) : Unit
|
||||
operator fun set(index : Int, value : T) : Unit
|
||||
|
||||
fun set(from: Int, count: Int, value: T) {
|
||||
operator fun set(from: Int, count: Int, value: T) {
|
||||
for(i in from..from+count-1) {
|
||||
set(i, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user