Adjust various testData to remove/charAt transformation
This commit is contained in:
+2
-2
@@ -14,7 +14,7 @@ class MyList<T>(val v: T): List<T> {
|
|||||||
override fun equals(other: Any?): Boolean = false
|
override fun equals(other: Any?): Boolean = false
|
||||||
|
|
||||||
public fun add(e: T): Boolean = true
|
public fun add(e: T): Boolean = true
|
||||||
public fun remove(o: Any?): Boolean = true
|
public fun remove(o: T): Boolean = true
|
||||||
public fun addAll(c: Collection<T>): Boolean = true
|
public fun addAll(c: Collection<T>): Boolean = true
|
||||||
public fun addAll(index: Int, c: Collection<T>): Boolean = true
|
public fun addAll(index: Int, c: Collection<T>): Boolean = true
|
||||||
public fun removeAll(c: Collection<Any?>): Boolean = true
|
public fun removeAll(c: Collection<Any?>): Boolean = true
|
||||||
@@ -22,7 +22,7 @@ class MyList<T>(val v: T): List<T> {
|
|||||||
public fun clear() {}
|
public fun clear() {}
|
||||||
public fun set(index: Int, element: T): T = element
|
public fun set(index: Int, element: T): T = element
|
||||||
public fun add(index: Int, element: T) {}
|
public fun add(index: Int, element: T) {}
|
||||||
public fun remove(index: Int): T = v
|
public fun removeAt(index: Int): T = v
|
||||||
}
|
}
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
open class Super<T>(val v: T) {
|
open class Super<T>(val v: T) {
|
||||||
public fun add(e: T): Boolean = true
|
public fun add(e: T): Boolean = true
|
||||||
public fun remove(o: Any?): Boolean = true
|
public fun remove(o: T): Boolean = true
|
||||||
public fun addAll(c: Collection<T>): Boolean = true
|
public fun addAll(c: Collection<T>): Boolean = true
|
||||||
public fun addAll(index: Int, c: Collection<T>): Boolean = true
|
public fun addAll(index: Int, c: Collection<T>): Boolean = true
|
||||||
public fun removeAll(c: Collection<Any?>): Boolean = true
|
public fun removeAll(c: Collection<Any?>): Boolean = true
|
||||||
@@ -8,7 +8,7 @@ open class Super<T>(val v: T) {
|
|||||||
public fun clear() {}
|
public fun clear() {}
|
||||||
public fun set(index: Int, element: T): T = element
|
public fun set(index: Int, element: T): T = element
|
||||||
public fun add(index: Int, element: T) {}
|
public fun add(index: Int, element: T) {}
|
||||||
public fun remove(index: Int): T = v
|
public fun removeAt(index: Int): T = v
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyList<T>(v: T): Super<T>(v), List<T> {
|
class MyList<T>(v: T): Super<T>(v), List<T> {
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ fun box(): String {
|
|||||||
a.add("")
|
a.add("")
|
||||||
a.set(0, "")
|
a.set(0, "")
|
||||||
a.add(0, "")
|
a.add(0, "")
|
||||||
a.remove(0)
|
a.removeAt(0)
|
||||||
a.remove("")
|
a.remove("")
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
open class SetStringImpl {
|
open class SetStringImpl {
|
||||||
fun add(s: String): Boolean = false
|
fun add(s: String): Boolean = false
|
||||||
fun remove(o: Any?): Boolean = false
|
fun remove(o: String): Boolean = false
|
||||||
fun clear(): Unit {}
|
fun clear(): Unit {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class A1 : MutableCollection<String> {
|
|||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun remove(o: Any?): Boolean {
|
override fun remove(o: String): Boolean {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
fun StringBuilder.first() = this.charAt(0)
|
fun StringBuilder.first() = this.get(0)
|
||||||
|
|
||||||
fun foo() = StringBuilder("foo").first()
|
fun foo() = StringBuilder("foo").first()
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
fun StringBuilder.takeFirst(): Char {
|
fun StringBuilder.takeFirst(): Char {
|
||||||
if (this.length() == 0) return 0.toChar()
|
if (this.length() == 0) return 0.toChar()
|
||||||
val c = this.charAt(0)
|
val c = this.get(0)
|
||||||
this.deleteCharAt(0)
|
this.deleteCharAt(0)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fun box(): String {
|
fun box(): String {
|
||||||
val o = "OK" charAt 0
|
val o = "OK" get 0
|
||||||
val array = CharArray(2)
|
val array = CharArray(2)
|
||||||
array[1] = 'K'
|
array[1] = 'K'
|
||||||
val k = array get 1
|
val k = array get 1
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
// KT-5956 java.lang.AbstractMethodError: test.Thing.subSequence(II)Ljava/lang/CharSequence
|
// KT-5956 java.lang.AbstractMethodError: test.Thing.subSequence(II)Ljava/lang/CharSequence
|
||||||
|
|
||||||
class Thing(val delegate: CharSequence) : CharSequence {
|
class Thing(val delegate: CharSequence) : CharSequence {
|
||||||
override fun charAt(index: Int): Char {
|
override fun get(index: Int): Char {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
override fun length(): Int = 0
|
override fun length(): Int = 0
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@ open class KList<E> : MutableList<E> {
|
|||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun remove(o: Any?): Boolean {
|
override fun remove(o: E): Boolean {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ open class KList<E> : MutableList<E> {
|
|||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun remove(index: Int): E {
|
override fun removeAt(index: Int): E {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ open class KList : MutableList<String> {
|
|||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun remove(o: Any?): Boolean {
|
override fun remove(o: String): Boolean {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ open class KList : MutableList<String> {
|
|||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun remove(index: Int): String {
|
override fun removeAt(index: Int): String {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ fun <T> testMutableCollection(c: MutableCollection<T>, t: T) {
|
|||||||
|
|
||||||
val <!UNUSED_VARIABLE!>mutableIterator<!>: MutableIterator<T> = c.iterator()
|
val <!UNUSED_VARIABLE!>mutableIterator<!>: MutableIterator<T> = c.iterator()
|
||||||
c.add(t)
|
c.add(t)
|
||||||
c.remove(1)
|
c.remove(<!UNCHECKED_CAST!>1 as T<!>)
|
||||||
c.addAll(c)
|
c.addAll(c)
|
||||||
c.removeAll(c)
|
c.removeAll(c)
|
||||||
c.retainAll(c)
|
c.retainAll(c)
|
||||||
@@ -52,7 +52,7 @@ fun <T> testList(l: List<T>, <!UNUSED_PARAMETER!>t<!>: T) {
|
|||||||
fun <T> testMutableList(l: MutableList<T>, t: T) {
|
fun <T> testMutableList(l: MutableList<T>, t: T) {
|
||||||
val <!UNUSED_VARIABLE!>value<!>: T = l.set(1, t)
|
val <!UNUSED_VARIABLE!>value<!>: T = l.set(1, t)
|
||||||
l.add(1, t)
|
l.add(1, t)
|
||||||
l.remove(1)
|
l.removeAt(1)
|
||||||
val <!UNUSED_VARIABLE!>mutableListIterator<!>: MutableListIterator<T> = l.listIterator()
|
val <!UNUSED_VARIABLE!>mutableListIterator<!>: MutableListIterator<T> = l.listIterator()
|
||||||
val <!UNUSED_VARIABLE!>mutableListIterator1<!>: MutableListIterator<T> = l.listIterator(1)
|
val <!UNUSED_VARIABLE!>mutableListIterator1<!>: MutableListIterator<T> = l.listIterator(1)
|
||||||
val <!UNUSED_VARIABLE!>mutableList<!>: MutableList<T> = l.subList(1, 2)
|
val <!UNUSED_VARIABLE!>mutableList<!>: MutableList<T> = l.subList(1, 2)
|
||||||
@@ -84,7 +84,7 @@ fun <T> testMutableSet(s: MutableSet<T>, t: T) {
|
|||||||
|
|
||||||
val <!UNUSED_VARIABLE!>mutableIterator<!>: MutableIterator<T> = s.iterator()
|
val <!UNUSED_VARIABLE!>mutableIterator<!>: MutableIterator<T> = s.iterator()
|
||||||
s.add(t)
|
s.add(t)
|
||||||
s.remove(1)
|
s.remove(<!UNCHECKED_CAST!>1 as T<!>)
|
||||||
s.addAll(s)
|
s.addAll(s)
|
||||||
s.removeAll(s)
|
s.removeAll(s)
|
||||||
s.retainAll(s)
|
s.retainAll(s)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import java.util.*
|
|||||||
import java.io.*
|
import java.io.*
|
||||||
|
|
||||||
fun takeFirst(expr: StringBuilder): Char {
|
fun takeFirst(expr: StringBuilder): Char {
|
||||||
val c = expr.charAt(0)
|
val c = expr.get(0)
|
||||||
expr.deleteCharAt(0)
|
expr.deleteCharAt(0)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ fun evaluateAdd(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
|||||||
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
||||||
val lhs = evaluateAdd(expr, numbers)
|
val lhs = evaluateAdd(expr, numbers)
|
||||||
if (expr.length() > 0) {
|
if (expr.length() > 0) {
|
||||||
val <!UNUSED_VARIABLE!>c<!> = expr.charAt(0)
|
val <!UNUSED_VARIABLE!>c<!> = expr.get(0)
|
||||||
expr.deleteCharAt(0)
|
expr.deleteCharAt(0)
|
||||||
}
|
}
|
||||||
return lhs
|
return lhs
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ fun String.bar(s: String) = s
|
|||||||
|
|
||||||
fun foo(s: String?) {
|
fun foo(s: String?) {
|
||||||
s?.bar(<!DEBUG_INFO_SMARTCAST!>s<!>)
|
s?.bar(<!DEBUG_INFO_SMARTCAST!>s<!>)
|
||||||
s?.charAt(<!DEBUG_INFO_SMARTCAST!>s<!>.length())
|
s?.get(<!DEBUG_INFO_SMARTCAST!>s<!>.length())
|
||||||
}
|
}
|
||||||
@@ -384,7 +384,7 @@ public class PackageGenTest extends CodegenTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testCallMethodDeclaredInSuperclass() throws Exception {
|
public void testCallMethodDeclaredInSuperclass() throws Exception {
|
||||||
loadText("fun foo(sb: StringBuilder) = sb.charAt(0)");
|
loadText("fun foo(sb: StringBuilder) = sb.get(0)");
|
||||||
Method main = generateFunction();
|
Method main = generateFunction();
|
||||||
StringBuilder sb = new StringBuilder("x");
|
StringBuilder sb = new StringBuilder("x");
|
||||||
assertEquals('x', ((Character) main.invoke(null, sb)).charValue());
|
assertEquals('x', ((Character) main.invoke(null, sb)).charValue());
|
||||||
|
|||||||
+1
-1
@@ -11,4 +11,4 @@ class C {
|
|||||||
// EXIST: { itemText: "extFunForString", attributes: "bold" }
|
// EXIST: { itemText: "extFunForString", attributes: "bold" }
|
||||||
// EXIST: { itemText: "extFunForAny", attributes: "" }
|
// EXIST: { itemText: "extFunForAny", attributes: "" }
|
||||||
// EXIST: { itemText: "extFunForStringNullable", attributes: "bold" }
|
// EXIST: { itemText: "extFunForStringNullable", attributes: "bold" }
|
||||||
// EXIST: { itemText: "charAt", attributes: "" }
|
// EXIST: { itemText: "get", attributes: "" }
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@ import java.util.*
|
|||||||
import java.io.*
|
import java.io.*
|
||||||
|
|
||||||
fun takeFirst(expr: StringBuilder): Char {
|
fun takeFirst(expr: StringBuilder): Char {
|
||||||
val c = expr.charAt(0)
|
val c = expr.get(0)
|
||||||
expr.deleteCharAt(0)
|
expr.deleteCharAt(0)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ fun evaluateAdd(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
|||||||
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
||||||
val lhs = evaluateAdd(expr, numbers)
|
val lhs = evaluateAdd(expr, numbers)
|
||||||
if (expr.length() > 0) {
|
if (expr.length() > 0) {
|
||||||
val <warning>c</warning> = expr.charAt(0)
|
val <warning>c</warning> = expr.get(0)
|
||||||
expr.deleteCharAt(0)
|
expr.deleteCharAt(0)
|
||||||
}
|
}
|
||||||
return lhs
|
return lhs
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ fun box(): Boolean {
|
|||||||
|
|
||||||
// test addAt
|
// test addAt
|
||||||
list.add(0, 400)
|
list.add(0, 400)
|
||||||
list.remove(0);
|
list.removeAt(0);
|
||||||
list.add(1, 500)
|
list.add(1, 500)
|
||||||
// test contains, addAll
|
// test contains, addAll
|
||||||
if (!list.contains(500) || list.contains(600) || list.addAll(ArrayList<Int>())) {
|
if (!list.contains(500) || list.contains(600) || list.addAll(ArrayList<Int>())) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ fun box(): Boolean {
|
|||||||
arr.add(i)
|
arr.add(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
val removedElement = arr.remove(2)
|
val removedElement = arr.removeAt(2)
|
||||||
val removed = arr.remove(4: Any)
|
val removed = arr.remove(4)
|
||||||
return arr.size() == 4 && removedElement == 2 && removed && arr[0] == 0 && arr[1] == 1 && arr[2] == 3 && arr[3] == 5
|
return arr.size() == 4 && removedElement == 2 && removed && arr[0] == 0 && arr[1] == 1 && arr[2] == 3 && arr[3] == 5
|
||||||
}
|
}
|
||||||
+2
-2
@@ -7,7 +7,7 @@ fun box(): Boolean {
|
|||||||
|
|
||||||
val arr = ArrayList<Int>()
|
val arr = ArrayList<Int>()
|
||||||
try {
|
try {
|
||||||
arr.remove(2)
|
arr.removeAt(2)
|
||||||
}
|
}
|
||||||
catch(e: IndexOutOfBoundsException) {
|
catch(e: IndexOutOfBoundsException) {
|
||||||
threwForEmptyList = true
|
threwForEmptyList = true
|
||||||
@@ -20,7 +20,7 @@ fun box(): Boolean {
|
|||||||
var threwForFilled = false
|
var threwForFilled = false
|
||||||
|
|
||||||
try {
|
try {
|
||||||
arr.remove(20)
|
arr.removeAt(20)
|
||||||
}
|
}
|
||||||
catch(e: IndexOutOfBoundsException) {
|
catch(e: IndexOutOfBoundsException) {
|
||||||
threwForFilled = true
|
threwForFilled = true
|
||||||
|
|||||||
Reference in New Issue
Block a user