package jvmgo.instructions;

import java.util.ArrayList;
import java.util.List;
import jvmgo.UnitTestRunner;
import org.junit.Test;
import static org.junit.Assert.*;

@SuppressWarnings("serial")
public class InvokeTest extends ArrayList<String> {

    @Override
    public String get(int index) {
        return "InvokeTest";
    }
    
    public String getFromSuper(int index) {
        return super.get(index);
    }
    
    public static void main(String[] args) {
        UnitTestRunner.run(InvokeTest.class);
    }
    
    @Test
    public void invoke() {
        InvokeTest test = new InvokeTest();
        test.add("ArrayList");
        
        // invokevirtual
        ArrayList<String> arrayList = test;
        assertEquals("InvokeTest", arrayList.get(0));
        
        // invokespecial
        assertEquals("ArrayList", test.getFromSuper(0));
        
        // invokeinterface
        List<String> list = test;
        assertEquals("InvokeTest", list.get(0));
    }
    
}

@@ -241,16 +241,118 @@
 ing%3E %7B%0A%0A
+    public static void main(String%5B%5D args) %7B%0A        UnitTestRunner.run(InvokeTest.class);%0A    %7D%0A    %0A
     @Ove
@@ -524,110 +524,8 @@
    %0A
-    public static void main(String%5B%5D args) %7B%0A        UnitTestRunner.run(InvokeTest.class);%0A    %7D%0A    %0A
     

refactor unit test