package ch.ntb.inf.deep.ssa;

import java.io.IOException;

import org.junit.BeforeClass;
import org.junit.Test;

import ch.ntb.inf.deep.classItems.Class;
import ch.ntb.inf.deep.classItems.IClassFileConsts;
import ch.ntb.inf.deep.classItems.Type;

public class SSA08 extends TestSSA {
	@BeforeClass
	public static void setUp() {
		String workspace =System.getProperty("user.dir");
		String[] rootClassNames = new String[] { "ch/ntb/inf/deep/testClasses/T08Calls" };
		try {
			Class.buildSystem(rootClassNames,workspace, (1 << IClassFileConsts.atxCode)
					| (1 << IClassFileConsts.atxLocalVariableTable)
					| (1 << IClassFileConsts.atxLineNumberTable)
					| (1 << IClassFileConsts.atxExceptions));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (Type.nofRootClasses > 0) {
			createSSA(Type.rootClasses[0]);
		}
	}

	@Test
	public void testConstructor() {
		SSANode[] nodes = getAndTestSSA(0, 1, 0);
		testNode(nodes[0], 3, 0, 2);
	}
	
	@Test
	public void testClassMethCall(){
		SSANode[] nodes = getAndTestSSA(1, 1, 0);
		testNode(nodes[0], 11, 0, 4);
	}
	
	@Test
	public void testObjectMethCall(){
		SSANode[] nodes = getAndTestSSA(2, 1, 0);
		testNode(nodes[0], 5, 0, 3);
	}
	
	@Test
	public void testCallToAnotherClass(){
		SSANode[] nodes = getAndTestSSA(3, 1, 0);
		testNode(nodes[0], 2, 0, 0);
	}

}

@@ -892,16 +892,143 @@
 %09%09%7D%0D%0A%09%7D%0D
+%0A%09@Test%0D%0A%09public void testClassConstructor()%7B%0D%0A%09%09SSANode%5B%5D nodes = getAndTestSSA(0, 1, 0);%0D%0A%09%09testNode(nodes%5B0%5D, 5, 0, 1);%0D%0A%09%7D%0D
 %0A%0D%0A%09@Tes
@@ -1090,33 +1090,33 @@
 = getAndTestSSA(
-0
+1
 , 1, 0);%0D%0A%09%09test
@@ -1134,15 +1134,15 @@
 0%5D, 
-3
+5
 , 0, 
-2
+3
 );%0D%0A
@@ -1217,33 +1217,33 @@
 = getAndTestSSA(
-1
+2
 , 1, 0);%0D%0A%09%09test
@@ -1346,33 +1346,33 @@
 = getAndTestSSA(
-2
+3
 , 1, 0);%0D%0A%09%09test
@@ -1478,33 +1478,33 @@
 = getAndTestSSA(
-3
+4
 , 1, 0);%0D%0A%09%09test

add test for clinit