package ch.hsr.ifs.pystructure.tests.utils;

import org.python.pydev.parser.jython.ParseException;
import org.python.pydev.parser.jython.ast.Call;
import org.python.pydev.parser.jython.ast.Expr;
import org.python.pydev.parser.jython.ast.Module;

import ch.hsr.ifs.pystructure.parser.Parser;
import ch.hsr.ifs.pystructure.typeinference.model.base.NodeUtils;
import junit.framework.TestCase;

public class NodeUtilsTest extends TestCase {
	
	public void testGetCallForFunc() throws ParseException {
		Module module = Parser.parse("module.func(arg)");
		Expr expr = (Expr) module.body[0];
		Call call = (Call) expr.value;
		call.func.parent = call;
		
		assertEquals(call, NodeUtils.getCallForFunc(call.func));
	}
	
}

@@ -92,16 +92,69 @@
 eption;%0A
+import org.python.pydev.parser.jython.ast.Attribute;%0A
 import o
@@ -485,16 +485,259 @@
 ase %7B%0A%09%0A
+%09public void testGetId() throws ParseException %7B%0A%09%09Module module = Parser.parse(%22module.func%22);%0A%09%09Expr expr = (Expr) module.body%5B0%5D;%0A%09%09Attribute attribute = (Attribute) expr.value;%0A%09%09assertEquals(%22func%22, NodeUtils.getId(attribute.attr));%0A%09%7D%0A%09%0A
 %09public 

Test for getId.