From 8fb8371b7396d8bb26f1d3cbb683365f68519274 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Fri, 27 Nov 2020 09:04:36 +0100 Subject: [PATCH 1/6] setup tests with maven --- pom.xml | 6 ++++++ sdg-core/pom.xml | 13 +++++++++++++ .../test/java/es/upv/mist/slicing/SlicerTest.java | 4 +++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 05254fc..544bb59 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,12 @@ 11 + + org.apache.maven.plugins + maven-surefire-plugin + + 2.22.0 + diff --git a/sdg-core/pom.xml b/sdg-core/pom.xml index d60b2b2..efc9e87 100644 --- a/sdg-core/pom.xml +++ b/sdg-core/pom.xml @@ -17,6 +17,19 @@ 11 + + + + src/test/res + + **/*.java + **/*.java.*.criterion + **/*.java.*.sliced + + + + + com.github.javaparser diff --git a/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java b/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java index 59d43fe..6df4d1e 100644 --- a/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java +++ b/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java @@ -49,7 +49,9 @@ public class SlicerTest { } public static Arguments[] findAllFiles() throws FileNotFoundException { - Collection args = findFiles(new File(TEST_FILES), DOT_JAVA); + File testFolder = new File(Thread.currentThread().getContextClassLoader() + .getResource("dinsa-tests/").getPath()); + Collection args = findFiles(testFolder, DOT_JAVA); return args.toArray(Arguments[]::new); } -- GitLab From 132316c820f6c56de063945d3672465b2777bd3d Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Fri, 27 Nov 2020 09:42:20 +0100 Subject: [PATCH 2/6] move tests to /regression in test resources directory --- .../java/es/upv/mist/slicing/SlicerTest.java | 29 ++++++++++--------- .../res/{ => regression}/carlos/Classic.java | 0 .../res/{ => regression}/carlos/Problem1.java | 0 .../res/{ => regression}/carlos/Problem2.java | 0 .../res/{ => regression}/carlos/Problem3.java | 0 .../res/{ => regression}/carlos/Test1.java | 0 .../ltd-samples/BasicBreak.java | 0 .../ltd-samples/BasicContinue.java | 0 .../ltd-samples/BasicForeach.java | 0 .../{ => regression}/ltd-samples/BasicIf.java | 0 .../ltd-samples/BasicIfElse.java | 0 .../ltd-samples/BasicSwitch.java | 0 .../ltd-samples/BasicSwitchDefault.java | 0 .../ltd-samples/BasicSwitchNoBreak.java | 0 .../ltd-samples/Bucles_1.java | 0 .../ltd-samples/Bucles_2.java | 0 .../ltd-samples/Bucles_3.java | 0 .../ltd-samples/Bucles_4.java | 0 .../ltd-samples/Bucles_5.java | 0 .../ltd-samples/Bucles_6.java | 0 .../ltd-samples/Bucles_Josep.java | 0 .../ltd-samples/ReturnTest.java | 0 .../{ => regression}/ltd-samples/Test_1.java | 0 .../{ => regression}/ltd-samples/Test_2.java | 0 .../{ => regression}/ltd-samples/Test_3.java | 0 .../{ => regression}/ltd-samples/Test_4.java | 0 .../{ => regression}/ltd-samples/Test_5.java | 0 .../{ => regression}/ltd-samples/Test_6.java | 0 .../{ => regression}/ltd-samples/Test_7.java | 0 .../{ => regression}/ltd-samples/Test_8.java | 0 .../{ => regression}/ltd-samples/Test_9.java | 0 .../papers/Example1_Horwitz_PPDG.java | 0 .../{ => regression}/programs/WhileLoop.java | 0 .../programs/cfg/CFG_Test1.java | 0 .../programs/cfg/CFG_Test2.java | 0 .../programs/cfg/CFG_Test3.java | 0 .../programs/cfg/CFG_Test4.java | 0 .../programs/cfg/CFG_Test5.java | 0 .../{ => regression}/programs/cfg/Eval_1.java | 0 .../{ => regression}/programs/cfg/Eval_2.java | 0 .../{ => regression}/programs/cfg/Eval_3.java | 0 .../{ => regression}/programs/cfg/Eval_4.java | 0 .../programs/pdg/Example1.java | 0 .../programs/pdg/Example2.java | 0 .../programs/pdg/Example3.java | 0 .../{ => regression}/programs/pdg/Test.java | 0 .../programs/sdg/Example1.java | 0 .../programs/sdg/Example2.java | 0 .../{ => regression}/review-07-2020/P1.java | 0 .../{ => regression}/review-07-2020/P2.java | 0 .../{ => regression}/review-07-2020/P3.java | 0 .../{ => regression}/review-07-2020/P4.java | 0 .../{ => regression}/review-07-2020/P5.java | 0 .../{ => regression}/review-07-2020/P6.java | 0 54 files changed, 15 insertions(+), 14 deletions(-) rename sdg-core/src/test/res/{ => regression}/carlos/Classic.java (100%) rename sdg-core/src/test/res/{ => regression}/carlos/Problem1.java (100%) rename sdg-core/src/test/res/{ => regression}/carlos/Problem2.java (100%) rename sdg-core/src/test/res/{ => regression}/carlos/Problem3.java (100%) rename sdg-core/src/test/res/{ => regression}/carlos/Test1.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/BasicBreak.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/BasicContinue.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/BasicForeach.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/BasicIf.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/BasicIfElse.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/BasicSwitch.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/BasicSwitchDefault.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/BasicSwitchNoBreak.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Bucles_1.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Bucles_2.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Bucles_3.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Bucles_4.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Bucles_5.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Bucles_6.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Bucles_Josep.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/ReturnTest.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Test_1.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Test_2.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Test_3.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Test_4.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Test_5.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Test_6.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Test_7.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Test_8.java (100%) rename sdg-core/src/test/res/{ => regression}/ltd-samples/Test_9.java (100%) rename sdg-core/src/test/res/{ => regression}/papers/Example1_Horwitz_PPDG.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/WhileLoop.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/cfg/CFG_Test1.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/cfg/CFG_Test2.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/cfg/CFG_Test3.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/cfg/CFG_Test4.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/cfg/CFG_Test5.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/cfg/Eval_1.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/cfg/Eval_2.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/cfg/Eval_3.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/cfg/Eval_4.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/pdg/Example1.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/pdg/Example2.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/pdg/Example3.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/pdg/Test.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/sdg/Example1.java (100%) rename sdg-core/src/test/res/{ => regression}/programs/sdg/Example2.java (100%) rename sdg-core/src/test/res/{ => regression}/review-07-2020/P1.java (100%) rename sdg-core/src/test/res/{ => regression}/review-07-2020/P2.java (100%) rename sdg-core/src/test/res/{ => regression}/review-07-2020/P3.java (100%) rename sdg-core/src/test/res/{ => regression}/review-07-2020/P4.java (100%) rename sdg-core/src/test/res/{ => regression}/review-07-2020/P5.java (100%) rename sdg-core/src/test/res/{ => regression}/review-07-2020/P6.java (100%) diff --git a/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java b/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java index 6df4d1e..b7a1c9d 100644 --- a/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java +++ b/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java @@ -32,7 +32,7 @@ public class SlicerTest { StaticJavaParser.getConfiguration().setAttributeComments(false); } - private static final String TEST_FILES = "./sdg-core/src/test/res/dinsa-tests"; + private static final String TEST_PKG = "regression"; private static final String DOT_JAVA = ".java"; public static Collection findFiles(File directory, String suffix) throws FileNotFoundException { @@ -40,29 +40,30 @@ public class SlicerTest { File[] files = directory.listFiles(); if (files == null) return Collections.emptyList(); for (File f : files) { - if (f.getName().endsWith(suffix)) - res.add(Arguments.of(f, getSliceFile(f), getCriterionLine(f))); - if (f.isDirectory()) + if (f.isDirectory()) { res.addAll(findFiles(f, suffix)); + } else if (f.getName().endsWith(suffix)) { + File slice = new File(f.getParent(), f.getName() + ".sdg.sliced"); + if (!slice.isFile() || !slice.canRead()) + continue; + int criterionLine; + try (Scanner in = new Scanner(new File(f.getParent(), f.getName() + "sdg.criterion"))) { + criterionLine = in.nextInt(); + } catch (FileNotFoundException e) { + continue; + } + res.add(Arguments.of(f, slice, criterionLine)); + } } return res; } public static Arguments[] findAllFiles() throws FileNotFoundException { - File testFolder = new File(Thread.currentThread().getContextClassLoader() - .getResource("dinsa-tests/").getPath()); + File testFolder = new File(Thread.currentThread().getContextClassLoader().getResource(TEST_PKG).getPath()); Collection args = findFiles(testFolder, DOT_JAVA); return args.toArray(Arguments[]::new); } - private static File getSliceFile(File file) { - return new File(file.getParent(), file.getName() + ".sdg.sliced"); - } - - private static int getCriterionLine(File file) throws FileNotFoundException { - return new Scanner(new File(file.getParent(), file.getName() + ".sdg.criterion")).nextInt(); - } - @ParameterizedTest(name = "[{index}] {0}") @MethodSource("findAllFiles") public void sdgCompare(File source, File target, int criterionLine) throws FileNotFoundException { diff --git a/sdg-core/src/test/res/carlos/Classic.java b/sdg-core/src/test/res/regression/carlos/Classic.java similarity index 100% rename from sdg-core/src/test/res/carlos/Classic.java rename to sdg-core/src/test/res/regression/carlos/Classic.java diff --git a/sdg-core/src/test/res/carlos/Problem1.java b/sdg-core/src/test/res/regression/carlos/Problem1.java similarity index 100% rename from sdg-core/src/test/res/carlos/Problem1.java rename to sdg-core/src/test/res/regression/carlos/Problem1.java diff --git a/sdg-core/src/test/res/carlos/Problem2.java b/sdg-core/src/test/res/regression/carlos/Problem2.java similarity index 100% rename from sdg-core/src/test/res/carlos/Problem2.java rename to sdg-core/src/test/res/regression/carlos/Problem2.java diff --git a/sdg-core/src/test/res/carlos/Problem3.java b/sdg-core/src/test/res/regression/carlos/Problem3.java similarity index 100% rename from sdg-core/src/test/res/carlos/Problem3.java rename to sdg-core/src/test/res/regression/carlos/Problem3.java diff --git a/sdg-core/src/test/res/carlos/Test1.java b/sdg-core/src/test/res/regression/carlos/Test1.java similarity index 100% rename from sdg-core/src/test/res/carlos/Test1.java rename to sdg-core/src/test/res/regression/carlos/Test1.java diff --git a/sdg-core/src/test/res/ltd-samples/BasicBreak.java b/sdg-core/src/test/res/regression/ltd-samples/BasicBreak.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/BasicBreak.java rename to sdg-core/src/test/res/regression/ltd-samples/BasicBreak.java diff --git a/sdg-core/src/test/res/ltd-samples/BasicContinue.java b/sdg-core/src/test/res/regression/ltd-samples/BasicContinue.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/BasicContinue.java rename to sdg-core/src/test/res/regression/ltd-samples/BasicContinue.java diff --git a/sdg-core/src/test/res/ltd-samples/BasicForeach.java b/sdg-core/src/test/res/regression/ltd-samples/BasicForeach.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/BasicForeach.java rename to sdg-core/src/test/res/regression/ltd-samples/BasicForeach.java diff --git a/sdg-core/src/test/res/ltd-samples/BasicIf.java b/sdg-core/src/test/res/regression/ltd-samples/BasicIf.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/BasicIf.java rename to sdg-core/src/test/res/regression/ltd-samples/BasicIf.java diff --git a/sdg-core/src/test/res/ltd-samples/BasicIfElse.java b/sdg-core/src/test/res/regression/ltd-samples/BasicIfElse.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/BasicIfElse.java rename to sdg-core/src/test/res/regression/ltd-samples/BasicIfElse.java diff --git a/sdg-core/src/test/res/ltd-samples/BasicSwitch.java b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitch.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/BasicSwitch.java rename to sdg-core/src/test/res/regression/ltd-samples/BasicSwitch.java diff --git a/sdg-core/src/test/res/ltd-samples/BasicSwitchDefault.java b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchDefault.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/BasicSwitchDefault.java rename to sdg-core/src/test/res/regression/ltd-samples/BasicSwitchDefault.java diff --git a/sdg-core/src/test/res/ltd-samples/BasicSwitchNoBreak.java b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchNoBreak.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/BasicSwitchNoBreak.java rename to sdg-core/src/test/res/regression/ltd-samples/BasicSwitchNoBreak.java diff --git a/sdg-core/src/test/res/ltd-samples/Bucles_1.java b/sdg-core/src/test/res/regression/ltd-samples/Bucles_1.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Bucles_1.java rename to sdg-core/src/test/res/regression/ltd-samples/Bucles_1.java diff --git a/sdg-core/src/test/res/ltd-samples/Bucles_2.java b/sdg-core/src/test/res/regression/ltd-samples/Bucles_2.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Bucles_2.java rename to sdg-core/src/test/res/regression/ltd-samples/Bucles_2.java diff --git a/sdg-core/src/test/res/ltd-samples/Bucles_3.java b/sdg-core/src/test/res/regression/ltd-samples/Bucles_3.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Bucles_3.java rename to sdg-core/src/test/res/regression/ltd-samples/Bucles_3.java diff --git a/sdg-core/src/test/res/ltd-samples/Bucles_4.java b/sdg-core/src/test/res/regression/ltd-samples/Bucles_4.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Bucles_4.java rename to sdg-core/src/test/res/regression/ltd-samples/Bucles_4.java diff --git a/sdg-core/src/test/res/ltd-samples/Bucles_5.java b/sdg-core/src/test/res/regression/ltd-samples/Bucles_5.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Bucles_5.java rename to sdg-core/src/test/res/regression/ltd-samples/Bucles_5.java diff --git a/sdg-core/src/test/res/ltd-samples/Bucles_6.java b/sdg-core/src/test/res/regression/ltd-samples/Bucles_6.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Bucles_6.java rename to sdg-core/src/test/res/regression/ltd-samples/Bucles_6.java diff --git a/sdg-core/src/test/res/ltd-samples/Bucles_Josep.java b/sdg-core/src/test/res/regression/ltd-samples/Bucles_Josep.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Bucles_Josep.java rename to sdg-core/src/test/res/regression/ltd-samples/Bucles_Josep.java diff --git a/sdg-core/src/test/res/ltd-samples/ReturnTest.java b/sdg-core/src/test/res/regression/ltd-samples/ReturnTest.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/ReturnTest.java rename to sdg-core/src/test/res/regression/ltd-samples/ReturnTest.java diff --git a/sdg-core/src/test/res/ltd-samples/Test_1.java b/sdg-core/src/test/res/regression/ltd-samples/Test_1.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Test_1.java rename to sdg-core/src/test/res/regression/ltd-samples/Test_1.java diff --git a/sdg-core/src/test/res/ltd-samples/Test_2.java b/sdg-core/src/test/res/regression/ltd-samples/Test_2.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Test_2.java rename to sdg-core/src/test/res/regression/ltd-samples/Test_2.java diff --git a/sdg-core/src/test/res/ltd-samples/Test_3.java b/sdg-core/src/test/res/regression/ltd-samples/Test_3.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Test_3.java rename to sdg-core/src/test/res/regression/ltd-samples/Test_3.java diff --git a/sdg-core/src/test/res/ltd-samples/Test_4.java b/sdg-core/src/test/res/regression/ltd-samples/Test_4.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Test_4.java rename to sdg-core/src/test/res/regression/ltd-samples/Test_4.java diff --git a/sdg-core/src/test/res/ltd-samples/Test_5.java b/sdg-core/src/test/res/regression/ltd-samples/Test_5.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Test_5.java rename to sdg-core/src/test/res/regression/ltd-samples/Test_5.java diff --git a/sdg-core/src/test/res/ltd-samples/Test_6.java b/sdg-core/src/test/res/regression/ltd-samples/Test_6.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Test_6.java rename to sdg-core/src/test/res/regression/ltd-samples/Test_6.java diff --git a/sdg-core/src/test/res/ltd-samples/Test_7.java b/sdg-core/src/test/res/regression/ltd-samples/Test_7.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Test_7.java rename to sdg-core/src/test/res/regression/ltd-samples/Test_7.java diff --git a/sdg-core/src/test/res/ltd-samples/Test_8.java b/sdg-core/src/test/res/regression/ltd-samples/Test_8.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Test_8.java rename to sdg-core/src/test/res/regression/ltd-samples/Test_8.java diff --git a/sdg-core/src/test/res/ltd-samples/Test_9.java b/sdg-core/src/test/res/regression/ltd-samples/Test_9.java similarity index 100% rename from sdg-core/src/test/res/ltd-samples/Test_9.java rename to sdg-core/src/test/res/regression/ltd-samples/Test_9.java diff --git a/sdg-core/src/test/res/papers/Example1_Horwitz_PPDG.java b/sdg-core/src/test/res/regression/papers/Example1_Horwitz_PPDG.java similarity index 100% rename from sdg-core/src/test/res/papers/Example1_Horwitz_PPDG.java rename to sdg-core/src/test/res/regression/papers/Example1_Horwitz_PPDG.java diff --git a/sdg-core/src/test/res/programs/WhileLoop.java b/sdg-core/src/test/res/regression/programs/WhileLoop.java similarity index 100% rename from sdg-core/src/test/res/programs/WhileLoop.java rename to sdg-core/src/test/res/regression/programs/WhileLoop.java diff --git a/sdg-core/src/test/res/programs/cfg/CFG_Test1.java b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test1.java similarity index 100% rename from sdg-core/src/test/res/programs/cfg/CFG_Test1.java rename to sdg-core/src/test/res/regression/programs/cfg/CFG_Test1.java diff --git a/sdg-core/src/test/res/programs/cfg/CFG_Test2.java b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test2.java similarity index 100% rename from sdg-core/src/test/res/programs/cfg/CFG_Test2.java rename to sdg-core/src/test/res/regression/programs/cfg/CFG_Test2.java diff --git a/sdg-core/src/test/res/programs/cfg/CFG_Test3.java b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test3.java similarity index 100% rename from sdg-core/src/test/res/programs/cfg/CFG_Test3.java rename to sdg-core/src/test/res/regression/programs/cfg/CFG_Test3.java diff --git a/sdg-core/src/test/res/programs/cfg/CFG_Test4.java b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test4.java similarity index 100% rename from sdg-core/src/test/res/programs/cfg/CFG_Test4.java rename to sdg-core/src/test/res/regression/programs/cfg/CFG_Test4.java diff --git a/sdg-core/src/test/res/programs/cfg/CFG_Test5.java b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test5.java similarity index 100% rename from sdg-core/src/test/res/programs/cfg/CFG_Test5.java rename to sdg-core/src/test/res/regression/programs/cfg/CFG_Test5.java diff --git a/sdg-core/src/test/res/programs/cfg/Eval_1.java b/sdg-core/src/test/res/regression/programs/cfg/Eval_1.java similarity index 100% rename from sdg-core/src/test/res/programs/cfg/Eval_1.java rename to sdg-core/src/test/res/regression/programs/cfg/Eval_1.java diff --git a/sdg-core/src/test/res/programs/cfg/Eval_2.java b/sdg-core/src/test/res/regression/programs/cfg/Eval_2.java similarity index 100% rename from sdg-core/src/test/res/programs/cfg/Eval_2.java rename to sdg-core/src/test/res/regression/programs/cfg/Eval_2.java diff --git a/sdg-core/src/test/res/programs/cfg/Eval_3.java b/sdg-core/src/test/res/regression/programs/cfg/Eval_3.java similarity index 100% rename from sdg-core/src/test/res/programs/cfg/Eval_3.java rename to sdg-core/src/test/res/regression/programs/cfg/Eval_3.java diff --git a/sdg-core/src/test/res/programs/cfg/Eval_4.java b/sdg-core/src/test/res/regression/programs/cfg/Eval_4.java similarity index 100% rename from sdg-core/src/test/res/programs/cfg/Eval_4.java rename to sdg-core/src/test/res/regression/programs/cfg/Eval_4.java diff --git a/sdg-core/src/test/res/programs/pdg/Example1.java b/sdg-core/src/test/res/regression/programs/pdg/Example1.java similarity index 100% rename from sdg-core/src/test/res/programs/pdg/Example1.java rename to sdg-core/src/test/res/regression/programs/pdg/Example1.java diff --git a/sdg-core/src/test/res/programs/pdg/Example2.java b/sdg-core/src/test/res/regression/programs/pdg/Example2.java similarity index 100% rename from sdg-core/src/test/res/programs/pdg/Example2.java rename to sdg-core/src/test/res/regression/programs/pdg/Example2.java diff --git a/sdg-core/src/test/res/programs/pdg/Example3.java b/sdg-core/src/test/res/regression/programs/pdg/Example3.java similarity index 100% rename from sdg-core/src/test/res/programs/pdg/Example3.java rename to sdg-core/src/test/res/regression/programs/pdg/Example3.java diff --git a/sdg-core/src/test/res/programs/pdg/Test.java b/sdg-core/src/test/res/regression/programs/pdg/Test.java similarity index 100% rename from sdg-core/src/test/res/programs/pdg/Test.java rename to sdg-core/src/test/res/regression/programs/pdg/Test.java diff --git a/sdg-core/src/test/res/programs/sdg/Example1.java b/sdg-core/src/test/res/regression/programs/sdg/Example1.java similarity index 100% rename from sdg-core/src/test/res/programs/sdg/Example1.java rename to sdg-core/src/test/res/regression/programs/sdg/Example1.java diff --git a/sdg-core/src/test/res/programs/sdg/Example2.java b/sdg-core/src/test/res/regression/programs/sdg/Example2.java similarity index 100% rename from sdg-core/src/test/res/programs/sdg/Example2.java rename to sdg-core/src/test/res/regression/programs/sdg/Example2.java diff --git a/sdg-core/src/test/res/review-07-2020/P1.java b/sdg-core/src/test/res/regression/review-07-2020/P1.java similarity index 100% rename from sdg-core/src/test/res/review-07-2020/P1.java rename to sdg-core/src/test/res/regression/review-07-2020/P1.java diff --git a/sdg-core/src/test/res/review-07-2020/P2.java b/sdg-core/src/test/res/regression/review-07-2020/P2.java similarity index 100% rename from sdg-core/src/test/res/review-07-2020/P2.java rename to sdg-core/src/test/res/regression/review-07-2020/P2.java diff --git a/sdg-core/src/test/res/review-07-2020/P3.java b/sdg-core/src/test/res/regression/review-07-2020/P3.java similarity index 100% rename from sdg-core/src/test/res/review-07-2020/P3.java rename to sdg-core/src/test/res/regression/review-07-2020/P3.java diff --git a/sdg-core/src/test/res/review-07-2020/P4.java b/sdg-core/src/test/res/regression/review-07-2020/P4.java similarity index 100% rename from sdg-core/src/test/res/review-07-2020/P4.java rename to sdg-core/src/test/res/regression/review-07-2020/P4.java diff --git a/sdg-core/src/test/res/review-07-2020/P5.java b/sdg-core/src/test/res/regression/review-07-2020/P5.java similarity index 100% rename from sdg-core/src/test/res/review-07-2020/P5.java rename to sdg-core/src/test/res/regression/review-07-2020/P5.java diff --git a/sdg-core/src/test/res/review-07-2020/P6.java b/sdg-core/src/test/res/regression/review-07-2020/P6.java similarity index 100% rename from sdg-core/src/test/res/review-07-2020/P6.java rename to sdg-core/src/test/res/regression/review-07-2020/P6.java -- GitLab From af492b3fa5dba7fd5170b1edc51d78b2a081ffaa Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Thu, 10 Dec 2020 14:45:43 +0100 Subject: [PATCH 3/6] improve test generation --- pom.xml | 2 +- .../java/es/upv/mist/slicing/SlicerTest.java | 162 +++++++++++++----- .../papers/Example1_Horwitz_PPDG.java | 8 - 3 files changed, 117 insertions(+), 55 deletions(-) delete mode 100644 sdg-core/src/test/res/regression/papers/Example1_Horwitz_PPDG.java diff --git a/pom.xml b/pom.xml index 544bb59..536544f 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.0 + 3.0.0-M5 diff --git a/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java b/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java index b7a1c9d..b64918b 100644 --- a/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java +++ b/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java @@ -11,6 +11,7 @@ import es.upv.mist.slicing.graphs.sdg.SDG; import es.upv.mist.slicing.slicing.FileLineSlicingCriterion; import es.upv.mist.slicing.slicing.Slice; import es.upv.mist.slicing.slicing.SlicingCriterion; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -18,10 +19,9 @@ import org.junit.jupiter.params.provider.MethodSource; import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.Scanner; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Supplier; public class SlicerTest { static { @@ -34,64 +34,134 @@ public class SlicerTest { private static final String TEST_PKG = "regression"; private static final String DOT_JAVA = ".java"; + private static final String SDG_CRITERION = ".sdg.criterion"; + private static final String SDG_SLICE = ".sdg.sliced"; - public static Collection findFiles(File directory, String suffix) throws FileNotFoundException { - Collection res = new LinkedList<>(); + public static void findFiles(File directory, String suffix, Consumer consumer) { File[] files = directory.listFiles(); - if (files == null) return Collections.emptyList(); + if (files == null) + return; for (File f : files) { - if (f.isDirectory()) { - res.addAll(findFiles(f, suffix)); - } else if (f.getName().endsWith(suffix)) { - File slice = new File(f.getParent(), f.getName() + ".sdg.sliced"); - if (!slice.isFile() || !slice.canRead()) - continue; - int criterionLine; - try (Scanner in = new Scanner(new File(f.getParent(), f.getName() + "sdg.criterion"))) { - criterionLine = in.nextInt(); - } catch (FileNotFoundException e) { - continue; - } - res.add(Arguments.of(f, slice, criterionLine)); - } + if (f.isDirectory()) + findFiles(f, suffix, consumer); + else if (f.getName().endsWith(suffix)) + consumer.accept(f); } - return res; } - public static Arguments[] findAllFiles() throws FileNotFoundException { + public static Arguments[] findAllFiles() { + Collection args = new LinkedList<>(); File testFolder = new File(Thread.currentThread().getContextClassLoader().getResource(TEST_PKG).getPath()); - Collection args = findFiles(testFolder, DOT_JAVA); + findFiles(testFolder, DOT_JAVA, f -> createArgumentForTest(f).ifPresent(args::add)); return args.toArray(Arguments[]::new); } + private static Optional createArgumentForTest(File javaFile) { + File slice = new File(javaFile.getParent(), javaFile.getName() + SDG_SLICE); + Optional criterion = findSDGCriterion(javaFile); + if (!slice.isFile() || !slice.canRead() || criterion.isEmpty()) + return Optional.empty(); + return Optional.of(Arguments.of(javaFile, slice, criterion.get())); + } + @ParameterizedTest(name = "[{index}] {0}") @MethodSource("findAllFiles") - public void sdgCompare(File source, File target, int criterionLine) throws FileNotFoundException { - // Build the SDG - SDG sdg = new ESSDG(); - sdg.build(new NodeList<>(StaticJavaParser.parse(source))); - SlicingCriterion sc = new FileLineSlicingCriterion(source, criterionLine); - Slice slice = sdg.slice(sc); - - // Convert the slice to code and output the result to `outputDir` - NodeList slicedUnits = slice.toAst(); - assert slicedUnits.size() == 1; - if (!target.exists()) { - try (PrintWriter pw = new PrintWriter(target)) { - pw.print(slicedUnits.get(0).toString()); - } + public void slicerRegressionTest(File source, File target, SlicingCriterion sc) throws FileNotFoundException { + if (!target.exists()) return; + Slice slice = slice(source ,sc); + boolean equal = slicesMatch(slice, target); + assert equal: "The slice for " + source.toString() + " has change, please fix the error or update the reference slice."; + } + + @Test + public void generateDefaultSlices() { + File testFolder = new File("./sdg-core/src/test/res/", TEST_PKG); + findFiles(testFolder, DOT_JAVA, SlicerTest::createAndSaveSlice); + } + + private static Optional findSDGCriterion(File javaFile) { + File criterionFile = new File(javaFile.getParentFile(), javaFile.getName() + SDG_CRITERION); + try (Scanner in = new Scanner(criterionFile)) { + return Optional.of(new FileLineSlicingCriterion(javaFile, in.nextInt())); + } catch (FileNotFoundException | NoSuchElementException e) { + return Optional.empty(); } - String targetSlice; - { + } + + private static void createAndSaveSlice(File javaFile) { + try { + File sliceFile = new File(javaFile.getParent(), javaFile.getName() + SDG_SLICE); + Optional sc = findSDGCriterion(javaFile); + if (sc.isEmpty() || sliceFile.exists()) + return; + Slice slice = slice(javaFile, sc.get()); + var cus = slice.toAst(); + assert cus.size() == 1; + try (PrintWriter pw = new PrintWriter(sliceFile)) { + pw.write(cus.getFirst().get().toString()); + } + } catch (FileNotFoundException e) { + System.err.println("Could not save slice due to missing file or permissions"); + } catch (Exception e) { + System.err.println("Error generating slice for " + javaFile.toString()); + System.err.println(e.getMessage()); + e.printStackTrace(); + } + } + + private static boolean slicesMatch(Slice slice, File referenceSlice) { + NodeList cus = slice.toAst(); + assert cus.size() == 1; + return Objects.equals(cus.getFirst().get().toString(), readFile(referenceSlice)); + } + + private static String readFile(File file, Supplier separator) { + try (Scanner in = new Scanner(file)) { StringBuilder builder = new StringBuilder(); - Scanner in = new Scanner(target); while (in.hasNextLine()) - builder.append(in.nextLine()).append('\n'); - targetSlice = builder.toString(); + builder.append(in.nextLine()).append(separator.get()); + return builder.toString(); + } catch (FileNotFoundException e) { + return ""; } - String ourSlice = slicedUnits.get(0).toString(); - boolean equal = targetSlice.equals(ourSlice); - assert equal; + } + + private static String readFile(File file) { + return readFile(file, () -> "\n"); + } + + private static Slice slice(File javaFile, SlicingCriterion sc) throws FileNotFoundException { + SDG sdg = new ESSDG(); + sdg.build(new NodeList<>(StaticJavaParser.parse(javaFile))); + return sdg.slice(sc); + } + + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + File testFolder = new File("./sdg-core/src/test/res/", TEST_PKG); + findFiles(testFolder, DOT_JAVA, file -> { + File sliceFile = new File(file.getParent(), file.getName() + SDG_CRITERION); + if (!sliceFile.exists()) { + int[] counter = new int[] { 1 }; + System.out.printf("%3d", counter[0]++); + System.out.print(readFile(file, () -> String.format("\n%3d", counter[0]++))); + System.out.printf("No criterion found for this program (%s), please input one (-1 to skip)\nCriterion: ", file); + int line = in.nextInt(); + if (line == -1) + return; + while (line <= 0 || line >= counter[0] - 2) { + System.out.printf("Your input is out-of-bounds, please try again [1-%d]: ", counter[0] - 2); + line = in.nextInt(); + } + System.out.printf("Saving line %d as slicing criterion for %s... ", line, file); + try (PrintWriter pw = new PrintWriter(sliceFile)) { + pw.write(line + ""); + System.out.println("DONE"); + } catch (FileNotFoundException e) { + System.out.println("ERROR"); + } + } + }); } } diff --git a/sdg-core/src/test/res/regression/papers/Example1_Horwitz_PPDG.java b/sdg-core/src/test/res/regression/papers/Example1_Horwitz_PPDG.java deleted file mode 100644 index da381ff..0000000 --- a/sdg-core/src/test/res/regression/papers/Example1_Horwitz_PPDG.java +++ /dev/null @@ -1,8 +0,0 @@ -public class Test { - public static void main(String[] args) { - switch (X) { - case e1: - - } - } -} \ No newline at end of file -- GitLab From f967bdb7bbabb4b12b6c02ca9b7f0b0b697f40d0 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Tue, 15 Dec 2020 19:19:01 +0100 Subject: [PATCH 4/6] Add test cases and their initial reference answer --- .../java/es/upv/mist/slicing/SlicerTest.java | 2 +- .../test/res/regression/carlos/Classic.java | 4 +- .../carlos/Classic.java.sdg.criterion | 1 + .../regression/carlos/Classic.java.sdg.sliced | 12 ++++ .../test/res/regression/carlos/Problem1.java | 10 ++-- .../carlos/Problem1.java.sdg.criterion | 1 + .../carlos/Problem1.java.sdg.sliced | 6 ++ .../carlos/Problem2.java.sdg.criterion | 1 + .../carlos/Problem2.java.sdg.sliced | 7 +++ .../carlos/Problem3.java.sdg.criterion | 1 + .../carlos/Problem3.java.sdg.sliced | 13 ++++ .../carlos/Test1.java.sdg.criterion | 1 + .../regression/carlos/Test1.java.sdg.sliced | 6 ++ .../test/res/regression/carlos/TestJosep.java | 43 +++++++++++++ .../carlos/TestJosep.java.sdg.criterion | 1 + .../carlos/TestJosep.java.sdg.sliced | 6 ++ .../res/regression/dinsa-tests/Carlos1.java | 51 ++++++++++++++++ .../dinsa-tests/Carlos1.java.sdg.criterion | 1 + .../dinsa-tests/Carlos1.java.sdg.sliced | 12 ++++ .../res/regression/dinsa-tests/Carlos2.java | 47 +++++++++++++++ .../dinsa-tests/Carlos2.java.sdg.criterion | 1 + .../dinsa-tests/Carlos2.java.sdg.sliced | 34 +++++++++++ .../res/regression/dinsa-tests/Josep.java | 49 +++++++++++++++ .../dinsa-tests/Josep.java.sdg.criterion | 1 + .../dinsa-tests/Josep.java.sdg.sliced | 37 ++++++++++++ .../res/regression/dinsa-tests/Josep2.java | 50 ++++++++++++++++ .../dinsa-tests/Josep2.java.sdg.criterion | 1 + .../dinsa-tests/Josep2.java.sdg.sliced | 38 ++++++++++++ .../res/regression/dinsa-tests/Josep3.java | 18 ++++++ .../dinsa-tests/Josep3.java.sdg.criterion | 1 + .../dinsa-tests/Josep3.java.sdg.sliced | 12 ++++ .../res/regression/dinsa-tests/Josep4.java | 22 +++++++ .../dinsa-tests/Josep4.java.sdg.criterion | 1 + .../dinsa-tests/Josep4.java.sdg.sliced | 16 +++++ .../res/regression/dinsa-tests/Josep5.java | 40 +++++++++++++ .../dinsa-tests/Josep5.java.sdg.criterion | 1 + .../dinsa-tests/Josep5.java.sdg.sliced | 27 +++++++++ .../res/regression/dinsa-tests/Josep6.java | 60 +++++++++++++++++++ .../dinsa-tests/Josep6.java.sdg.criterion | 1 + .../dinsa-tests/Josep6.java.sdg.sliced | 26 ++++++++ .../res/regression/dinsa-tests/Josep7.java | 46 ++++++++++++++ .../dinsa-tests/Josep7.java.sdg.criterion | 1 + .../dinsa-tests/Josep7.java.sdg.sliced | 25 ++++++++ .../res/regression/dinsa-tests/Josep8.java | 46 ++++++++++++++ .../dinsa-tests/Josep8.java.sdg.criterion | 1 + .../dinsa-tests/Josep8.java.sdg.sliced | 25 ++++++++ .../res/regression/dinsa-tests/Josep9.java | 31 ++++++++++ .../dinsa-tests/Josep9.java.sdg.criterion | 1 + .../dinsa-tests/Josep9.java.sdg.sliced | 20 +++++++ .../ltd-samples/BasicBreak.java.sdg.criterion | 1 + .../ltd-samples/BasicBreak.java.sdg.sliced | 14 +++++ .../BasicContinue.java.sdg.criterion | 1 + .../ltd-samples/BasicContinue.java.sdg.sliced | 14 +++++ .../BasicForeach.java.sdg.criterion | 1 + .../ltd-samples/BasicForeach.java.sdg.sliced | 9 +++ .../ltd-samples/BasicIf.java.sdg.criterion | 1 + .../ltd-samples/BasicIf.java.sdg.sliced | 11 ++++ .../BasicIfElse.java.sdg.criterion | 1 + .../ltd-samples/BasicIfElse.java.sdg.sliced | 19 ++++++ .../BasicSwitch.java.sdg.criterion | 1 + .../ltd-samples/BasicSwitch.java.sdg.sliced | 28 +++++++++ .../BasicSwitchDefault.java.sdg.criterion | 1 + .../BasicSwitchDefault.java.sdg.sliced | 24 ++++++++ .../BasicSwitchNoBreak.java.sdg.criterion | 1 + .../BasicSwitchNoBreak.java.sdg.sliced | 15 +++++ .../ltd-samples/Bucles_1.java.sdg.criterion | 1 + .../ltd-samples/Bucles_1.java.sdg.sliced | 11 ++++ .../ltd-samples/Bucles_2.java.sdg.criterion | 1 + .../ltd-samples/Bucles_2.java.sdg.sliced | 11 ++++ .../ltd-samples/Bucles_3.java.sdg.criterion | 1 + .../ltd-samples/Bucles_3.java.sdg.sliced | 13 ++++ .../ltd-samples/Bucles_4.java.sdg.criterion | 1 + .../ltd-samples/Bucles_4.java.sdg.sliced | 14 +++++ .../ltd-samples/Bucles_5.java.sdg.criterion | 1 + .../ltd-samples/Bucles_5.java.sdg.sliced | 13 ++++ .../ltd-samples/Bucles_6.java.sdg.criterion | 1 + .../ltd-samples/Bucles_6.java.sdg.sliced | 17 ++++++ .../Bucles_Josep.java.sdg.criterion | 1 + .../ltd-samples/Bucles_Josep.java.sdg.sliced | 10 ++++ .../ltd-samples/ReturnTest.java.sdg.criterion | 1 + .../ltd-samples/ReturnTest.java.sdg.sliced | 10 ++++ .../ltd-samples/Test_1.java.sdg.criterion | 1 + .../ltd-samples/Test_1.java.sdg.sliced | 9 +++ .../ltd-samples/Test_2.java.sdg.criterion | 1 + .../ltd-samples/Test_2.java.sdg.sliced | 11 ++++ .../ltd-samples/Test_3.java.sdg.criterion | 1 + .../ltd-samples/Test_3.java.sdg.sliced | 9 +++ .../ltd-samples/Test_4.java.sdg.criterion | 1 + .../ltd-samples/Test_4.java.sdg.sliced | 14 +++++ .../ltd-samples/Test_5.java.sdg.criterion | 1 + .../ltd-samples/Test_5.java.sdg.sliced | 14 +++++ .../ltd-samples/Test_6.java.sdg.criterion | 1 + .../ltd-samples/Test_6.java.sdg.sliced | 12 ++++ .../ltd-samples/Test_7.java.sdg.criterion | 1 + .../ltd-samples/Test_7.java.sdg.sliced | 12 ++++ .../ltd-samples/Test_8.java.sdg.criterion | 1 + .../ltd-samples/Test_8.java.sdg.sliced | 14 +++++ .../ltd-samples/Test_9.java.sdg.criterion | 1 + .../ltd-samples/Test_9.java.sdg.sliced | 28 +++++++++ .../programs/WhileLoop.java.sdg.criterion | 1 + .../programs/WhileLoop.java.sdg.sliced | 16 +++++ .../programs/cfg/CFG_Test2.java.sdg.criterion | 1 + ...G_Test1.java => CFG_Test2.java.sdg.sliced} | 7 ++- .../programs/cfg/CFG_Test3.java.sdg.criterion | 1 + .../programs/cfg/CFG_Test3.java.sdg.sliced | 8 +++ .../programs/cfg/CFG_Test4.java.sdg.criterion | 1 + .../programs/cfg/CFG_Test4.java.sdg.sliced | 12 ++++ .../programs/cfg/CFG_Test5.java.sdg.criterion | 1 + .../programs/cfg/CFG_Test5.java.sdg.sliced | 10 ++++ .../res/regression/programs/cfg/Eval_1.java | 2 +- .../programs/cfg/Eval_1.java.sdg.criterion | 1 + .../programs/cfg/Eval_1.java.sdg.sliced | 38 ++++++++++++ .../programs/cfg/Eval_2.java.sdg.criterion | 1 + .../programs/cfg/Eval_2.java.sdg.sliced | 9 +++ .../programs/cfg/Eval_3.java.sdg.criterion | 1 + .../programs/cfg/Eval_3.java.sdg.sliced | 8 +++ .../programs/cfg/Eval_4.java.sdg.criterion | 1 + .../programs/cfg/Eval_4.java.sdg.sliced | 18 ++++++ .../res/regression/programs/pdg/Example1.java | 4 +- .../programs/pdg/Example1.java.sdg.criterion | 1 + .../programs/pdg/Example1.java.sdg.sliced | 36 +++++++++++ .../res/regression/programs/pdg/Example2.java | 2 +- .../programs/pdg/Example2.java.sdg.criterion | 1 + .../programs/pdg/Example2.java.sdg.sliced | 16 +++++ .../res/regression/programs/pdg/Example3.java | 4 +- .../programs/pdg/Example3.java.sdg.criterion | 1 + .../programs/pdg/Example3.java.sdg.sliced | 17 ++++++ .../programs/pdg/Test.java.sdg.criterion | 1 + .../programs/pdg/Test.java.sdg.sliced | 9 +++ .../programs/sdg/Example1.java.sdg.criterion | 1 + .../programs/sdg/Example1.java.sdg.sliced | 16 +++++ .../programs/sdg/Example2.java.sdg.criterion | 1 + .../review-07-2020/P1.java.sdg.criterion | 1 + .../review-07-2020/P1.java.sdg.sliced | 24 ++++++++ .../review-07-2020/P2.java.sdg.criterion | 1 + .../review-07-2020/P2.java.sdg.sliced | 8 +++ .../review-07-2020/P3.java.sdg.criterion | 1 + .../review-07-2020/P3.java.sdg.sliced | 12 ++++ .../review-07-2020/P4.java.sdg.criterion | 1 + .../review-07-2020/P4.java.sdg.sliced | 12 ++++ .../review-07-2020/P5.java.sdg.criterion | 1 + .../review-07-2020/P5.java.sdg.sliced | 38 ++++++++++++ .../review-07-2020/P6.java.sdg.criterion | 1 + .../review-07-2020/P6.java.sdg.sliced | 17 ++++++ 144 files changed, 1587 insertions(+), 16 deletions(-) create mode 100644 sdg-core/src/test/res/regression/carlos/Classic.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/carlos/Classic.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/carlos/Problem1.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/carlos/Problem1.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/carlos/Problem2.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/carlos/Problem2.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/carlos/Problem3.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/carlos/Problem3.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/carlos/Test1.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/carlos/Test1.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/carlos/TestJosep.java create mode 100644 sdg-core/src/test/res/regression/carlos/TestJosep.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/carlos/TestJosep.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Carlos1.java create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Carlos1.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Carlos1.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Carlos2.java create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Carlos2.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Carlos2.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep.java create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep2.java create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep2.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep2.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep3.java create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep3.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep3.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep4.java create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep4.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep4.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep5.java create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep5.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep5.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep6.java create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep6.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep6.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep7.java create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep7.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep7.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep8.java create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep8.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep8.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep9.java create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep9.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/dinsa-tests/Josep9.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicBreak.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicBreak.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicContinue.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicContinue.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicForeach.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicForeach.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicIf.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicIf.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicIfElse.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicIfElse.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicSwitch.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicSwitch.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicSwitchDefault.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicSwitchDefault.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicSwitchNoBreak.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/BasicSwitchNoBreak.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_1.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_1.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_2.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_2.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_3.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_3.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_4.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_4.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_5.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_5.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_6.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_6.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_Josep.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Bucles_Josep.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/ReturnTest.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/ReturnTest.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_1.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_1.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_2.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_2.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_3.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_3.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_4.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_4.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_5.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_5.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_6.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_6.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_7.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_7.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_8.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_8.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_9.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/ltd-samples/Test_9.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/WhileLoop.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/WhileLoop.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/cfg/CFG_Test2.java.sdg.criterion rename sdg-core/src/test/res/regression/programs/cfg/{CFG_Test1.java => CFG_Test2.java.sdg.sliced} (53%) create mode 100644 sdg-core/src/test/res/regression/programs/cfg/CFG_Test3.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/cfg/CFG_Test3.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/cfg/CFG_Test4.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/cfg/CFG_Test4.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/cfg/CFG_Test5.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/cfg/CFG_Test5.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/cfg/Eval_1.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/cfg/Eval_1.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/cfg/Eval_2.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/cfg/Eval_2.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/cfg/Eval_3.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/cfg/Eval_3.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/cfg/Eval_4.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/cfg/Eval_4.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/pdg/Example1.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/pdg/Example1.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/pdg/Example2.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/pdg/Example2.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/pdg/Example3.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/pdg/Example3.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/pdg/Test.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/pdg/Test.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/sdg/Example1.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/programs/sdg/Example1.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/programs/sdg/Example2.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/review-07-2020/P1.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/review-07-2020/P1.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/review-07-2020/P2.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/review-07-2020/P2.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/review-07-2020/P3.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/review-07-2020/P3.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/review-07-2020/P4.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/review-07-2020/P4.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/review-07-2020/P5.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/review-07-2020/P5.java.sdg.sliced create mode 100644 sdg-core/src/test/res/regression/review-07-2020/P6.java.sdg.criterion create mode 100644 sdg-core/src/test/res/regression/review-07-2020/P6.java.sdg.sliced diff --git a/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java b/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java index b64918b..1d03298 100644 --- a/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java +++ b/sdg-core/src/test/java/es/upv/mist/slicing/SlicerTest.java @@ -71,7 +71,7 @@ public class SlicerTest { return; Slice slice = slice(source ,sc); boolean equal = slicesMatch(slice, target); - assert equal: "The slice for " + source.toString() + " has change, please fix the error or update the reference slice."; + assert equal: "The slice for " + source.toString() + " has changed, please fix the error or update the reference slice."; } @Test diff --git a/sdg-core/src/test/res/regression/carlos/Classic.java b/sdg-core/src/test/res/regression/carlos/Classic.java index 4b062ad..074070f 100644 --- a/sdg-core/src/test/res/regression/carlos/Classic.java +++ b/sdg-core/src/test/res/regression/carlos/Classic.java @@ -1,3 +1,5 @@ +import java.util.Scanner; + public class Classic { public static void main(String[] args) { int sum = 0; @@ -18,7 +20,7 @@ public class Classic { int chars = 1; String subtext = ""; int i = 0; - while (i < text.size()) { + while (i < text.length()) { char c = text.charAt(i); if (c == '\n') { lines += 1; diff --git a/sdg-core/src/test/res/regression/carlos/Classic.java.sdg.criterion b/sdg-core/src/test/res/regression/carlos/Classic.java.sdg.criterion new file mode 100644 index 0000000..b1bd38b --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/Classic.java.sdg.criterion @@ -0,0 +1 @@ +13 diff --git a/sdg-core/src/test/res/regression/carlos/Classic.java.sdg.sliced b/sdg-core/src/test/res/regression/carlos/Classic.java.sdg.sliced new file mode 100644 index 0000000..b1cec7b --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/Classic.java.sdg.sliced @@ -0,0 +1,12 @@ +import java.util.Scanner; + +public class Classic { + + public static void main(String[] args) { + int product = 1; + for (int i = 1; i < N; i++) { + product *= i; + } + System.out.println(product); + } +} diff --git a/sdg-core/src/test/res/regression/carlos/Problem1.java b/sdg-core/src/test/res/regression/carlos/Problem1.java index 7260874..925a4e8 100644 --- a/sdg-core/src/test/res/regression/carlos/Problem1.java +++ b/sdg-core/src/test/res/regression/carlos/Problem1.java @@ -3,14 +3,14 @@ public class Problem1 { while (X) { if (Y) { if (Z) { - A(); + System.out.println("A"); break; } - B(); + System.out.println("B"); break; } - C(); + System.out.println("C"); } - D(); + System.out.println("D"); } -} \ No newline at end of file +} diff --git a/sdg-core/src/test/res/regression/carlos/Problem1.java.sdg.criterion b/sdg-core/src/test/res/regression/carlos/Problem1.java.sdg.criterion new file mode 100644 index 0000000..da2d398 --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/Problem1.java.sdg.criterion @@ -0,0 +1 @@ +14 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/carlos/Problem1.java.sdg.sliced b/sdg-core/src/test/res/regression/carlos/Problem1.java.sdg.sliced new file mode 100644 index 0000000..624bb93 --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/Problem1.java.sdg.sliced @@ -0,0 +1,6 @@ +public class Problem1 { + + public static void main(String[] args) { + System.out.println("D"); + } +} diff --git a/sdg-core/src/test/res/regression/carlos/Problem2.java.sdg.criterion b/sdg-core/src/test/res/regression/carlos/Problem2.java.sdg.criterion new file mode 100644 index 0000000..f11c82a --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/Problem2.java.sdg.criterion @@ -0,0 +1 @@ +9 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/carlos/Problem2.java.sdg.sliced b/sdg-core/src/test/res/regression/carlos/Problem2.java.sdg.sliced new file mode 100644 index 0000000..369ed03 --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/Problem2.java.sdg.sliced @@ -0,0 +1,7 @@ +public class Problem2 { + + public static void main(String[] args) { + int a = 0; + System.out.println(a); + } +} diff --git a/sdg-core/src/test/res/regression/carlos/Problem3.java.sdg.criterion b/sdg-core/src/test/res/regression/carlos/Problem3.java.sdg.criterion new file mode 100644 index 0000000..25bf17f --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/Problem3.java.sdg.criterion @@ -0,0 +1 @@ +18 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/carlos/Problem3.java.sdg.sliced b/sdg-core/src/test/res/regression/carlos/Problem3.java.sdg.sliced new file mode 100644 index 0000000..4fadd2b --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/Problem3.java.sdg.sliced @@ -0,0 +1,13 @@ +public class Problem3 { + + public static void main() throws Exception { + x = 0; + f(); + } + + public static void f() throws Exception { + if (x % 2 == 0) + throw new Exception("error!"); + System.out.println("x = " + x); + } +} diff --git a/sdg-core/src/test/res/regression/carlos/Test1.java.sdg.criterion b/sdg-core/src/test/res/regression/carlos/Test1.java.sdg.criterion new file mode 100644 index 0000000..62f9457 --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/Test1.java.sdg.criterion @@ -0,0 +1 @@ +6 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/carlos/Test1.java.sdg.sliced b/sdg-core/src/test/res/regression/carlos/Test1.java.sdg.sliced new file mode 100644 index 0000000..c45927c --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/Test1.java.sdg.sliced @@ -0,0 +1,6 @@ +public class Test1 { + + public static void main(String[] args) { + System.out.println(true); + } +} diff --git a/sdg-core/src/test/res/regression/carlos/TestJosep.java b/sdg-core/src/test/res/regression/carlos/TestJosep.java new file mode 100644 index 0000000..518eba5 --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/TestJosep.java @@ -0,0 +1,43 @@ +public class TestJosep { + int x = 0; + public static void main(int y) { + int z = 0; + while (y > z) { + y--; + if (x > 10) { + log(x); + } else { + log(z); + } + + } + switch (z) { + case 1: + x--; + break; + case 2: + x++; + default: + log(x); + break; + case 3: + y = x + z; + break; + } + log(x); + log(y); + log(z); + } + + public void objetos() { + Object o = new Object(); + o.x = 10; + Object y = new Object(); + y.z = 210; + o = y; + log(o); + log(y); + } + + public void log(Object o) {} +} diff --git a/sdg-core/src/test/res/regression/carlos/TestJosep.java.sdg.criterion b/sdg-core/src/test/res/regression/carlos/TestJosep.java.sdg.criterion new file mode 100644 index 0000000..d99e90e --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/TestJosep.java.sdg.criterion @@ -0,0 +1 @@ +29 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/carlos/TestJosep.java.sdg.sliced b/sdg-core/src/test/res/regression/carlos/TestJosep.java.sdg.sliced new file mode 100644 index 0000000..da134e6 --- /dev/null +++ b/sdg-core/src/test/res/regression/carlos/TestJosep.java.sdg.sliced @@ -0,0 +1,6 @@ +public class TestJosep { + + public static void main(int y) { + log(z); + } +} diff --git a/sdg-core/src/test/res/regression/dinsa-tests/Carlos1.java b/sdg-core/src/test/res/regression/dinsa-tests/Carlos1.java new file mode 100644 index 0000000..545396d --- /dev/null +++ b/sdg-core/src/test/res/regression/dinsa-tests/Carlos1.java @@ -0,0 +1,51 @@ +class A{ + +public static void main(String[] args){ + + int x = 0; + + try { + if (x==0) + { + throw generadorExcepciones(2); + } + else throw generadorExcepciones(2); + } + catch(Exception3 eb) {System.out.println("Capturada Exception3");} + catch(Exception2 ea) {System.out.println("Capturada Exception2");} + catch(Exception e) {System.out.println("Capturada Exception");} + + int SC = 42; +} + + + +static Exception generadorExcepciones(int x){ + Exception e1 = new Exception(); + Exception2 e2 = new Exception2(); + Exception3 e3 = new Exception3(); + + switch (x) { + case 1: return e1; + case 2: return e2; + case 3: return e3; + } + return e1; +} +} + +class Exception2 extends Exception{ + + /** + * + */ + private static final long serialVersionUID = 1L; +} + +class Exception3 extends Exception2{ + +/** + * + */ + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/dinsa-tests/Carlos1.java.sdg.criterion b/sdg-core/src/test/res/regression/dinsa-tests/Carlos1.java.sdg.criterion new file mode 100644 index 0000000..3c03207 --- /dev/null +++ b/sdg-core/src/test/res/regression/dinsa-tests/Carlos1.java.sdg.criterion @@ -0,0 +1 @@ +18 diff --git a/sdg-core/src/test/res/regression/dinsa-tests/Carlos1.java.sdg.sliced b/sdg-core/src/test/res/regression/dinsa-tests/Carlos1.java.sdg.sliced new file mode 100644 index 0000000..18cd2cc --- /dev/null +++ b/sdg-core/src/test/res/regression/dinsa-tests/Carlos1.java.sdg.sliced @@ -0,0 +1,12 @@ +class A { + + public static void main(String[] args) { + int SC = 42; + } +} + +class Exception2 extends Exception { +} + +class Exception3 extends Exception2 { +} diff --git a/sdg-core/src/test/res/regression/dinsa-tests/Carlos2.java b/sdg-core/src/test/res/regression/dinsa-tests/Carlos2.java new file mode 100644 index 0000000..04e5792 --- /dev/null +++ b/sdg-core/src/test/res/regression/dinsa-tests/Carlos2.java @@ -0,0 +1,47 @@ +class A{ + +public static void main(String[] args){ + + try { + + try { + throw generadorExcepciones(2); + } + catch(Exception3 eb) {System.out.println("Capturada Exception3");} + catch(Exception2 ea) {System.out.println("Capturada Exception2");} + //catch(Exception e) {System.out.println("Capturada Exception");} + + int SC = 42; + + } catch(Exception e) {System.out.println("Capturada Exception");} +} + +static Exception generadorExcepciones(int x){ + Exception e1 = new Exception(); + Exception2 e2 = new Exception2(); + Exception3 e3 = new Exception3(); + + switch (x) { + case 1: return e1; + case 2: return e2; + case 3: return e3; + } + return e1; +} +} + +class Exception2 extends Exception{ + + /** + * + */ + private static final long serialVersionUID = 1L; +} + +class Exception3 extends Exception2{ + +/** + * + */ + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/dinsa-tests/Carlos2.java.sdg.criterion b/sdg-core/src/test/res/regression/dinsa-tests/Carlos2.java.sdg.criterion new file mode 100644 index 0000000..8351c19 --- /dev/null +++ b/sdg-core/src/test/res/regression/dinsa-tests/Carlos2.java.sdg.criterion @@ -0,0 +1 @@ +14 diff --git a/sdg-core/src/test/res/regression/dinsa-tests/Carlos2.java.sdg.sliced b/sdg-core/src/test/res/regression/dinsa-tests/Carlos2.java.sdg.sliced new file mode 100644 index 0000000..0df3d83 --- /dev/null +++ b/sdg-core/src/test/res/regression/dinsa-tests/Carlos2.java.sdg.sliced @@ -0,0 +1,34 @@ +class A { + + public static void main(String[] args) { + try { + try { + throw generadorExcepciones(2); + } catch (Exception3 eb) { + } catch (Exception2 ea) { + } + int SC = 42; + } + } + + static Exception generadorExcepciones(int x) { + Exception e1 = new Exception(); + Exception2 e2 = new Exception2(); + Exception3 e3 = new Exception3(); + switch(x) { + case 1: + return e1; + case 2: + return e2; + case 3: + return e3; + } + return e1; + } +} + +class Exception2 extends Exception { +} + +class Exception3 extends Exception2 { +} diff --git a/sdg-core/src/test/res/regression/dinsa-tests/Josep.java b/sdg-core/src/test/res/regression/dinsa-tests/Josep.java new file mode 100644 index 0000000..51bda6f --- /dev/null +++ b/sdg-core/src/test/res/regression/dinsa-tests/Josep.java @@ -0,0 +1,49 @@ + +public class Josep { + + public static void main(String[] args) { + int suma =0; + suma += factorial(5); + suma += factorial2(5); + System.out.print(suma); // SLICING CRITERION + } + + static int factorial(int x) + { + int contador = 1; + int fact = 1; + while (contador 10) + break; + x++; + } + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicContinue.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/BasicContinue.java.sdg.criterion new file mode 100644 index 0000000..da2d398 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicContinue.java.sdg.criterion @@ -0,0 +1 @@ +14 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicContinue.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/BasicContinue.java.sdg.sliced new file mode 100644 index 0000000..c00796b --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicContinue.java.sdg.sliced @@ -0,0 +1,14 @@ +package mytest; + +public class BasicContinue { + + public static void main(String[] args) { + int x = 0; + bucle: while (x < 20) { + x++; + if (x > 10) + continue; + x++; + } + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicForeach.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/BasicForeach.java.sdg.criterion new file mode 100644 index 0000000..62f9457 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicForeach.java.sdg.criterion @@ -0,0 +1 @@ +6 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicForeach.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/BasicForeach.java.sdg.sliced new file mode 100644 index 0000000..eee2fcd --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicForeach.java.sdg.sliced @@ -0,0 +1,9 @@ +public class BasicForeach { + + public static void main(String[] args) { + int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + for (int item : numbers) { + System.out.println("Count is: " + item); + } + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicIf.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/BasicIf.java.sdg.criterion new file mode 100644 index 0000000..62f9457 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicIf.java.sdg.criterion @@ -0,0 +1 @@ +6 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicIf.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/BasicIf.java.sdg.sliced new file mode 100644 index 0000000..2c3e7d8 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicIf.java.sdg.sliced @@ -0,0 +1,11 @@ +public class BasicIf { + + public static void main(String[] args) { + boolean isMoving = false; + int currentSpeed = 10; + if (isMoving) { + currentSpeed--; + } else { + } + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicIfElse.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/BasicIfElse.java.sdg.criterion new file mode 100644 index 0000000..8e2afd3 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicIfElse.java.sdg.criterion @@ -0,0 +1 @@ +17 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicIfElse.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/BasicIfElse.java.sdg.sliced new file mode 100644 index 0000000..4e8c16d --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicIfElse.java.sdg.sliced @@ -0,0 +1,19 @@ +public class BasicIfElse { + + public static void main(String[] args) { + int testscore = 76; + char grade; + if (testscore >= 90) { + grade = 'A'; + } else if (testscore >= 80) { + grade = 'B'; + } else if (testscore >= 70) { + grade = 'C'; + } else if (testscore >= 60) { + grade = 'D'; + } else { + grade = 'F'; + } + System.out.println("Grade = " + grade); + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicSwitch.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitch.java.sdg.criterion new file mode 100644 index 0000000..978b4e8 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitch.java.sdg.criterion @@ -0,0 +1 @@ +26 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicSwitch.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitch.java.sdg.sliced new file mode 100644 index 0000000..7dd819c --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitch.java.sdg.sliced @@ -0,0 +1,28 @@ +package mytest; + +public class BasicSwitch { + + public static void main(String[] args) { + int x = Integer.valueOf(args[0]); + int y = -1; + switch(x) { + case 1: + y = 10; + break; + case 2: + y = 20; + break; + case 3: + y = 30; + break; + case 4: + case 5: + y = 100; + break; + case 6: + case 10: + y = 0; + } + System.out.println(y); + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchDefault.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchDefault.java.sdg.criterion new file mode 100644 index 0000000..b5045cc --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchDefault.java.sdg.criterion @@ -0,0 +1 @@ +21 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchDefault.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchDefault.java.sdg.sliced new file mode 100644 index 0000000..66b717c --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchDefault.java.sdg.sliced @@ -0,0 +1,24 @@ +package mytest; + +public class BasicSwitchDefault { + + public static void main(String[] args) { + int x = Integer.valueOf(args[0]); + int y; + switch(x % 3) { + case 0: + y = 10; + break; + case 1: + y = 20; + break; + case 2: + y = 30; + break; + default: + y = -1; + break; + } + System.out.println(y); + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchNoBreak.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchNoBreak.java.sdg.criterion new file mode 100644 index 0000000..da2d398 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchNoBreak.java.sdg.criterion @@ -0,0 +1 @@ +14 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchNoBreak.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchNoBreak.java.sdg.sliced new file mode 100644 index 0000000..1f56da9 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/BasicSwitchNoBreak.java.sdg.sliced @@ -0,0 +1,15 @@ +package mytest; + +public class BasicSwitchNoBreak { + + public static void main(String[] args) { + String res = ""; + switch(args[0]) { + case "a": + case "b": + case "c": + res = "cab"; + } + System.out.println(res); + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_1.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Bucles_1.java.sdg.criterion new file mode 100644 index 0000000..9a03714 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_1.java.sdg.criterion @@ -0,0 +1 @@ +10 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_1.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Bucles_1.java.sdg.sliced new file mode 100644 index 0000000..d66b56b --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_1.java.sdg.sliced @@ -0,0 +1,11 @@ +package ejemplos; + +public class Bucles_1 { + + public static void main(String[] args) { + int x = 1; + while (x <= 10) { + x++; + } + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_2.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Bucles_2.java.sdg.criterion new file mode 100644 index 0000000..8e2afd3 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_2.java.sdg.criterion @@ -0,0 +1 @@ +17 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_2.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Bucles_2.java.sdg.sliced new file mode 100644 index 0000000..536db49 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_2.java.sdg.sliced @@ -0,0 +1,11 @@ +package ejemplos; + +public class Bucles_2 { + + public static void main(String[] args) { + int x = 1; + while (x <= 10) { + x++; + } + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_3.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Bucles_3.java.sdg.criterion new file mode 100644 index 0000000..d99e90e --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_3.java.sdg.criterion @@ -0,0 +1 @@ +29 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_3.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Bucles_3.java.sdg.sliced new file mode 100644 index 0000000..b269ac3 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_3.java.sdg.sliced @@ -0,0 +1,13 @@ +package ejemplos; + +public class Bucles_3 { + + public static void main(String[] args) { + int x; + x = 1; + x = 1; + do { + x++; + } while (x <= 10); + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_4.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Bucles_4.java.sdg.criterion new file mode 100644 index 0000000..8580e7b --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_4.java.sdg.criterion @@ -0,0 +1 @@ +30 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_4.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Bucles_4.java.sdg.sliced new file mode 100644 index 0000000..75a9bcb --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_4.java.sdg.sliced @@ -0,0 +1,14 @@ +package ejemplos; + +public class Bucles_4 { + + public static void main(String[] args) { + int sumatorio = 0; + int min = 10; + int max = 100; + for (int num = min; num <= max; num++) { + sumatorio += num; + } + System.out.println(sumatorio); + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_5.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Bucles_5.java.sdg.criterion new file mode 100644 index 0000000..aaa6442 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_5.java.sdg.criterion @@ -0,0 +1 @@ +41 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_5.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Bucles_5.java.sdg.sliced new file mode 100644 index 0000000..7fac87e --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_5.java.sdg.sliced @@ -0,0 +1,13 @@ +package ejemplos; + +public class Bucles_5 { + + public static void main(String[] args) { + int x = 0; + x = 1; + x = 1; + do { + x++; + } while (x <= 10); + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_6.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Bucles_6.java.sdg.criterion new file mode 100644 index 0000000..dec2bf5 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_6.java.sdg.criterion @@ -0,0 +1 @@ +19 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_6.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Bucles_6.java.sdg.sliced new file mode 100644 index 0000000..4a65de7 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_6.java.sdg.sliced @@ -0,0 +1,17 @@ +package ejemplos; + +public class Bucles_6 { + + public static void main(String[] args) { + int x = 1; + while (x <= 10) { + x++; + while (x <= 10) { + x++; + } + } + while (x <= 10) { + x++; + } + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_Josep.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Bucles_Josep.java.sdg.criterion new file mode 100644 index 0000000..b74e882 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_Josep.java.sdg.criterion @@ -0,0 +1 @@ +31 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Bucles_Josep.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Bucles_Josep.java.sdg.sliced new file mode 100644 index 0000000..7883a00 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Bucles_Josep.java.sdg.sliced @@ -0,0 +1,10 @@ +package ejemplos; + +public class Bucles_Josep { + + public static void main(String[] args) { + int x = 0; + int y = 0, z = 0; + z = x + y; + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/ReturnTest.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/ReturnTest.java.sdg.criterion new file mode 100644 index 0000000..301160a --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/ReturnTest.java.sdg.criterion @@ -0,0 +1 @@ +8 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/ReturnTest.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/ReturnTest.java.sdg.sliced new file mode 100644 index 0000000..5d292fe --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/ReturnTest.java.sdg.sliced @@ -0,0 +1,10 @@ +public class ReturnTest { + + public static void main(String[] args) { + int i = Integer.valueOf(args[0]); + if (i == 0) { + } else { + System.out.println("false"); + } + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_1.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Test_1.java.sdg.criterion new file mode 100644 index 0000000..9a03714 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_1.java.sdg.criterion @@ -0,0 +1 @@ +10 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_1.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Test_1.java.sdg.sliced new file mode 100644 index 0000000..f182aee --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_1.java.sdg.sliced @@ -0,0 +1,9 @@ +package ejemplos; + +public class Test_1 { + + public static void main(String[] args) { + int x = 1; + x = 4; + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_2.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Test_2.java.sdg.criterion new file mode 100644 index 0000000..9d60796 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_2.java.sdg.criterion @@ -0,0 +1 @@ +11 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_2.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Test_2.java.sdg.sliced new file mode 100644 index 0000000..b61c5b7 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_2.java.sdg.sliced @@ -0,0 +1,11 @@ +package ejemplos; + +public class Test_2 { + + public static void main(String[] args) { + int x = 1; + int y = 0; + x = x + y; + System.out.println(x); + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_3.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Test_3.java.sdg.criterion new file mode 100644 index 0000000..9d60796 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_3.java.sdg.criterion @@ -0,0 +1 @@ +11 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_3.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Test_3.java.sdg.sliced new file mode 100644 index 0000000..5639ebd --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_3.java.sdg.sliced @@ -0,0 +1,9 @@ +package ejemplos; + +public class Test_3 { + + public static void main(String[] args) { + int x = 1; + x = 4; + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_4.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Test_4.java.sdg.criterion new file mode 100644 index 0000000..3cacc0b --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_4.java.sdg.criterion @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_4.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Test_4.java.sdg.sliced new file mode 100644 index 0000000..4a6d796 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_4.java.sdg.sliced @@ -0,0 +1,14 @@ +package ejemplos; + +public class Test_4 { + + public static void main(String[] args) { + int x = 1; + if (x == 1) { + x = 2; + if (x >= 1) { + x = 4; + } + } + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_5.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Test_5.java.sdg.criterion new file mode 100644 index 0000000..3cacc0b --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_5.java.sdg.criterion @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_5.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Test_5.java.sdg.sliced new file mode 100644 index 0000000..fb17866 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_5.java.sdg.sliced @@ -0,0 +1,14 @@ +package ejemplos; + +public class Test_5 { + + public static void main(String[] args) { + int x = 1; + if (x == 1) { + x = 2; + if (x >= 1) { + x = 4; + } + } + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_6.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Test_6.java.sdg.criterion new file mode 100644 index 0000000..ca7bf83 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_6.java.sdg.criterion @@ -0,0 +1 @@ +13 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_6.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Test_6.java.sdg.sliced new file mode 100644 index 0000000..c28a646 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_6.java.sdg.sliced @@ -0,0 +1,12 @@ +package ejemplos; + +public class Test_6 { + + public static void main(String[] args) { + int x = 1; + if (x == 1) { + } else { + x = 5; + } + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_7.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Test_7.java.sdg.criterion new file mode 100644 index 0000000..da2d398 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_7.java.sdg.criterion @@ -0,0 +1 @@ +14 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_7.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Test_7.java.sdg.sliced new file mode 100644 index 0000000..85dbf11 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_7.java.sdg.sliced @@ -0,0 +1,12 @@ +package ejemplos; + +public class Test_7 { + + public static void main(String[] args) { + int x = 1; + x = 4; + if (x == 2) { + x = 5; + } + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_8.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Test_8.java.sdg.criterion new file mode 100644 index 0000000..19c7bdb --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_8.java.sdg.criterion @@ -0,0 +1 @@ +16 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_8.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Test_8.java.sdg.sliced new file mode 100644 index 0000000..b2bbcdf --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_8.java.sdg.sliced @@ -0,0 +1,14 @@ +package ejemplos; + +public class Test_8 { + + public static void main(String[] args) { + int x = 1; + x = 6; + if (x == 2) { + x = 7; + } + if (x == 3) + x = 8; + } +} diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_9.java.sdg.criterion b/sdg-core/src/test/res/regression/ltd-samples/Test_9.java.sdg.criterion new file mode 100644 index 0000000..b5045cc --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_9.java.sdg.criterion @@ -0,0 +1 @@ +21 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/ltd-samples/Test_9.java.sdg.sliced b/sdg-core/src/test/res/regression/ltd-samples/Test_9.java.sdg.sliced new file mode 100644 index 0000000..54c5660 --- /dev/null +++ b/sdg-core/src/test/res/regression/ltd-samples/Test_9.java.sdg.sliced @@ -0,0 +1,28 @@ +package ejemplos; + +public class Test_9 { + + public static void main(String[] args) { + int x = 0; + if (x > 1) { + x = 1; + while (x > 2) { + x = 2; + while (x > 3) { + x = 3; + if (x > 4) { + x = 4; + if (x > 5) { + x = 5; + } + x--; + } + x--; + } + x--; + } + x--; + } + x--; + } +} diff --git a/sdg-core/src/test/res/regression/programs/WhileLoop.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/WhileLoop.java.sdg.criterion new file mode 100644 index 0000000..fc9afb4 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/WhileLoop.java.sdg.criterion @@ -0,0 +1 @@ +59 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/WhileLoop.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/WhileLoop.java.sdg.sliced new file mode 100644 index 0000000..7f6e63f --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/WhileLoop.java.sdg.sliced @@ -0,0 +1,16 @@ +package tfm.programs; + +public class WhileLoop { + + void while5() { + int x = 1; + int y = 2; + while (x < y) { + x += y; + while (y < x) { + y++; + } + y += 1; + } + } +} diff --git a/sdg-core/src/test/res/regression/programs/cfg/CFG_Test2.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test2.java.sdg.criterion new file mode 100644 index 0000000..62f9457 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test2.java.sdg.criterion @@ -0,0 +1 @@ +6 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/cfg/CFG_Test1.java b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test2.java.sdg.sliced similarity index 53% rename from sdg-core/src/test/res/regression/programs/cfg/CFG_Test1.java rename to sdg-core/src/test/res/regression/programs/cfg/CFG_Test2.java.sdg.sliced index 01539fd..aa4affe 100644 --- a/sdg-core/src/test/res/regression/programs/cfg/CFG_Test1.java +++ b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test2.java.sdg.sliced @@ -1,5 +1,6 @@ -public class CFG_Test1 { - public static void main(String[] args) { +public class CFG_Test2 { + public static void main(String[] args) { + int d = 4; } -} \ No newline at end of file +} diff --git a/sdg-core/src/test/res/regression/programs/cfg/CFG_Test3.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test3.java.sdg.criterion new file mode 100644 index 0000000..62f9457 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test3.java.sdg.criterion @@ -0,0 +1 @@ +6 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/cfg/CFG_Test3.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test3.java.sdg.sliced new file mode 100644 index 0000000..eb6eb66 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test3.java.sdg.sliced @@ -0,0 +1,8 @@ +public class CFG_Test3 { + + public static void main(String[] args) { + int a = 1; + while (a < 10) a++; + System.out.println(a); + } +} diff --git a/sdg-core/src/test/res/regression/programs/cfg/CFG_Test4.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test4.java.sdg.criterion new file mode 100644 index 0000000..f11c82a --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test4.java.sdg.criterion @@ -0,0 +1 @@ +9 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/cfg/CFG_Test4.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test4.java.sdg.sliced new file mode 100644 index 0000000..2ee2c9e --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test4.java.sdg.sliced @@ -0,0 +1,12 @@ +public class CFG_Test4 { + + public static void main(String[] args) { + int a = 1; + if (a % 2 == 0) { + a++; + } else { + a--; + } + System.out.println(a); + } +} diff --git a/sdg-core/src/test/res/regression/programs/cfg/CFG_Test5.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test5.java.sdg.criterion new file mode 100644 index 0000000..c793025 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test5.java.sdg.criterion @@ -0,0 +1 @@ +7 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/cfg/CFG_Test5.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test5.java.sdg.sliced new file mode 100644 index 0000000..dbb0f7e --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/CFG_Test5.java.sdg.sliced @@ -0,0 +1,10 @@ +public class CFG_Test5 { + + public static void main(String[] args) { + int a = 1; + if (a % 2 == 0) { + a++; + } + System.out.println(a); + } +} diff --git a/sdg-core/src/test/res/regression/programs/cfg/Eval_1.java b/sdg-core/src/test/res/regression/programs/cfg/Eval_1.java index 75d1e42..f088059 100644 --- a/sdg-core/src/test/res/regression/programs/cfg/Eval_1.java +++ b/sdg-core/src/test/res/regression/programs/cfg/Eval_1.java @@ -61,6 +61,6 @@ public class Eval_1 { break; } - Logger.log(x); + System.out.println(x); } } diff --git a/sdg-core/src/test/res/regression/programs/cfg/Eval_1.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/cfg/Eval_1.java.sdg.criterion new file mode 100644 index 0000000..4b6f9c3 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/Eval_1.java.sdg.criterion @@ -0,0 +1 @@ +64 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/cfg/Eval_1.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/cfg/Eval_1.java.sdg.sliced new file mode 100644 index 0000000..3b67b2f --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/Eval_1.java.sdg.sliced @@ -0,0 +1,38 @@ +package tfm.programs.cfg; + +import tfm.utils.Logger; + +public class Eval_1 { + + public static void main(String[] args) { + int x = 1; + one: while (x <= 10) { + x++; + } + do { + x--; + if (x == 1) { + x = 2; + } else { + x = 4; + } + } while (x < 1); + for (int z = 1; z < x; z++, x--) { + } + switch(x) { + case 1: + x = 3; + break; + case 2: + x = 4; + break; + case 3: + x = 5; + break; + default: + x = 5; + break; + } + System.out.println(x); + } +} diff --git a/sdg-core/src/test/res/regression/programs/cfg/Eval_2.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/cfg/Eval_2.java.sdg.criterion new file mode 100644 index 0000000..2edeafb --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/Eval_2.java.sdg.criterion @@ -0,0 +1 @@ +20 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/cfg/Eval_2.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/cfg/Eval_2.java.sdg.sliced new file mode 100644 index 0000000..ee31854 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/Eval_2.java.sdg.sliced @@ -0,0 +1,9 @@ +package tfm.programs.cfg; + +public class Eval_2 { + + public static void main(String[] args) { + int x = 1; + System.out.println(x); + } +} diff --git a/sdg-core/src/test/res/regression/programs/cfg/Eval_3.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/cfg/Eval_3.java.sdg.criterion new file mode 100644 index 0000000..410b14d --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/Eval_3.java.sdg.criterion @@ -0,0 +1 @@ +25 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/cfg/Eval_3.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/cfg/Eval_3.java.sdg.sliced new file mode 100644 index 0000000..05636d5 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/Eval_3.java.sdg.sliced @@ -0,0 +1,8 @@ +package tfm.programs.cfg; + +public class Eval_3 { + + public static void main(String[] args) { + int x = 1; + } +} diff --git a/sdg-core/src/test/res/regression/programs/cfg/Eval_4.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/cfg/Eval_4.java.sdg.criterion new file mode 100644 index 0000000..dec2bf5 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/Eval_4.java.sdg.criterion @@ -0,0 +1 @@ +19 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/cfg/Eval_4.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/cfg/Eval_4.java.sdg.sliced new file mode 100644 index 0000000..fe4b735 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/cfg/Eval_4.java.sdg.sliced @@ -0,0 +1,18 @@ +package tfm.programs.cfg; + +public class Eval_4 { + + public static void main(String[] args) { + String[] fruits = new String[] { "Orange", "Apple", "Pear", "Strawberry" }; + String[] animals = new String[] { "Bear", "Monkey" }; + int x = 1; + while (x <= 3) { + for (String fruit : fruits) { + for (String animal : animals) { + System.out.println(animal); + } + } + x++; + } + } +} diff --git a/sdg-core/src/test/res/regression/programs/pdg/Example1.java b/sdg-core/src/test/res/regression/programs/pdg/Example1.java index 0f750f9..d4cc9a5 100644 --- a/sdg-core/src/test/res/regression/programs/pdg/Example1.java +++ b/sdg-core/src/test/res/regression/programs/pdg/Example1.java @@ -58,7 +58,7 @@ public class Example1 { default: } - Logger.log(e); + System.out.println(e); } // public static void main2() { @@ -68,6 +68,6 @@ public class Example1 { // // int t = z * p; // -// Logger.log(t); +// System.out.println(t); // } } diff --git a/sdg-core/src/test/res/regression/programs/pdg/Example1.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/pdg/Example1.java.sdg.criterion new file mode 100644 index 0000000..eebd1d1 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/pdg/Example1.java.sdg.criterion @@ -0,0 +1 @@ +61 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/pdg/Example1.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/pdg/Example1.java.sdg.sliced new file mode 100644 index 0000000..511bb68 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/pdg/Example1.java.sdg.sliced @@ -0,0 +1,36 @@ +package tfm.programs.pdg; + +import es.upv.mist.slicing.utils.Logger; + +public class Example1 { + + public static void main(String[] args) { + int x = 1; + int y = 2; + if (x < y) { + while (x < y) { + y = x; + for (int i = 0; i < y; i++) { + y += i; + if (x > y) + continue; + x = y; + } + x++; + } + } else { + x = 4; + } + int e = x; + switch(x) { + case 1: + e = 5; + break; + case 2: + case 3: + e = 4; + break; + } + System.out.println(e); + } +} diff --git a/sdg-core/src/test/res/regression/programs/pdg/Example2.java b/sdg-core/src/test/res/regression/programs/pdg/Example2.java index 4da30ee..9955a84 100644 --- a/sdg-core/src/test/res/regression/programs/pdg/Example2.java +++ b/sdg-core/src/test/res/regression/programs/pdg/Example2.java @@ -33,6 +33,6 @@ public class Example2 { b++; } - Logger.log(b); + System.out.println(b); } } diff --git a/sdg-core/src/test/res/regression/programs/pdg/Example2.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/pdg/Example2.java.sdg.criterion new file mode 100644 index 0000000..dce6588 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/pdg/Example2.java.sdg.criterion @@ -0,0 +1 @@ +36 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/pdg/Example2.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/pdg/Example2.java.sdg.sliced new file mode 100644 index 0000000..66694da --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/pdg/Example2.java.sdg.sliced @@ -0,0 +1,16 @@ +package tfm.programs.pdg; + +import tfm.utils.Logger; +import java.util.Arrays; + +public class Example2 { + + public static void main(String[] args) { + int a = 8; + int b = 2; + for (; a < 100; a++) { + b++; + } + System.out.println(b); + } +} diff --git a/sdg-core/src/test/res/regression/programs/pdg/Example3.java b/sdg-core/src/test/res/regression/programs/pdg/Example3.java index c1f1c30..cfe6c74 100644 --- a/sdg-core/src/test/res/regression/programs/pdg/Example3.java +++ b/sdg-core/src/test/res/regression/programs/pdg/Example3.java @@ -18,7 +18,7 @@ public class Example3 { i++; } - Logger.log(sum); - Logger.log(product); + System.out.println(sum); + System.out.println(product); } } diff --git a/sdg-core/src/test/res/regression/programs/pdg/Example3.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/pdg/Example3.java.sdg.criterion new file mode 100644 index 0000000..b5045cc --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/pdg/Example3.java.sdg.criterion @@ -0,0 +1 @@ +21 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/pdg/Example3.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/pdg/Example3.java.sdg.sliced new file mode 100644 index 0000000..739d7d7 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/pdg/Example3.java.sdg.sliced @@ -0,0 +1,17 @@ +package tfm.programs.pdg; + +import tfm.utils.Logger; + +public class Example3 { + + public static void main(String[] args) { + int n = 1; + int i = 1; + int sum = 0; + while (i < n) { + sum += i; + i++; + } + System.out.println(sum); + } +} diff --git a/sdg-core/src/test/res/regression/programs/pdg/Test.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/pdg/Test.java.sdg.criterion new file mode 100644 index 0000000..9d60796 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/pdg/Test.java.sdg.criterion @@ -0,0 +1 @@ +11 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/pdg/Test.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/pdg/Test.java.sdg.sliced new file mode 100644 index 0000000..883158f --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/pdg/Test.java.sdg.sliced @@ -0,0 +1,9 @@ +package tfm.programs.pdg; + +public class Test { + + public static void main(String[] args) { + int a = 0; + System.out.println(a); + } +} diff --git a/sdg-core/src/test/res/regression/programs/sdg/Example1.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/sdg/Example1.java.sdg.criterion new file mode 100644 index 0000000..9d60796 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/sdg/Example1.java.sdg.criterion @@ -0,0 +1 @@ +11 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/programs/sdg/Example1.java.sdg.sliced b/sdg-core/src/test/res/regression/programs/sdg/Example1.java.sdg.sliced new file mode 100644 index 0000000..ae19329 --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/sdg/Example1.java.sdg.sliced @@ -0,0 +1,16 @@ +package tfm.programs.sdg; + +public class Example1 { + + public static void main(String[] args) { + int n1 = 1; + int n2 = 2; + int f = sum(n1, n2); + System.out.println(f); + } + + private static int sum(int x, int y) { + int res = x + y; + return res; + } +} diff --git a/sdg-core/src/test/res/regression/programs/sdg/Example2.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/sdg/Example2.java.sdg.criterion new file mode 100644 index 0000000..3e932fe --- /dev/null +++ b/sdg-core/src/test/res/regression/programs/sdg/Example2.java.sdg.criterion @@ -0,0 +1 @@ +34 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/review-07-2020/P1.java.sdg.criterion b/sdg-core/src/test/res/regression/review-07-2020/P1.java.sdg.criterion new file mode 100644 index 0000000..b2412e3 --- /dev/null +++ b/sdg-core/src/test/res/regression/review-07-2020/P1.java.sdg.criterion @@ -0,0 +1 @@ +62 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/review-07-2020/P1.java.sdg.sliced b/sdg-core/src/test/res/regression/review-07-2020/P1.java.sdg.sliced new file mode 100644 index 0000000..2785ae1 --- /dev/null +++ b/sdg-core/src/test/res/regression/review-07-2020/P1.java.sdg.sliced @@ -0,0 +1,24 @@ +class FiguresGroup { + + public Figure greatestFigure() { + if (numF == 0) + return null; + Figure f = figuresList[0]; + double a = figuresList[0].area(); + for (int i = 1; i < numF; i++) { + double b = figuresList[i].area(); + if (a < b) { + f = figuresList[i]; + a = b; + } + } + return f; + } +} + +class Figure { + + int area() { + return 5; + } +} diff --git a/sdg-core/src/test/res/regression/review-07-2020/P2.java.sdg.criterion b/sdg-core/src/test/res/regression/review-07-2020/P2.java.sdg.criterion new file mode 100644 index 0000000..9d60796 --- /dev/null +++ b/sdg-core/src/test/res/regression/review-07-2020/P2.java.sdg.criterion @@ -0,0 +1 @@ +11 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/review-07-2020/P2.java.sdg.sliced b/sdg-core/src/test/res/regression/review-07-2020/P2.java.sdg.sliced new file mode 100644 index 0000000..1a7c326 --- /dev/null +++ b/sdg-core/src/test/res/regression/review-07-2020/P2.java.sdg.sliced @@ -0,0 +1,8 @@ +public class Bucles { + + public static void main(String[] args) { + int x; + int i = 8; + x = 5 + i; + } +} diff --git a/sdg-core/src/test/res/regression/review-07-2020/P3.java.sdg.criterion b/sdg-core/src/test/res/regression/review-07-2020/P3.java.sdg.criterion new file mode 100644 index 0000000..368f89c --- /dev/null +++ b/sdg-core/src/test/res/regression/review-07-2020/P3.java.sdg.criterion @@ -0,0 +1 @@ +28 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/review-07-2020/P3.java.sdg.sliced b/sdg-core/src/test/res/regression/review-07-2020/P3.java.sdg.sliced new file mode 100644 index 0000000..d722393 --- /dev/null +++ b/sdg-core/src/test/res/regression/review-07-2020/P3.java.sdg.sliced @@ -0,0 +1,12 @@ +public class Bucles { + + public static void main(String[] args) { + int x = 2; + } +} + +class ExceptionA extends Exception { +} + +class ExceptionB extends ExceptionA { +} diff --git a/sdg-core/src/test/res/regression/review-07-2020/P4.java.sdg.criterion b/sdg-core/src/test/res/regression/review-07-2020/P4.java.sdg.criterion new file mode 100644 index 0000000..368f89c --- /dev/null +++ b/sdg-core/src/test/res/regression/review-07-2020/P4.java.sdg.criterion @@ -0,0 +1 @@ +28 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/review-07-2020/P4.java.sdg.sliced b/sdg-core/src/test/res/regression/review-07-2020/P4.java.sdg.sliced new file mode 100644 index 0000000..1c388f1 --- /dev/null +++ b/sdg-core/src/test/res/regression/review-07-2020/P4.java.sdg.sliced @@ -0,0 +1,12 @@ +public class Bucles { + + public static void main(String[] args) { + System.out.println("No se lanza ninguna excepcion"); + } +} + +class ExceptionA extends Exception { +} + +class ExceptionB extends ExceptionA { +} diff --git a/sdg-core/src/test/res/regression/review-07-2020/P5.java.sdg.criterion b/sdg-core/src/test/res/regression/review-07-2020/P5.java.sdg.criterion new file mode 100644 index 0000000..9d60796 --- /dev/null +++ b/sdg-core/src/test/res/regression/review-07-2020/P5.java.sdg.criterion @@ -0,0 +1 @@ +11 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/review-07-2020/P5.java.sdg.sliced b/sdg-core/src/test/res/regression/review-07-2020/P5.java.sdg.sliced new file mode 100644 index 0000000..a22b18d --- /dev/null +++ b/sdg-core/src/test/res/regression/review-07-2020/P5.java.sdg.sliced @@ -0,0 +1,38 @@ +public class Josep2 { + + public static void main(String[] args) { + int suma = 0; + suma += factorial(5); + Numeros num = new GrandesNumeros(7); + suma += num.random(); + System.out.print(suma); + } + + static int factorial(int x) { + int contador = 1; + int fact = 1; + while (contador < x) { + contador++; + fact = fact * contador; + } + return fact; + } +} + +class Numeros { + + int random() { + return haceFalta; + } +} + +class GrandesNumeros extends Numeros { + + GrandesNumeros(double x) { + haceFalta = 0; + } + + int random() { + return haceFalta; + } +} diff --git a/sdg-core/src/test/res/regression/review-07-2020/P6.java.sdg.criterion b/sdg-core/src/test/res/regression/review-07-2020/P6.java.sdg.criterion new file mode 100644 index 0000000..410b14d --- /dev/null +++ b/sdg-core/src/test/res/regression/review-07-2020/P6.java.sdg.criterion @@ -0,0 +1 @@ +25 \ No newline at end of file diff --git a/sdg-core/src/test/res/regression/review-07-2020/P6.java.sdg.sliced b/sdg-core/src/test/res/regression/review-07-2020/P6.java.sdg.sliced new file mode 100644 index 0000000..7e9046d --- /dev/null +++ b/sdg-core/src/test/res/regression/review-07-2020/P6.java.sdg.sliced @@ -0,0 +1,17 @@ +public class Bucles { + + static void metodoGeneradorExcepciones(int x) throws Exception { + if (x == 0) + throw new ExceptionA(); + if (x == 1) + throw new ExceptionB(); + if (x == 2) + throw new Exception(); + } +} + +class ExceptionA extends Exception { +} + +class ExceptionB extends ExceptionA { +} -- GitLab From 77c9ba06d8552673675800ac8fad887bbbafc7ef Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Tue, 15 Dec 2020 19:38:06 +0100 Subject: [PATCH 5/6] Add .gitlab-ci.yml --- .gitlab-ci.yml | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..be99d2b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,55 @@ +# This file is a template, and might need editing before it works on your project. +# Build JAVA applications using Apache Maven (http://maven.apache.org) +# For docker image tags see https://hub.docker.com/_/maven/ +# +# For general lifecycle information see https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html + +# This template will build and test your projects +# * Caches downloaded dependencies and plugins between invocation. +# * Verify but don't deploy merge requests. +# * Deploy built artifacts from master branch only. + +variables: + # This will suppress any download for dependencies and plugins or upload messages which would clutter the console log. + # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work. + MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" + # As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used + # when running from the command line. + # `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins. + MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" + +# This template uses jdk8 for verifying and deploying images +image: maven:3-jdk-11 + +# Cache downloaded dependencies and plugins between builds. +# To keep cache across branches add 'key: "$CI_JOB_NAME"' +cache: + paths: + - .m2/repository + +# For merge requests do not `deploy` but only run `verify`. +# See https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html +.verify: &verify + stage: test + script: + - 'mvn $MAVEN_CLI_OPTS verify' + except: + - master + +# Verify merge requests using JDK8 +verify:jdk11: + <<: *verify + +# To deploy packages from CI, create a ci_settings.xml file +# For deploying packages to GitLab's Maven Repository: See https://docs.gitlab.com/ee/user/project/packages/maven_repository.html#creating-maven-packages-with-gitlab-cicd for more details. +# Please note: The GitLab Maven Repository is currently only available in GitLab Premium / Ultimate. +# For `master` branch run `mvn deploy` automatically. +deploy:jdk11: + stage: deploy + script: + - if [ ! -f ci_settings.xml ]; + then echo "CI settings missing\! If deploying to GitLab Maven Repository, please see https://docs.gitlab.com/ee/user/project/packages/maven_repository.html#creating-maven-packages-with-gitlab-cicd for instructions."; + fi + - 'mvn $MAVEN_CLI_OPTS deploy -s ci_settings.xml' + only: + - master -- GitLab From f293d4184d799718a883a69c9cab1f9869b233b3 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Wed, 16 Dec 2020 11:47:24 +0100 Subject: [PATCH 6/6] Removed test due to lack of support: nested calls are not yet supported --- sdg-core/src/test/res/regression/programs/sdg/Example2.java | 4 ++-- .../res/regression/programs/sdg/Example2.java.sdg.criterion | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 sdg-core/src/test/res/regression/programs/sdg/Example2.java.sdg.criterion diff --git a/sdg-core/src/test/res/regression/programs/sdg/Example2.java b/sdg-core/src/test/res/regression/programs/sdg/Example2.java index d92a978..9b80443 100644 --- a/sdg-core/src/test/res/regression/programs/sdg/Example2.java +++ b/sdg-core/src/test/res/regression/programs/sdg/Example2.java @@ -31,7 +31,7 @@ public class Example2 { public static void main(String[] args) { CustomObject customObject = new CustomObject(new InnerObject(1)); modifyCustomObject(customObject); - modifyInnerObject(customObject.inner); + modifyInnerObject(customObject.inner); // Slicing criterion } public static void modifyCustomObject(CustomObject customObject) { @@ -41,4 +41,4 @@ public class Example2 { public static void modifyInnerObject(InnerObject innerObject) { innerObject.x = 5; } -} \ No newline at end of file +} diff --git a/sdg-core/src/test/res/regression/programs/sdg/Example2.java.sdg.criterion b/sdg-core/src/test/res/regression/programs/sdg/Example2.java.sdg.criterion deleted file mode 100644 index 3e932fe..0000000 --- a/sdg-core/src/test/res/regression/programs/sdg/Example2.java.sdg.criterion +++ /dev/null @@ -1 +0,0 @@ -34 \ No newline at end of file -- GitLab