Existing tests for 'val reassignment' of function parameters fixed
This commit is contained in:
@@ -52,7 +52,7 @@ abstract class Sum() : Iteratee<Int, Int> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class Collection<E> : Iterable<E> {
|
abstract class Collection<E> : Iterable<E> {
|
||||||
fun iterate<O>(iteratee : Iteratee<E, O>) : O {
|
fun iterate<O>(var iteratee : Iteratee<E, O>) : O {
|
||||||
for (x in this) {
|
for (x in this) {
|
||||||
val it = iteratee.process(x)
|
val it = iteratee.process(x)
|
||||||
if (it.isDone) return it.result
|
if (it.isDone) return it.result
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class Foo(var bar : Int, barr : Int, val barrr : Int) {
|
class Foo(var bar : Int, var barr : Int, var barrr : Int) {
|
||||||
{
|
{
|
||||||
bar = 1
|
bar = 1
|
||||||
barr = 1
|
barr = 1
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
this : Foo
|
this : Foo
|
||||||
}
|
}
|
||||||
|
|
||||||
this(val bar : Int) : this(1, 1, 1) {
|
this(var bar : Int) : this(1, 1, 1) {
|
||||||
bar = 1
|
bar = 1
|
||||||
this.bar
|
this.bar
|
||||||
1 : Int
|
1 : Int
|
||||||
|
|||||||
@@ -48,6 +48,13 @@ fun t2() {
|
|||||||
fun doSmth(s: String) {}
|
fun doSmth(s: String) {}
|
||||||
fun doSmth(i: Int) {}
|
fun doSmth(i: Int) {}
|
||||||
|
|
||||||
|
class A() {}
|
||||||
|
|
||||||
|
fun t4(a: A, val b: A, var c: A) {
|
||||||
|
<!VAL_REASSIGNMENT!>a<!> = A()
|
||||||
|
<!VAL_REASSIGNMENT!>b<!> = A()
|
||||||
|
c = A()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace reassigned_vals {
|
namespace reassigned_vals {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ abstract class Sum() : Iteratee<Int, Int> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class Collection<E> : Iterable<E> {
|
abstract class Collection<E> : Iterable<E> {
|
||||||
fun iterate<O>(iteratee : Iteratee<E, O>) : O {
|
fun iterate<O>(var iteratee : Iteratee<E, O>) : O {
|
||||||
for (x in this) {
|
for (x in this) {
|
||||||
val it = iteratee.process(x)
|
val it = iteratee.process(x)
|
||||||
if (it.isDone) return it.result
|
if (it.isDone) return it.result
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
class Foo(var bar : Int, barr : Int, val barrr : Int) {
|
class Foo(var bar : Int, var barr : Int, var barrr : Int) {
|
||||||
{
|
{
|
||||||
bar = 1
|
bar = 1
|
||||||
barr = 1
|
barr = 1
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
this : Foo
|
this : Foo
|
||||||
}
|
}
|
||||||
|
|
||||||
this(val bar : Int) : this(1, 1, 1) {
|
this(var bar : Int) : this(1, 1, 1) {
|
||||||
bar = 1
|
bar = 1
|
||||||
this.bar
|
this.bar
|
||||||
1 : Int
|
1 : Int
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
fun loop(times : Int) {
|
fun loop(var times : Int) {
|
||||||
while(times > 0) {
|
while(times > 0) {
|
||||||
val u : fun(value : Int) : Unit = {
|
val u : fun(value : Int) : Unit = {
|
||||||
System.out?.println(it)
|
System.out?.println(it)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class C(x: Int, val y : Int) {
|
class C(x: Int, val y : Int) {
|
||||||
fun initChild(x: Int) : java.lang.Object {
|
fun initChild(var x: Int) : java.lang.Object {
|
||||||
return object : java.lang.Object() {
|
return object : java.lang.Object() {
|
||||||
override fun toString(): String? {
|
override fun toString(): String? {
|
||||||
x = x + y
|
x = x + y
|
||||||
|
|||||||
@@ -169,25 +169,25 @@ public class PrimitiveTypesTest extends CodegenTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testPreDecrement() throws Exception {
|
public void testPreDecrement() throws Exception {
|
||||||
loadText("fun foo(a: Int): Int { return --a;}");
|
loadText("fun foo(var a: Int): Int { return --a;}");
|
||||||
final Method main = generateFunction();
|
final Method main = generateFunction();
|
||||||
assertEquals(9, main.invoke(null, 10));
|
assertEquals(9, main.invoke(null, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPreIncrementLong() throws Exception {
|
public void testPreIncrementLong() throws Exception {
|
||||||
loadText("fun foo(a: Long): Long = ++a");
|
loadText("fun foo(var a: Long): Long = ++a");
|
||||||
final Method main = generateFunction();
|
final Method main = generateFunction();
|
||||||
assertEquals(11L, main.invoke(null, 10L));
|
assertEquals(11L, main.invoke(null, 10L));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPreIncrementFloat() throws Exception {
|
public void testPreIncrementFloat() throws Exception {
|
||||||
loadText("fun foo(a: Float): Float = ++a");
|
loadText("fun foo(var a: Float): Float = ++a");
|
||||||
final Method main = generateFunction();
|
final Method main = generateFunction();
|
||||||
assertEquals(2.0f, main.invoke(null, 1.0f));
|
assertEquals(2.0f, main.invoke(null, 1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPreIncrementDouble() throws Exception {
|
public void testPreIncrementDouble() throws Exception {
|
||||||
loadText("fun foo(a: Double): Double = ++a");
|
loadText("fun foo(var a: Double): Double = ++a");
|
||||||
final Method main = generateFunction();
|
final Method main = generateFunction();
|
||||||
assertEquals(2.0, main.invoke(null, 1.0));
|
assertEquals(2.0, main.invoke(null, 1.0));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user