Loading iacfg/src/test/java/es/upv/mist/slicing/graphs/icfg/ICFGTest.java +13 −3 Original line number Diff line number Diff line Loading @@ -14,7 +14,18 @@ public class ICFGTest { StaticJavaParser.getConfiguration().setAttributeComments(false); StaticTypeSolver.addTypeSolverJRE(); File file = new File(Thread.currentThread().getContextClassLoader().getResource("Test.java").getPath()); createGraph("TestInicial.java", "grafoInicial"); System.out.println("Grafo 1 generado..."); createGraph("TestGlobalVariables.java", "grafoGlobalVariables"); System.out.println("Grafo 2 generado..."); createGraph("TestEmbebedFunctions.java", "grafoEmbebedFunctions"); System.out.println("Grafo 3 generado..."); } private static void createGraph(String fileName, String graphName) throws IOException { File file = new File(Thread.currentThread().getContextClassLoader().getResource(fileName).getPath()); NodeList<CompilationUnit> units = new NodeList<>(); try { units.add(StaticJavaParser.parse(file)); Loading @@ -23,7 +34,6 @@ public class ICFGTest { } ICFG icfg = new ICFG(); icfg.build(units); new ICFGLog(icfg).generateImages("migrafo"); System.out.println("Grafo generado..."); new ICFGLog(icfg).generateImages(graphName); } } iacfg/src/test/resources/TestEmbebedFunctions.java 0 → 100644 +65 −0 Original line number Diff line number Diff line public class TestEmbebedFunctions { public static int x = 0; public static int y = 5; public static int z = 7; public static void main(String[] args) { System.out.println("Valores iniciales:"); System.out.println("x: " + TestEmbebedFunctions.x); System.out.println("y: " + TestEmbebedFunctions.y); System.out.println("z: " + TestEmbebedFunctions.z); TestEmbebedFunctions.x = 10; TestEmbebedFunctions.y = TestEmbebedFunctions.y + TestEmbebedFunctions.x; System.out.println("\nValores despues de modificar:"); System.out.println("x: " + TestEmbebedFunctions.x); System.out.println("y: " + TestEmbebedFunctions.y); System.out.println("z: " + TestEmbebedFunctions.z); int valor1 = multiplyCtimes(TestEmbebedFunctions.x, incrementar(TestEmbebedFunctions.y, TestEmbebedFunctions.x), TestEmbebedFunctions.z); System.out.println("valor1 (x * (y+1) repeated z times): " + valor1); int valor2 = multiplyCtimes(TestEmbebedFunctions.x, incrementarBucle(TestEmbebedFunctions.y), TestEmbebedFunctions.z); System.out.println("valor2 (x * sum(0..y-1) repeated z times): " + valor2); int valor3 = multiplyCtimes(TestEmbebedFunctions.x, TestEmbebedFunctions.y, incrementar(TestEmbebedFunctions.z, TestEmbebedFunctions.x)); System.out.println("valor3 (x * y repeated (z+1) times): " + valor3); int valor4 = multiplyCtimes(TestEmbebedFunctions.x, TestEmbebedFunctions.y, incrementarBucle(TestEmbebedFunctions.z)); System.out.println("valor4 (x * y repeated sum(0..z-1) times): " + valor4); } private static int multiplyCtimes(int a, int b, int c) { if (c <= 0) { return 0; } int result = b; for (int i = 1; i < c; i++) { result *= a; } return result; } private static int incrementar(int a, int b) { b++; return a + 1; } private static int incrementarBucle(int a) { if (a > 0) { int x = 0; for (int i = 0; i < a; i++) { x = x + i; } return x; } else { return a; } } } No newline at end of file iacfg/src/test/resources/TestGlobalVariables.java 0 → 100644 +46 −0 Original line number Diff line number Diff line public class TestGlobalVariables { public static int x = 0; public static int y = 5; public static void main(String[] args) { System.out.println("Valores iniciales:"); System.out.println("x: " + TestGlobalVariables.x); System.out.println("y: " + TestGlobalVariables.y); TestGlobalVariables.x = 10; TestGlobalVariables.y = TestGlobalVariables.y + TestGlobalVariables.x; System.out.println("\nValores despues de modificar:"); System.out.println("x: " + TestGlobalVariables.x); System.out.println("y: " + TestGlobalVariables.y); while (TestGlobalVariables.x < 100) { if (TestGlobalVariables.x < 50) { System.out.println(TestGlobalVariables.x); TestGlobalVariables.x = incrementar(TestGlobalVariables.x, 0); } else { System.out.println(TestGlobalVariables.x); TestGlobalVariables.x = incrementarBucle(TestGlobalVariables.x); } } } private static int incrementar(int a, int b) { b++; return a + 1; } private static int incrementarBucle(int a) { if (a > 0) { int x = 0; for (int i = 0; i < a; i++) { x = x + i; } return x; } else { return a; } } } iacfg/src/test/resources/Test.java→iacfg/src/test/resources/TestInicial.java +1 −1 Original line number Diff line number Diff line public class Test { public class TestInicial { public static int z = 0; Loading Loading
iacfg/src/test/java/es/upv/mist/slicing/graphs/icfg/ICFGTest.java +13 −3 Original line number Diff line number Diff line Loading @@ -14,7 +14,18 @@ public class ICFGTest { StaticJavaParser.getConfiguration().setAttributeComments(false); StaticTypeSolver.addTypeSolverJRE(); File file = new File(Thread.currentThread().getContextClassLoader().getResource("Test.java").getPath()); createGraph("TestInicial.java", "grafoInicial"); System.out.println("Grafo 1 generado..."); createGraph("TestGlobalVariables.java", "grafoGlobalVariables"); System.out.println("Grafo 2 generado..."); createGraph("TestEmbebedFunctions.java", "grafoEmbebedFunctions"); System.out.println("Grafo 3 generado..."); } private static void createGraph(String fileName, String graphName) throws IOException { File file = new File(Thread.currentThread().getContextClassLoader().getResource(fileName).getPath()); NodeList<CompilationUnit> units = new NodeList<>(); try { units.add(StaticJavaParser.parse(file)); Loading @@ -23,7 +34,6 @@ public class ICFGTest { } ICFG icfg = new ICFG(); icfg.build(units); new ICFGLog(icfg).generateImages("migrafo"); System.out.println("Grafo generado..."); new ICFGLog(icfg).generateImages(graphName); } }
iacfg/src/test/resources/TestEmbebedFunctions.java 0 → 100644 +65 −0 Original line number Diff line number Diff line public class TestEmbebedFunctions { public static int x = 0; public static int y = 5; public static int z = 7; public static void main(String[] args) { System.out.println("Valores iniciales:"); System.out.println("x: " + TestEmbebedFunctions.x); System.out.println("y: " + TestEmbebedFunctions.y); System.out.println("z: " + TestEmbebedFunctions.z); TestEmbebedFunctions.x = 10; TestEmbebedFunctions.y = TestEmbebedFunctions.y + TestEmbebedFunctions.x; System.out.println("\nValores despues de modificar:"); System.out.println("x: " + TestEmbebedFunctions.x); System.out.println("y: " + TestEmbebedFunctions.y); System.out.println("z: " + TestEmbebedFunctions.z); int valor1 = multiplyCtimes(TestEmbebedFunctions.x, incrementar(TestEmbebedFunctions.y, TestEmbebedFunctions.x), TestEmbebedFunctions.z); System.out.println("valor1 (x * (y+1) repeated z times): " + valor1); int valor2 = multiplyCtimes(TestEmbebedFunctions.x, incrementarBucle(TestEmbebedFunctions.y), TestEmbebedFunctions.z); System.out.println("valor2 (x * sum(0..y-1) repeated z times): " + valor2); int valor3 = multiplyCtimes(TestEmbebedFunctions.x, TestEmbebedFunctions.y, incrementar(TestEmbebedFunctions.z, TestEmbebedFunctions.x)); System.out.println("valor3 (x * y repeated (z+1) times): " + valor3); int valor4 = multiplyCtimes(TestEmbebedFunctions.x, TestEmbebedFunctions.y, incrementarBucle(TestEmbebedFunctions.z)); System.out.println("valor4 (x * y repeated sum(0..z-1) times): " + valor4); } private static int multiplyCtimes(int a, int b, int c) { if (c <= 0) { return 0; } int result = b; for (int i = 1; i < c; i++) { result *= a; } return result; } private static int incrementar(int a, int b) { b++; return a + 1; } private static int incrementarBucle(int a) { if (a > 0) { int x = 0; for (int i = 0; i < a; i++) { x = x + i; } return x; } else { return a; } } } No newline at end of file
iacfg/src/test/resources/TestGlobalVariables.java 0 → 100644 +46 −0 Original line number Diff line number Diff line public class TestGlobalVariables { public static int x = 0; public static int y = 5; public static void main(String[] args) { System.out.println("Valores iniciales:"); System.out.println("x: " + TestGlobalVariables.x); System.out.println("y: " + TestGlobalVariables.y); TestGlobalVariables.x = 10; TestGlobalVariables.y = TestGlobalVariables.y + TestGlobalVariables.x; System.out.println("\nValores despues de modificar:"); System.out.println("x: " + TestGlobalVariables.x); System.out.println("y: " + TestGlobalVariables.y); while (TestGlobalVariables.x < 100) { if (TestGlobalVariables.x < 50) { System.out.println(TestGlobalVariables.x); TestGlobalVariables.x = incrementar(TestGlobalVariables.x, 0); } else { System.out.println(TestGlobalVariables.x); TestGlobalVariables.x = incrementarBucle(TestGlobalVariables.x); } } } private static int incrementar(int a, int b) { b++; return a + 1; } private static int incrementarBucle(int a) { if (a > 0) { int x = 0; for (int i = 0; i < a; i++) { x = x + i; } return x; } else { return a; } } }
iacfg/src/test/resources/Test.java→iacfg/src/test/resources/TestInicial.java +1 −1 Original line number Diff line number Diff line public class Test { public class TestInicial { public static int z = 0; Loading