augmented assignments for arrays; replace the hack of "value before receiver" with a lesser hack of dupReceiver()

This commit is contained in:
Dmitry Jemerov
2011-04-15 19:46:33 +02:00
parent f13da41f43
commit 009c58f680
3 changed files with 31 additions and 14 deletions
@@ -338,10 +338,18 @@ public class NamespaceGenTest extends CodegenTestCase {
public void testArrayWrite() throws Exception {
loadText("fun foo(c: Array<String>) { c[0] = \"jet\"; }");
System.out.println(generateToText());
final Method main = generateFunction();
String[] array = new String[] { null };
main.invoke(null, new Object[] { array });
assertEquals("jet", array[0]);
}
public void testArrayAugAssign() throws Exception {
loadText("fun foo(c: Array<Int>) { c[0] *= 2 }");
System.out.println(generateToText());
final Method main = generateFunction();
int[] data = new int[] { 5 };
main.invoke(null, new Object[] { data });
assertEquals(10, data[0]);
}
}