Commit 5aa62335 authored by Lubomir Bulej's avatar Lubomir Bulej

Fix white space in tests suites to make modifications easier to merge.

parent d2ea1487
......@@ -3,6 +3,7 @@ package ch.usi.dag.disl.scope;
import org.junit.Assert;
import org.junit.Test;
public class TypeMatcherTest {
@Test
......
......@@ -3,6 +3,7 @@ package ch.usi.dag.disl.scope;
import org.junit.Assert;
import org.junit.Test;
public class WildCardMatcherTest {
@Test
......
package ch.usi.dag.disl.test.suite.after.app;
public class TargetClass {
public void print(final boolean flag) {
try {
System.out.println("app: TargetClass.print(..) - try:begin");
if (flag) {
final String float_one = "1.0";
final Integer int_one = Integer.valueOf(float_one);
System.out.println("app: UNREACHABLE " + int_one);
}
System.out.println("app: TargetClass.print(..) - try:end");
} finally {
System.out.println("app: TargetClass.print(..) - finally");
}
}
public static void main (final String [] args) {
try {
final TargetClass t = new TargetClass ();
System.out.println ("app: TargetClass.main(..) - .print(false)");
t.print (false);
System.out.println ("app: TargetClass.main(..) - .print(true)");
t.print (true);
} catch (final Throwable e) {
System.out.println ("app: TargetClass.main(..) - catch");
}
}
}
package ch.usi.dag.disl.test.suite.after.app;
public class TargetClass {
public void print(final boolean flag) {
try {
System.out.println("app: TargetClass.print(..) - try:begin");
if (flag) {
final String float_one = "1.0";
final Integer int_one = Integer.valueOf(float_one);
System.out.println("app: UNREACHABLE " + int_one);
}
System.out.println("app: TargetClass.print(..) - try:end");
} finally {
System.out.println("app: TargetClass.print(..) - finally");
}
}
public static void main (final String [] args) {
try {
final TargetClass t = new TargetClass ();
System.out.println ("app: TargetClass.main(..) - .print(false)");
t.print (false);
System.out.println ("app: TargetClass.main(..) - .print(true)");
t.print (true);
} catch (final Throwable e) {
System.out.println ("app: TargetClass.main(..) - catch");
}
}
}
package ch.usi.dag.disl.test.suite.after.instr;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.AfterThrowing;
import ch.usi.dag.disl.marker.BodyMarker;
public class DiSLClass {
@After(marker = BodyMarker.class, scope = "TargetClass.print(boolean)", order = 0)
public static void after() {
System.out.println("disl: after");
}
@AfterThrowing(marker = BodyMarker.class, scope = "TargetClass.print(boolean)", order = 1)
public static void afterThrowning() {
System.out.println("disl: afterThrowning");
}
}
package ch.usi.dag.disl.test.suite.after.instr;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.AfterThrowing;
import ch.usi.dag.disl.marker.BodyMarker;
public class DiSLClass {
@After(marker = BodyMarker.class, scope = "TargetClass.print(boolean)", order = 0)
public static void after() {
System.out.println("disl: after");
}
@AfterThrowing(marker = BodyMarker.class, scope = "TargetClass.print(boolean)", order = 1)
public static void afterThrowning() {
System.out.println("disl: afterThrowning");
}
}
package ch.usi.dag.disl.test.suite.after2.app;
public class TargetClass {
public static void main(String[] args) {
// NOTE: this test is better to use on large project and not this simple class
// NOTE: this test is better to use on large project and not this simple class
System.out.println("app: TargetClass.main(..)");
}
}
......@@ -10,6 +10,7 @@ import ch.usi.dag.disl.staticcontext.uid.UniqueMethodId;
import ch.usi.dag.disl.test.suite.after2.instr.runtime.Analysis;
public class DiSLClass {
@ThreadLocal
static Stack<Integer> stackTL;
......@@ -26,4 +27,5 @@ public class DiSLClass {
public static void onMethodExit(UniqueMethodId id) {
Analysis.onExit(stackTL, id.get());
}
}
......@@ -4,9 +4,10 @@ import ch.usi.dag.disl.annotation.GuardMethod;
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
public class NotInitNorClinit {
@GuardMethod
@GuardMethod
public static boolean isApplicable(MethodStaticContext msc) {
return (msc.thisMethodName().endsWith("init>")) ? false : true;
}
}
......@@ -3,16 +3,18 @@ package ch.usi.dag.disl.test.suite.after2.instr.runtime;
import java.util.Stack;
public class Analysis {
public static void onExit(Stack<Integer> stack, int methodUID) {
int topOfTheStack = stack.pop();
if (topOfTheStack != methodUID) {
System.err.println("After method: " + methodUID);
int size = stack.size();
System.err.println("Stack[" + size + "]: " + topOfTheStack);
for(int i = size - 1; i >= 0; i--) {
System.err.println("Stack[" + i + "]: " + stack.elementAt(i));
}
System.exit(1);
}
System.err.println("After method: " + methodUID);
int size = stack.size();
System.err.println("Stack[" + size + "]: " + topOfTheStack);
for(int i = size - 1; i >= 0; i--) {
System.err.println("Stack[" + i + "]: " + stack.elementAt(i));
}
System.exit(1);
}
}
}
package ch.usi.dag.disl.test.suite.after3.app;
public class TargetClass {
public static void main(String[] args) {
try {
System.out.println("app: TargetClass.main(..) - .ethrowing1()");
ethrowing1();
System.out.println("app: TargetClass.main(..) - ~ethrowing1()");
} catch (Exception e) {
System.out.println("app: TargetClass.main(..) - catch");
}
try {
System.out.println("app: TargetClass.main(..) - .ereturning1()");
ereturning1();
System.out.println("app: TargetClass.main(..) - ~ereturning1()");
} catch (Exception e) {
System.out.println("app: TargetClass.main(..) - catch");
}
try {
System.out.println("app: TargetClass.main(..) - .ethrowing2()");
ethrowing2();
System.out.println("app: TargetClass.main(..) - ~ethrowing2()");
} catch (Exception e) {
System.out.println("app: TargetClass.main(..) - catch");
}
try {
System.out.println("app: TargetClass.main(..) - ~ereturning2()");
ereturning2();
System.out.println("app: TargetClass.main(..) - ~ereturning2()");
} catch (Exception e) {
System.out.println("app: TargetClass.main(..) - catch");
}
}
public static void ethrowing1()
throws Exception {
try {
if("a".equals("a")) {
throw new Exception();
}
return;
} catch (Exception e) {
throw e;
}
}
public static void ereturning1()
throws Exception {
try {
if("a".equals("a")) {
//throw new Exception();
}
return;
} catch (Exception e) {
throw e;
}
}
public static void ethrowing2()
throws Exception {
throw new Exception();
}
public static void ereturning2()
throws Exception {
//throw new Exception();
}
}
package ch.usi.dag.disl.test.suite.after3.app;
public class TargetClass {
public static void main(String[] args) {
try {
System.out.println("app: TargetClass.main(..) - .ethrowing1()");
ethrowing1();
System.out.println("app: TargetClass.main(..) - ~ethrowing1()");
} catch (Exception e) {
System.out.println("app: TargetClass.main(..) - catch");
}
try {
System.out.println("app: TargetClass.main(..) - .ereturning1()");
ereturning1();
System.out.println("app: TargetClass.main(..) - ~ereturning1()");
} catch (Exception e) {
System.out.println("app: TargetClass.main(..) - catch");
}
try {
System.out.println("app: TargetClass.main(..) - .ethrowing2()");
ethrowing2();
System.out.println("app: TargetClass.main(..) - ~ethrowing2()");
} catch (Exception e) {
System.out.println("app: TargetClass.main(..) - catch");
}
try {
System.out.println("app: TargetClass.main(..) - ~ereturning2()");
ereturning2();
System.out.println("app: TargetClass.main(..) - ~ereturning2()");
} catch (Exception e) {
System.out.println("app: TargetClass.main(..) - catch");
}
}
public static void ethrowing1()
throws Exception {
try {
if("a".equals("a")) {
throw new Exception();
}
return;
} catch (Exception e) {
throw e;
}
}
public static void ereturning1()
throws Exception {
try {
if("a".equals("a")) {
//throw new Exception();
}
return;
} catch (Exception e) {
throw e;
}
}
public static void ethrowing2()
throws Exception {
throw new Exception();
}
public static void ereturning2()
throws Exception {
//throw new Exception();
}
}
package ch.usi.dag.disl.test.suite.after3.instr;
import ch.usi.dag.disl.annotation.AfterReturning;
import ch.usi.dag.disl.annotation.AfterThrowing;
import ch.usi.dag.disl.marker.BodyMarker;
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
public class DiSLClass {
@AfterThrowing(marker = BodyMarker.class, scope = "TargetClass.e*", order = 0)
public static void throwing(MethodStaticContext sc) {
System.out.println("disl: throwing from " + sc.thisMethodName());
}
@AfterReturning(marker = BodyMarker.class, scope = "TargetClass.e*", order = 0)
public static void returning(MethodStaticContext sc) {
System.out.println("disl: returning from " + sc.thisMethodName());
}
}
package ch.usi.dag.disl.test.suite.after3.instr;
import ch.usi.dag.disl.annotation.AfterReturning;
import ch.usi.dag.disl.annotation.AfterThrowing;
import ch.usi.dag.disl.marker.BodyMarker;
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
public class DiSLClass {
@AfterThrowing(marker = BodyMarker.class, scope = "TargetClass.e*", order = 0)
public static void throwing(MethodStaticContext sc) {
System.out.println("disl: throwing from " + sc.thisMethodName());
}
@AfterReturning(marker = BodyMarker.class, scope = "TargetClass.e*", order = 0)
public static void returning(MethodStaticContext sc) {
System.out.println("disl: returning from " + sc.thisMethodName());
}
}
......@@ -40,4 +40,5 @@ public class TargetClass {
final TargetSubclass t = new TargetSubclass ();
t.method ();
}
}
......@@ -17,4 +17,5 @@ public class DiSLClass {
public static void afterThrowning () {
System.out.println ("After");
}
}
......@@ -32,4 +32,5 @@ public class TargetClass {
final TargetClass t = new TargetSubclass ();
System.out.println (t.getClass ().getSimpleName ());
}
}
......@@ -18,4 +18,5 @@ public class DiSLClass {
public static void afterThrowning (final MethodStaticContext msc) {
System.out.println (msc.thisClassSimpleName () +"."+ msc.thisMethodName () +" after");
}
}
......@@ -2,87 +2,86 @@ package ch.usi.dag.disl.test.suite.args.app;
public class TargetClass {
public void test_int(int i) {
System.out.println("app: TargetClass.test_int");
}
public void test_Integer(Integer i) {
System.out.println("app: TargetClass.test_Integer");
}
public void test_float(float f) {
System.out.println("app: TargetClass.test_float");
}
public void test_Float(Float f) {
System.out.println("app: TargetClass.test_Float");
}
public void test_double(double d) {
System.out.println("app: TargetClass.test_double");
}
public void test_Double(Double d) {
System.out.println("app: TargetClass.test_Double");
}
public void test_String(String s) {
System.out.println("app: TargetClass.test_String");
}
public void test_Object(Object o) {
System.out.println("app: TargetClass.test_Object");
}
public void test_ObjectArray(Object[] oa) {
System.out.println("app: TargetClass.test_ObjectArray");
}
public void test_MultipleObjectArray(Object[] oa1, Object[] oa2) {
System.out.println("app: TargetClass.test_MultipleObjectArray");
}
public void test_VariableObjectArray(Object[]... oas) {
System.out.println("app: TargetClass.test_VaribleObjectArray");
}
public static void main(String[] args) {
System.out.println("app: TargetClass.main - begin");
TargetClass t = new TargetClass();
t.test_int(42);
t.test_Integer(new Integer(42));
t.test_float(42.42f);
t.test_Float(new Float(42.42f));
t.test_double(42.42);
t.test_Double(new Double(42.42));
t.test_String("my test string");
t.test_Object("my test object string");
t.test_ObjectArray(new Object[] {"str1", "str2", "str3"});
t.test_MultipleObjectArray(new Object[] {"1str1", "1str2", "1str3"}, new Object[] {"2str1", "2str2", "2str3"});
t.test_VariableObjectArray(new Object[] {"1str1", "1str2", "1str3"}, new Object[] {"2str1", "2str2", "2str3"});
/*t.method1();
t.method2(1, 2, 3);
t.method3("object", "string");
t.method3("object2", "string2");
t.method3(t, "THIS IS THE REF TO THIS");
t.method3(1, 2, "object");
t.method4(new String[] { "hello" }, new int[] { 1, 2, 3, 4, 5 });
TargetClass.isValidChar('c');*/
System.out.println("app: TargetClass.main - end");
}
public void test_int(int i) {
System.out.println("app: TargetClass.test_int");
}
public void test_Integer(Integer i) {
System.out.println("app: TargetClass.test_Integer");
}
public void test_float(float f) {
System.out.println("app: TargetClass.test_float");
}
public void test_Float(Float f) {
System.out.println("app: TargetClass.test_Float");
}
public void test_double(double d) {
System.out.println("app: TargetClass.test_double");
}
public void test_Double(Double d) {
System.out.println("app: TargetClass.test_Double");
}
public void test_String(String s) {
System.out.println("app: TargetClass.test_String");
}
public void test_Object(Object o) {
System.out.println("app: TargetClass.test_Object");
}
public void test_ObjectArray(Object[] oa) {
System.out.println("app: TargetClass.test_ObjectArray");
}
public void test_MultipleObjectArray(Object[] oa1, Object[] oa2) {
System.out.println("app: TargetClass.test_MultipleObjectArray");
}
public void test_VariableObjectArray(Object[]... oas) {
System.out.println("app: TargetClass.test_VaribleObjectArray");
}
public static void main(String[] args) {
System.out.println("app: TargetClass.main - begin");
TargetClass t = new TargetClass();
t.test_int(42);
t.test_Integer(new Integer(42));
t.test_float(42.42f);
t.test_Float(new Float(42.42f));
t.test_double(42.42);
t.test_Double(new Double(42.42));
t.test_String("my test string");
t.test_Object("my test object string");
t.test_ObjectArray(new Object[] {"str1", "str2", "str3"});
t.test_MultipleObjectArray(new Object[] {"1str1", "1str2", "1str3"}, new Object[] {"2str1", "2str2", "2str3"});
t.test_VariableObjectArray(new Object[] {"1str1", "1str2", "1str3"}, new Object[] {"2str1", "2str2", "2str3"});
/*t.method1();
t.method2(1, 2, 3);
t.method3("object", "string");
t.method3("object2", "string2");
t.method3(t, "THIS IS THE REF TO THIS");
t.method3(1, 2, "object");
t.method4(new String[] { "hello" }, new int[] { 1, 2, 3, 4, 5 });
TargetClass.isValidChar('c');*/
System.out.println("app: TargetClass.main - end");
}
}
......@@ -8,63 +8,63 @@ import ch.usi.dag.disl.staticcontext.MethodStaticContext;
public class DiSLClass {
@AfterReturning(marker = BodyMarker.class, scope = "TargetClass.*")
public static void postcondition(final MethodStaticContext sc, final ArgumentProcessorContext pc) {
System.out.printf("disl: args for %s %s\n", sc.thisMethodFullName(), sc.thisMethodDescriptor());
final Object[] args = pc.getArgs(ArgumentProcessorMode.METHOD_ARGS);
LEVEL1: for(int i = 0 ; i < args.length; ++i) {
System.out.printf("disl: \targ[%d]\n", i);
if (args[i] instanceof Object[]) {
final Object[] argsarr = (Object[])args[i];
LEVEL2: for (final Object arg : argsarr) {
if (arg instanceof Object[]) {
final Object[] argsarr2 = (Object[])arg;
LEVEL3: for (final Object arg2 : argsarr2) {
final Object a = arg2;
final String n = a.getClass().getCanonicalName();
// code duplication as this is DiSL class
// and we would have to move it out
if(n.equals ("java.lang.Integer")) {
System.out.printf("disl: \t\t\t\t%s\n", n);
System.out.printf("disl: \t\t\t\t%s\n", a.toString());
continue LEVEL3;
}
if(n.equals ("java.lang.Float")) {
System.out.printf("disl: \t\t\t\t%s\n", n);
System.out.printf("disl: \t\t\t\t%s\n", a.toString());
continue LEVEL3;
}
if(n.equals ("java.lang.Double")) {
System.out.printf("disl: \t\t\t\t%s\n", n);
System.out.printf("disl: \t\t\t\t%s\n", a.toString());
continue LEVEL3;
}
if(n.equals ("java.lang.String")) {
System.out.printf("disl: \t\t\t\t%s\n", n);
System.out.printf("disl: \t\t\t\t%s\n", a.toString());
continue LEVEL3;
}
// default
System.out.printf("disl: \t\t\t\t%s\n", n);
System.out.printf("disl: \t\t\t\t== cannot print ==\n");
}
} else {
final Object a = arg;
final String n = a.getClass().getCanonicalName();
if(n.equals ("java.lang.Integer")) {
@AfterReturning(marker = BodyMarker.class, scope = "TargetClass.*")
public static void postcondition(final MethodStaticContext sc, final ArgumentProcessorContext pc) {
System.out.printf("disl: args for %s %s\n", sc.thisMethodFullName(), sc.thisMethodDescriptor());
final Object[] args = pc.getArgs(ArgumentProcessorMode.METHOD_ARGS);
LEVEL1: for(int i = 0 ; i < args.length; ++i) {
System.out.printf("disl: \targ[%d]\n", i);
if (args[i] instanceof Object[]) {
final Object[] argsarr = (Object[])args[i];
LEVEL2: for (final Object arg : argsarr) {
if (arg instanceof Object[]) {
final Object[] argsarr2 = (Object[])arg;
LEVEL3: for (final Object arg2 : argsarr2) {
final Object a = arg2;
final String n = a.getClass().getCanonicalName();
// code duplication as this is DiSL class
// and we would have to move it out