diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..2487d83 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,43 @@ +# Java Maven CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-java/ for more details +# +version: 2 +jobs: + build: + docker: + # specify the version you desire here + - image: circleci/openjdk:8-jdk + + # Specify service dependencies here if necessary + # CircleCI maintains a library of pre-built images + # documented at https://circleci.com/docs/2.0/circleci-images/ + # - image: circleci/postgres:9.4 + + working_directory: ~/repo + + environment: + # Customize the JVM maximum heap limit + MAVEN_OPTS: -Xmx3200m + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "pom.xml" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: mvn dependency:go-offline + + - save_cache: + paths: + - ~/.m2 + key: v1-dependencies-{{ checksum "pom.xml" }} + + # run tests! + - run: mvn integration-test + + diff --git a/.travis.yml b/.travis.yml index 3d861eb..2e3f86a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: java notifications: - on_failure: never - on_success: always \ No newline at end of file + email: + on_failure: never + on_success: always diff --git a/README.md b/README.md index 1a707b0..de4d193 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # FailingProject This repository contains source of the test project of [Nopol](https://github.com/SpoonLabs/nopol). -It is intended to have failing tests, as it is used on an automatic repair project. \ No newline at end of file +It is intended to have failing tests, as it is used on an automatic repair project. + diff --git a/src/main/java/evo_examples/evo_example_1/EvoExample.java b/src/main/java/evo_examples/evo_example_1/EvoExample.java deleted file mode 100644 index 227281e..0000000 --- a/src/main/java/evo_examples/evo_example_1/EvoExample.java +++ /dev/null @@ -1,22 +0,0 @@ -package evo_examples.evo_example_1; - -public class EvoExample { - - private int value = 1; - - public int minZero(int number){ - - if(number <= 1){ - return 0; - } - return number; - } - - public void setValue(int v){ - this.value = v; - } - - public int getValue(){ - return this.value; - } -} diff --git a/src/main/java/infinitel_examples/infinitel_example_1/InfinitelExample.java b/src/main/java/infinitel_examples/infinitel_example_1/InfinitelExample.java deleted file mode 100644 index 1e9c0ca..0000000 --- a/src/main/java/infinitel_examples/infinitel_example_1/InfinitelExample.java +++ /dev/null @@ -1,66 +0,0 @@ -package infinitel_examples.infinitel_example_1; - - -public class InfinitelExample { - - public int loopResult(Integer a) { - int b = 0; - while (b != a) { - a += 1; - b += 2; - } - return b / 2; - } - - private void fixableInfiniteLoop(int a) { - while (true) { - if (unfixableInfiniteLoop(a-1)) { - return; - } else if (unfixableInfiniteLoop(a+1)) { - return; - } - } - } - - private boolean unfixableInfiniteLoop(int a) { - while (true) { - if (unfixableInfiniteLoop(a-1)) { - return true; - } else if (unfixableInfiniteLoop(a+1)) { - return false; - } - } - } - - private int otherUnfixableInfiniteLoop(boolean a, int b) { - if (a) - while (true) { - if (unfixableInfiniteLoop(b-1)) { - return b-1; - } else if (unfixableInfiniteLoop(b+1)) { - return b+1; - } - } - else - return 0; - } - - public double binomialTest(int numberOfTrials, int numberOfSuccesses, char probability) { - switch (probability) { - case '0': - int criticalValueLow = 0; - int criticalValueHigh = numberOfTrials; - double pTotal = 0; - while (true) { - double pLow = numberOfTrials / 0.01; - numberOfTrials = (int) pLow; - if ((criticalValueLow > numberOfSuccesses) || (criticalValueHigh < numberOfSuccesses)) { - break; - } - } - return pTotal; - default : - return 1; - } - } -} diff --git a/src/main/java/infinitel_examples/infinitel_example_2/InfinitelExample.java b/src/main/java/infinitel_examples/infinitel_example_2/InfinitelExample.java deleted file mode 100644 index 347f51e..0000000 --- a/src/main/java/infinitel_examples/infinitel_example_2/InfinitelExample.java +++ /dev/null @@ -1,64 +0,0 @@ -package infinitel_examples.infinitel_example_2; - -public class InfinitelExample { - - public int oneIterationOrZero(boolean oneIteration) { - int a = 0; - while (oneIteration || ! oneIteration && a == 0) { - a += 10; - } - return a; - } - - public int breakInSwitchIsNotForWhile(char aChar) { - while (true) { - switch (aChar) { - case 'a': - return 1; - case 'e': - return 2; - case 's': - break; - case 't': - break; - case 'u': - break; - case 'v': - break; - } - if (aChar == 255) { - break; - } - aChar++; - } - return 12; - } - - public int returnInAnonymousClassIsNotForWhile(int a) { - while (a-- > 0) { - Comparable comparable = new Comparable() { - public int compareTo(Integer b) { - return 0; - } - }; - a += comparable.compareTo(a); - } - return a; - } - - public int breakAndReturnInForNotForWhile(int a) { - while (a-- > 0) { - for (int i = 0; i < a; i += 1) { - if (i == -a) { - break; - } - } - for (int i = a; i < 0; i -= 1) { - if (i == -a) { - return 0; - } - } - } - return a; - } -} diff --git a/src/main/java/infinitel_examples/infinitel_example_3/InfinitelExample.java b/src/main/java/infinitel_examples/infinitel_example_3/InfinitelExample.java deleted file mode 100644 index 136bc43..0000000 --- a/src/main/java/infinitel_examples/infinitel_example_3/InfinitelExample.java +++ /dev/null @@ -1,18 +0,0 @@ -package infinitel_examples.infinitel_example_3; - -public class InfinitelExample { - - public static int nestedLoops(int a) { - int aCopy = a; - while (true) { - while (aCopy > 0) { - aCopy -= 1; - } - if (a > aCopy) { - break; - } - } - return aCopy; - } - -} diff --git a/src/main/java/infinitel_examples/infinitel_example_4/InfinitelExample.java b/src/main/java/infinitel_examples/infinitel_example_4/InfinitelExample.java deleted file mode 100644 index c1dcd98..0000000 --- a/src/main/java/infinitel_examples/infinitel_example_4/InfinitelExample.java +++ /dev/null @@ -1,18 +0,0 @@ -package infinitel_examples.infinitel_example_4; - -public class InfinitelExample { - - public static int loopWithBreakAndReturn(int a) { - int b = a; - while (b > 0) { - if (b == 18) { - return a; - } - if (b == 9) { - break; - } - b -=1; - } - return b; - } -} diff --git a/src/main/java/infinitel_examples/infinitel_example_5/InfinitelExample.java b/src/main/java/infinitel_examples/infinitel_example_5/InfinitelExample.java deleted file mode 100644 index 00ed561..0000000 --- a/src/main/java/infinitel_examples/infinitel_example_5/InfinitelExample.java +++ /dev/null @@ -1,56 +0,0 @@ -package infinitel_examples.infinitel_example_5; - -public class InfinitelExample { - - public InfinitelExample(int size) { - consumer = new Consumer(size); - } - - public boolean consume(String word) { - int index = 0; - while (canKeepConsuming(index, word)) { - index++; - consumer().consume(); - } - return consumer().getConsumed() == consumer().getSize(); - } - - public boolean canKeepConsuming(int index, String word) { - return index >= word.length() || word.charAt(index) != '.'; - } - - private Consumer consumer() { - return consumer; - } - - private Consumer consumer; -} - -class Consumer { - - public Consumer(int size) { - this.size = size; - this.consumed = 0; - } - - public void consume() { - consumed++; - } - - protected int getConsumed() { - return consumed; - } - - protected int getSize() { - return size; - } - - @SuppressWarnings("unused") - private int getId() { - return id; - } - - private int size; - private int consumed; - private static int id = 18213131; -} \ No newline at end of file diff --git a/src/main/java/nopol_examples/nopol_example_1/NopolExample.java b/src/main/java/nopol_examples/nopol_example_1/NopolExample.java deleted file mode 100644 index 6ccce00..0000000 --- a/src/main/java/nopol_examples/nopol_example_1/NopolExample.java +++ /dev/null @@ -1,29 +0,0 @@ -package nopol_examples.nopol_example_1; - -public class NopolExample { - - /* - * Return the index char of s - * or the last if index > s.length - * or the first if index < 0 - */ - public char charAt(String s, int index){ - - if ( index == 0 ) // Fix index <= 0 - return s.charAt(0); - - if ( index < s.length() ) - return s.charAt(index); - - return s.charAt(s.length()-1); - } - - public NopolExample() { - int variableInsideConstructor; - variableInsideConstructor = 15; - index = 2 * variableInsideConstructor; - } - - private int index = 419382; - private static String s = "Overloading field name with parameter name"; -} diff --git a/src/main/java/nopol_examples/nopol_example_12/NopolExample.java b/src/main/java/nopol_examples/nopol_example_12/NopolExample.java deleted file mode 100644 index 18335f6..0000000 --- a/src/main/java/nopol_examples/nopol_example_12/NopolExample.java +++ /dev/null @@ -1,13 +0,0 @@ -package nopol_examples.nopol_example_12; -public class NopolExample { - public boolean isEmpty(java.util.List list) { - java.util.ArrayList list2 = new java.util.ArrayList(); - int x = 3; // 3 should also be added to the list of constants - if (list.isEmpty()) - return true; - foo(null); - int y = x + list2.size(); // required for preventing the compiler to remive the variable (collection is done at ru qntime) - return false; - } - int foo(java.util.List l) { return 0; } -} \ No newline at end of file diff --git a/src/main/java/nopol_examples/nopol_example_13/NopolExample.java b/src/main/java/nopol_examples/nopol_example_13/NopolExample.java deleted file mode 100644 index 05094b2..0000000 --- a/src/main/java/nopol_examples/nopol_example_13/NopolExample.java +++ /dev/null @@ -1,9 +0,0 @@ -package nopol_examples.nopol_example_13; -public class NopolExample { - public boolean isEmpty(java.util.List list) { - if (list.isEmpty()) - return true; - - return false; - } -} \ No newline at end of file diff --git a/src/main/java/nopol_examples/nopol_example_2/NopolExample.java b/src/main/java/nopol_examples/nopol_example_2/NopolExample.java deleted file mode 100644 index 632d906..0000000 --- a/src/main/java/nopol_examples/nopol_example_2/NopolExample.java +++ /dev/null @@ -1,45 +0,0 @@ -package nopol_examples.nopol_example_2; - -import java.util.concurrent.Callable; - -public class NopolExample { - - /* - * Return the max between a and b - */ - public int getMax(int a, int b){ - if ( (b - a) < 0 ){ // Fix a < b - return b; - } - return a; - } - - private class InnerNopolExample { - - public int method(boolean aBoolean) { - int result = 29; - if (aBoolean) { - return result * 2; - } else { - return result * 3; - } - } - - private int fieldOfInnerClass; - } - - public Callable newCallable() { - return new Callable() { - private int limit = 114; - public Boolean call() throws Exception { - if (fieldOfOuterClass > limit) { - return true; - } else { - return false; - } - } - }; - } - - private int fieldOfOuterClass = 12302; -} diff --git a/src/main/java/nopol_examples/nopol_example_3/NopolExample.java b/src/main/java/nopol_examples/nopol_example_3/NopolExample.java deleted file mode 100644 index 7f71a18..0000000 --- a/src/main/java/nopol_examples/nopol_example_3/NopolExample.java +++ /dev/null @@ -1,41 +0,0 @@ -package nopol_examples.nopol_example_3; - -public class NopolExample { - - /* - * Return true if a is odd number - */ - public boolean isOddNumber(int a){ - int tmp = (a-1)%2; - - if ( tmp != 0 ){ // Fix : tmp == 0 - return true; - } - return false; - - } - - private void method(boolean aBoolean) { - int reachableVariable = 3; - int unreachableVariable; - if ("aaaa".startsWith("b")) { - unreachableVariable = 23; - } else { - if (! aBoolean || reachableVariable < 2) { - unreachableVariable = 10; - } - } - } - - private void otherMethod(boolean aBoolean) { - int uninitializedReachableVariable; - if (aBoolean) { - uninitializedReachableVariable = 23; - } else { - uninitializedReachableVariable = 11; - if (! aBoolean && uninitializedReachableVariable < 2) { - uninitializedReachableVariable = 10; - } - } - } -} diff --git a/src/main/java/nopol_examples/nopol_example_4/NopolExample.java b/src/main/java/nopol_examples/nopol_example_4/NopolExample.java deleted file mode 100644 index 129c326..0000000 --- a/src/main/java/nopol_examples/nopol_example_4/NopolExample.java +++ /dev/null @@ -1,32 +0,0 @@ -package nopol_examples.nopol_example_4; - -public class NopolExample { - - /* - * return true if a can be divided by 3 - */ - - public boolean canBeDividedby3(String a) { - - int initializedVariableShouldBeCollected = 2; - int uninitializedVariableShouldNotBeCollected; - int otherInitializedVariableShouldBeCollected; - - if ( a.length() == 0 ){ - return false; - } - - if ( a.charAt(0)== '0' ) - return false; - - otherInitializedVariableShouldBeCollected = 34; - - /* - * FIX : (((1)+(1))<((a.length())-((1)+(1))))||(((a.length())-((1)+(1)))<=(1)) - */ - a = a.substring(1); - - boolean result = (Integer.parseInt(a)%3 == 0); - return result; - } -} \ No newline at end of file diff --git a/src/main/java/nopol_examples/nopol_example_5/NopolExample.java b/src/main/java/nopol_examples/nopol_example_5/NopolExample.java deleted file mode 100644 index 692ce2c..0000000 --- a/src/main/java/nopol_examples/nopol_example_5/NopolExample.java +++ /dev/null @@ -1,25 +0,0 @@ -package nopol_examples.nopol_example_5; - -public class NopolExample { - - public static class InnerStaticClass { - public void method(String stringParameter) { - if (! stringParameter.isEmpty()) { - System.out.println(stringParameter); - } - } - } - - /* - * Return -a if a isn't negative number, otherwise return a if it's already negative number - */ - public int negate(int a){ - int r = 1; - - // FIX : precondition missing : if ( -1 b) { // FIX: if(a < b) - return b - a; - } - return a - b; - } - -} diff --git a/src/main/java/nopol_examples/nopol_example_7/NopolExample.java b/src/main/java/nopol_examples/nopol_example_7/NopolExample.java deleted file mode 100644 index 0051b6e..0000000 --- a/src/main/java/nopol_examples/nopol_example_7/NopolExample.java +++ /dev/null @@ -1,35 +0,0 @@ -package nopol_examples.nopol_example_7; - -public class NopolExample { - - /* - * Return true if a is Prime Number - */ - public boolean isPrime(int a){ - - if ( a < 0 ){ - return false; - } - - /* - * Nopol doesn't find patch after the nullness check modification - */ - - int intermediaire = a%2; - - // FIX if ( intermediaire == 0 && a!=2) - if ( intermediaire == 0 ) - return false; - - int sqrtMiddle = (int)(Math.sqrt(a)/2); - for ( int i = 3 ; i <= sqrtMiddle ; i+=2 ){ - int tmp = a%i; - if ( tmp == 0 ){ - return false; - } - } - return true; - } - - -} diff --git a/src/main/java/nopol_examples/nopol_example_8/NopolExample.java b/src/main/java/nopol_examples/nopol_example_8/NopolExample.java deleted file mode 100644 index bb5a0d9..0000000 --- a/src/main/java/nopol_examples/nopol_example_8/NopolExample.java +++ /dev/null @@ -1,24 +0,0 @@ -package nopol_examples.nopol_example_8; - -public class NopolExample { - - /* - * Return true if (a * b) <= 100 - * - */ - public boolean productLowerThan100(double a, double b){ - - // if ( a * b <= 100) // FIX - if ( a * b < 100) - return true; - - return false; - } - - public boolean subconditionCollection(double a, double b) { - if (( a * b < 11 || productLowerThan100(a, b) || ! (a < b)) || (a = -b) > 0) { - return false; - } - return true; - } -} diff --git a/src/main/java/symbolic_examples/symbolic_example_1/NopolExample.java b/src/main/java/symbolic_examples/symbolic_example_1/NopolExample.java deleted file mode 100644 index a29aa51..0000000 --- a/src/main/java/symbolic_examples/symbolic_example_1/NopolExample.java +++ /dev/null @@ -1,29 +0,0 @@ -package symbolic_examples.symbolic_example_1; - -public class NopolExample { - - /* - * Return the index char of s - * or the last if index > s.length - * or the first if index < 0 - */ - public char charAt(String s, int index){ - - if ( index == 0 ) // Fix index <= 0 - return s.charAt(0); - - if ( index < s.length() ) - return s.charAt(index); - - return s.charAt(s.length()-1); - } - - public NopolExample() { - int variableInsideConstructor; - variableInsideConstructor = 15; - index = 2 * variableInsideConstructor; - } - - private int index = 419382; - private static String s = "Overloading field name with parameter name"; -} diff --git a/src/main/java/symbolic_examples/symbolic_example_10/NopolExample.java b/src/main/java/symbolic_examples/symbolic_example_10/NopolExample.java deleted file mode 100644 index 7b93d18..0000000 --- a/src/main/java/symbolic_examples/symbolic_example_10/NopolExample.java +++ /dev/null @@ -1,14 +0,0 @@ -package symbolic_examples.symbolic_example_10; - -public class NopolExample { - - int g(int x) { - int resg = 0; - - // here there is a bug: fix is x*2 - resg = x * 3; - - return resg; - } - -} \ No newline at end of file diff --git a/src/main/java/symbolic_examples/symbolic_example_11/NopolExample.java b/src/main/java/symbolic_examples/symbolic_example_11/NopolExample.java deleted file mode 100644 index 03cf3a1..0000000 --- a/src/main/java/symbolic_examples/symbolic_example_11/NopolExample.java +++ /dev/null @@ -1,18 +0,0 @@ -package symbolic_examples.symbolic_example_11; - -public class NopolExample { - - int h(int x, int y) { - int resh = 0; - - if (y < 0) { - // here there is a bug: fix is x%5 - resh = x % 6; - } else { - resh = x - 1; - } - - return resh + 1; - } - -} \ No newline at end of file diff --git a/src/main/java/symbolic_examples/symbolic_example_12/NopolExample.java b/src/main/java/symbolic_examples/symbolic_example_12/NopolExample.java deleted file mode 100644 index 81883d1..0000000 --- a/src/main/java/symbolic_examples/symbolic_example_12/NopolExample.java +++ /dev/null @@ -1,31 +0,0 @@ -package symbolic_examples.symbolic_example_12; - -public class NopolExample { - - int i(int x, Calculator y) { - int resi = 0; - - // here there is in the concrete implementation of y - resi = y.compute(x); - - return resi * 2; - } -} - -interface Calculator { - int compute(int x); -} - -class C1 implements Calculator { - public int compute(int x) { - return x + 1; - } -} - -class C2 implements Calculator { - public int compute(int x) { - // bug: should be x+2 - int resC2 = x + 3; - return resC2; - } -} \ No newline at end of file diff --git a/src/main/java/symbolic_examples/symbolic_example_2/NopolExample.java b/src/main/java/symbolic_examples/symbolic_example_2/NopolExample.java deleted file mode 100644 index b2fd792..0000000 --- a/src/main/java/symbolic_examples/symbolic_example_2/NopolExample.java +++ /dev/null @@ -1,45 +0,0 @@ -package symbolic_examples.symbolic_example_2; - -import java.util.concurrent.Callable; - -public class NopolExample { - - /* - * Return the max between a and b - */ - public int getMax(int a, int b){ - if ( (b - a) < 0 ){ // Fix a < b - return b; - } - return a; - } - - private class InnerNopolExample { - - public int method(boolean aBoolean) { - int result = 29; - if (aBoolean) { - return result * 2; - } else { - return result * 3; - } - } - - private int fieldOfInnerClass; - } - - public Callable newCallable() { - return new Callable() { - private int limit = 114; - public Boolean call() throws Exception { - if (fieldOfOuterClass > limit) { - return true; - } else { - return false; - } - } - }; - } - - private int fieldOfOuterClass = 12302; -} diff --git a/src/main/java/symbolic_examples/symbolic_example_3/NopolExample.java b/src/main/java/symbolic_examples/symbolic_example_3/NopolExample.java index dba5e3b..873fe42 100644 --- a/src/main/java/symbolic_examples/symbolic_example_3/NopolExample.java +++ b/src/main/java/symbolic_examples/symbolic_example_3/NopolExample.java @@ -8,7 +8,7 @@ public class NopolExample { public boolean isOddNumber(int a){ int tmp = (a-1)%2; - if ( tmp != 0 ){ // Fix : tmp == 0 + if ( tmp == 0 ){ return true; } return false; diff --git a/src/main/java/symbolic_examples/symbolic_example_4/NopolExample.java b/src/main/java/symbolic_examples/symbolic_example_4/NopolExample.java deleted file mode 100644 index 9f41e5a..0000000 --- a/src/main/java/symbolic_examples/symbolic_example_4/NopolExample.java +++ /dev/null @@ -1,32 +0,0 @@ -package symbolic_examples.symbolic_example_4; - -public class NopolExample { - - /* - * return true if a can be divided by 3 - */ - - public boolean canBeDividedby3(String a) { - - int initializedVariableShouldBeCollected = 2; - int uninitializedVariableShouldNotBeCollected; - int otherInitializedVariableShouldBeCollected; - - if ( a.charAt(0)== '0' ) - return false; - - otherInitializedVariableShouldBeCollected = 34; - - /* - * FIX : (((1)+(1))<((a.length())-((1)+(1))))||(((a.length())-((1)+(1)))<=(1)) - */ - a = a.substring(1); - - if ( a.length() == 0 ){ - return false; - } - - boolean result = (Integer.parseInt(a)%3 == 0); - return result; - } -} \ No newline at end of file diff --git a/src/main/java/symbolic_examples/symbolic_example_5/NopolExample.java b/src/main/java/symbolic_examples/symbolic_example_5/NopolExample.java deleted file mode 100644 index 9598074..0000000 --- a/src/main/java/symbolic_examples/symbolic_example_5/NopolExample.java +++ /dev/null @@ -1,25 +0,0 @@ -package symbolic_examples.symbolic_example_5; - -public class NopolExample { - - public static class InnerStaticClass { - public void method(String stringParameter) { - if (! stringParameter.isEmpty()) { - System.out.println(stringParameter); - } - } - } - - /* - * Return -a if a isn't negative number, otherwise return a if it's already negative number - */ - public int negate(int a){ - int r = 1; - - // FIX : precondition missing : if ( -1 b) { // FIX: if(a < b) - return b - a; - } - return a - b; - } - -} diff --git a/src/main/java/symbolic_examples/symbolic_example_7/NopolExample.java b/src/main/java/symbolic_examples/symbolic_example_7/NopolExample.java deleted file mode 100644 index a43a04c..0000000 --- a/src/main/java/symbolic_examples/symbolic_example_7/NopolExample.java +++ /dev/null @@ -1,35 +0,0 @@ -package symbolic_examples.symbolic_example_7; - -public class NopolExample { - - /* - * Return true if a is Prime Number - */ - public boolean isPrime(int a){ - - if ( a < 0 ){ - return false; - } - - /* - * Nopol doesn't find patch after the nullness check modification - */ - - int intermediaire = a%2; - - // FIX if ( intermediaire == 0 && a!=2) - if ( intermediaire == 0 ) - return false; - - int sqrtMiddle = (int)(Math.sqrt(a)/2); - for ( int i = 3 ; i <= sqrtMiddle ; i+=2 ){ - int tmp = a%i; - if ( tmp == 0 ){ - return false; - } - } - return true; - } - - -} diff --git a/src/main/java/symbolic_examples/symbolic_example_8/NopolExample.java b/src/main/java/symbolic_examples/symbolic_example_8/NopolExample.java deleted file mode 100644 index 16044dd..0000000 --- a/src/main/java/symbolic_examples/symbolic_example_8/NopolExample.java +++ /dev/null @@ -1,24 +0,0 @@ -package symbolic_examples.symbolic_example_8; - -public class NopolExample { - - /* - * Return true if (a * b) <= 100 - * - */ - public boolean productLowerThan100(double a, double b){ - - // if ( a * b <= 100) // FIX - if ( a * b < 100 ) - return true; - - return false; - } - - public boolean subconditionCollection(double a, double b) { - if (( a * b < 11 || productLowerThan100(a, b) || ! (a < b)) || (a = -b) > 0) { - return false; - } - return true; - } -} diff --git a/src/main/java/symbolic_examples/symbolic_example_9/NopolExample.java b/src/main/java/symbolic_examples/symbolic_example_9/NopolExample.java deleted file mode 100644 index d72e102..0000000 --- a/src/main/java/symbolic_examples/symbolic_example_9/NopolExample.java +++ /dev/null @@ -1,14 +0,0 @@ -package symbolic_examples.symbolic_example_9; - -public class NopolExample { - - public int f(int x) { - int resf = 0; - - // here there is a bug: fix is x+2 - //int guess_fix=Debug.makeSymbolicInteger("guess_fix"); - //resf = x + guess_fix;//1; - resf = x + 1; - return resf; - } -} \ No newline at end of file diff --git a/src/test/java/nopol_examples/nopol_example_1/NopolExampleTest.java b/src/test/java/nopol_examples/nopol_example_1/NopolExampleTest.java deleted file mode 100644 index b6ba9ed..0000000 --- a/src/test/java/nopol_examples/nopol_example_1/NopolExampleTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package nopol_examples.nopol_example_1; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class NopolExampleTest { - - @Test - public void test1(){ - NopolExample ex = new NopolExample(); - assertEquals('a', ex.charAt("abcd", 0)); - } - - @Test - public void test2(){ - NopolExample ex = new NopolExample(); - assertEquals('d', ex.charAt("abcd", 3)); - } - - @Test - public void test3(){ - NopolExample ex = new NopolExample(); - String s = "abcd"; - assertEquals('d', ex.charAt(s, s.length()-1)); - } - - @Test - public void test4(){ - NopolExample ex = new NopolExample(); - String s = "abcd"; - assertEquals('d', ex.charAt(s, 12)); - } - - @Test - public void test5(){ - NopolExample ex = new NopolExample(); - String s = "abcd"; - assertEquals('a', ex.charAt(s, -5)); - } - - @Test - public void test6(){ - NopolExample ex = new NopolExample(); - String s = "abcd"; - assertEquals('a', ex.charAt(s, -1)); - } - - @Test - public void test7(){ - NopolExample ex = new NopolExample(); - assertEquals('c', ex.charAt("abcd", 2)); - } - - @Test - public void test8(){ - NopolExample ex = new NopolExample(); - assertEquals('b', ex.charAt("abcd", 1)); - } - - @Test - public void test9(){ - NopolExample ex = new NopolExample(); - assertEquals('f', ex.charAt("abcdefghijklm", 5)); - } -} diff --git a/src/test/java/nopol_examples/nopol_example_12/NopolExampleTest.java b/src/test/java/nopol_examples/nopol_example_12/NopolExampleTest.java deleted file mode 100644 index a3f1b37..0000000 --- a/src/test/java/nopol_examples/nopol_example_12/NopolExampleTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package nopol_examples.nopol_example_12; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class NopolExampleTest { - - - @Test - public void test_1() { - assertTrue(new NopolExample().isEmpty(Collections.EMPTY_LIST)); - } - - @Test - public void test_2() { - List list = new ArrayList<>(); - list.add(1); - assertFalse(new NopolExample().isEmpty(list)); - } - - @Test - public void test_3() { - assertTrue(new NopolExample().isEmpty(null)); - } - - @Test - public void test_4() { - List list = new ArrayList<>(); - list.add(1); - list.add(2); - list.add(3); - assertFalse(new NopolExample().isEmpty(list)); - } -} diff --git a/src/test/java/nopol_examples/nopol_example_13/NopolExampleTest.java b/src/test/java/nopol_examples/nopol_example_13/NopolExampleTest.java deleted file mode 100644 index 3488e9a..0000000 --- a/src/test/java/nopol_examples/nopol_example_13/NopolExampleTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package nopol_examples.nopol_example_13; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class NopolExampleTest { - - - @Test - public void test_1() { - assertTrue(new NopolExample().isEmpty(Collections.EMPTY_LIST)); - assertTrue(new NopolExample().isEmpty(null)); - } - - @Test - public void test_2() { - List list = new ArrayList<>(); - list.add(1); - assertFalse(new NopolExample().isEmpty(list)); - } - - @Test - public void test_3() { - List list = new ArrayList<>(); - list.add(1); - list.add(2); - list.add(3); - assertFalse(new NopolExample().isEmpty(list)); - } -} diff --git a/src/test/java/nopol_examples/nopol_example_2/NopolExampleTest.java b/src/test/java/nopol_examples/nopol_example_2/NopolExampleTest.java deleted file mode 100644 index 16899c6..0000000 --- a/src/test/java/nopol_examples/nopol_example_2/NopolExampleTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package nopol_examples.nopol_example_2; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class NopolExampleTest { - - @Test - public void test1() { - NopolExample ex = new NopolExample(); - assertEquals(4, ex.getMax(2, 4)); - } - - @Test - public void test2() { - NopolExample ex = new NopolExample(); - assertEquals(4, ex.getMax(4, 2)); - } - - @Test - public void test3() { - NopolExample ex = new NopolExample(); - assertEquals(4, ex.getMax(4, 4)); - } - - @Test - public void test4() { - NopolExample ex = new NopolExample(); - assertEquals(4, ex.getMax(4, -2)); - } - - @Test - public void test5() { - NopolExample ex = new NopolExample(); - assertEquals(4, ex.getMax(-2, 4)); - } - - @Test - public void test6() { - NopolExample ex = new NopolExample(); - assertEquals(-2, ex.getMax(-2, -4)); - } - - @Test - public void test7() { - NopolExample ex = new NopolExample(); - assertEquals(-2, ex.getMax(-4, -2)); - } - - @Test - public void test8() { - NopolExample ex = new NopolExample(); - assertEquals(-2, ex.getMax(-2, -2)); - } - - @Test - public void test9() { - NopolExample ex = new NopolExample(); - assertEquals(2, ex.getMax(2, -8)); - } - -} diff --git a/src/test/java/nopol_examples/nopol_example_3/NopolExampleTest.java b/src/test/java/nopol_examples/nopol_example_3/NopolExampleTest.java deleted file mode 100644 index 2962cc9..0000000 --- a/src/test/java/nopol_examples/nopol_example_3/NopolExampleTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package nopol_examples.nopol_example_3; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class NopolExampleTest { - - @Test - public void test1() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isOddNumber(3)); - } - @Test - public void test2() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isOddNumber(5)); - } - @Test - public void test3() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isOddNumber(-1)); - } - @Test - public void test4() { - NopolExample ex = new NopolExample(); - assertTrue(!ex.isOddNumber(2)); - } - @Test - public void test5() { - NopolExample ex = new NopolExample(); - assertTrue(!ex.isOddNumber(-8)); - } - @Test - public void test6() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isOddNumber((int)(Math.pow(2,6)+1))); - } - @Test - public void test7() { - NopolExample ex = new NopolExample(); - assertTrue(!ex.isOddNumber((int)(Math.pow(2, 3)))); - } - @Test - public void test8() { - NopolExample ex = new NopolExample(); - assertTrue(!ex.isOddNumber(100/2)); - } - @Test - public void test9() { - NopolExample ex = new NopolExample(); - assertTrue(!ex.isOddNumber(0)); - } -} diff --git a/src/test/java/nopol_examples/nopol_example_4/NopolExampleTest.java b/src/test/java/nopol_examples/nopol_example_4/NopolExampleTest.java deleted file mode 100644 index 7c3fe70..0000000 --- a/src/test/java/nopol_examples/nopol_example_4/NopolExampleTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package nopol_examples.nopol_example_4; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class NopolExampleTest { - - @Test - public void test1(){ - NopolExample ex = new NopolExample(); - assertFalse(ex.canBeDividedby3("0")); - } - - @Test - public void test2(){ - NopolExample ex = new NopolExample(); - assertFalse(ex.canBeDividedby3("00000")); - } - - @Test - public void test3(){ - NopolExample ex = new NopolExample(); - assertTrue(ex.canBeDividedby3("33")); - } - - @Test - public void test4(){ - NopolExample ex = new NopolExample(); - assertTrue(ex.canBeDividedby3("333")); - } - - @Test - public void test5(){ - NopolExample ex = new NopolExample(); - assertTrue(ex.canBeDividedby3("8142")); - } - - @Test - public void test6(){ - NopolExample ex = new NopolExample(); - assertTrue(ex.canBeDividedby3("-15339")); - } - - @Test - public void test7(){ - NopolExample ex = new NopolExample(); - assertTrue(ex.canBeDividedby3("-150333333")); - } - - @Test - public void test8(){ - NopolExample ex = new NopolExample(); - assertFalse(ex.canBeDividedby3("-1411111")); - } - - @Test - public void test9(){ - NopolExample ex = new NopolExample(); - assertFalse(ex.canBeDividedby3("-2212")); - } - - @Test - public void test10(){ - NopolExample ex = new NopolExample(); - assertFalse(ex.canBeDividedby3("-")); - } - - @Test - public void test11(){ - NopolExample ex = new NopolExample(); - assertFalse(ex.canBeDividedby3("")); - } -} - diff --git a/src/test/java/nopol_examples/nopol_example_5/NopolExampleTest.java b/src/test/java/nopol_examples/nopol_example_5/NopolExampleTest.java deleted file mode 100644 index e3ff042..0000000 --- a/src/test/java/nopol_examples/nopol_example_5/NopolExampleTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package nopol_examples.nopol_example_5; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class NopolExampleTest { - - @Test - public void test1(){ - assertEquals(-2, new NopolExample().negate(2)); - } - @Test - public void test2(){ - assertEquals(-10, new NopolExample().negate(10)); - } - @Test - public void test3(){ - assertEquals(0, new NopolExample().negate(0)); - } - @Test - public void test4(){ - assertEquals(-2, new NopolExample().negate(-2)); - } - @Test - public void test5(){ - assertEquals(-5, new NopolExample().negate(-5)); - } - @Test - public void test6(){ - assertEquals(-1, new NopolExample().negate(1)); - } -} diff --git a/src/test/java/nopol_examples/nopol_example_6/NopolExampleTest.java b/src/test/java/nopol_examples/nopol_example_6/NopolExampleTest.java deleted file mode 100644 index fc87c4b..0000000 --- a/src/test/java/nopol_examples/nopol_example_6/NopolExampleTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package nopol_examples.nopol_example_6; - -import junit.framework.TestCase; - -public class NopolExampleTest extends TestCase { - - public void test1() - { - NopolExample program = new NopolExample(); - assertEquals(program.abs(3, 5), 2); - } - - public void test2() - { - NopolExample program = new NopolExample(); - assertEquals(program.abs(5, 3), 2); - } - - public void test3() - { - NopolExample program = new NopolExample(); - assertEquals(program.abs(4, 0), 4); - } - - public void test4() - { - NopolExample program = new NopolExample(); - assertEquals(program.abs(0, 4), 4); - } - - public void test5() - { - NopolExample program = new NopolExample(); - assertEquals(program.abs(1, 1), 0); - } - - public void test6() - { - NopolExample program = new NopolExample(); - assertEquals(program.abs(0, -3), 3); - } -} diff --git a/src/test/java/nopol_examples/nopol_example_7/NopolExampleTest.java b/src/test/java/nopol_examples/nopol_example_7/NopolExampleTest.java deleted file mode 100644 index fe93723..0000000 --- a/src/test/java/nopol_examples/nopol_example_7/NopolExampleTest.java +++ /dev/null @@ -1,178 +0,0 @@ -package nopol_examples.nopol_example_7; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class NopolExampleTest { - - /* - * Prime Number : - * 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 - */ - - @Test - public void test1() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(2)); - } - - @Test - public void test2() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(3)); - } - - @Test - public void test3() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(5)); - } - - @Test - public void test4() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(7)); - } - @Test - public void test5() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(11)); - } - @Test - public void test6() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(13)); - } - @Test - public void test7() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(17)); - } - @Test - public void test8() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(19)); - } - @Test - public void test9() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(23)); - } - @Test - public void test10() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(29)); - } - @Test - public void test11() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(31)); - } - @Test - public void test12() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(37)); - } - @Test - public void test13() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(41)); - } - @Test - public void test14() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(43)); - } - @Test - public void test15() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(47)); - } - @Test - public void test16() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(53)); - } - @Test - public void test17() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(59)); - } - @Test - public void test18() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(61)); - } - @Test - public void test19() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(67)); - } - @Test - public void test20() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(71)); - } - @Test - public void test21() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(73)); - } - @Test - public void test22() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(79)); - } - @Test - public void test23() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(83)); - } - @Test - public void test24() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(89)); - } - @Test - public void test25() { - NopolExample ex = new NopolExample(); - assertTrue(ex.isPrime(97)); - } - @Test - public void test26() { - NopolExample ex = new NopolExample(); - assertFalse(ex.isPrime(4)); - } - - @Test - public void test27() { - NopolExample ex = new NopolExample(); - assertFalse(ex.isPrime(42)); - } - - @Test - public void test28() { - NopolExample ex = new NopolExample(); - assertFalse(ex.isPrime(81)); - } - - @Test - public void test29() { - NopolExample ex = new NopolExample(); - assertFalse(ex.isPrime(102)); - } - - @Test - public void test30() { - NopolExample ex = new NopolExample(); - assertFalse(ex.isPrime(225)); - } - - @Test - public void test31() { - NopolExample ex = new NopolExample(); - assertFalse(ex.isPrime(-231)); - } -} diff --git a/src/test/java/nopol_examples/nopol_example_8/NopolExampleTest.java b/src/test/java/nopol_examples/nopol_example_8/NopolExampleTest.java deleted file mode 100644 index b32135d..0000000 --- a/src/test/java/nopol_examples/nopol_example_8/NopolExampleTest.java +++ /dev/null @@ -1,67 +0,0 @@ -package nopol_examples.nopol_example_8; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class NopolExampleTest { - - @Test - public void test_1() { - assertTrue(new NopolExample().productLowerThan100(5, 5)); - } - - @Test - public void test_2() { - assertTrue(new NopolExample().productLowerThan100(2, 50)); - } - - @Test - public void test_3() { - assertTrue(new NopolExample().productLowerThan100(50, 1)); - } - - @Test - public void test_4() { - assertTrue(new NopolExample().productLowerThan100(7, 8)); - } - - @Test - public void test_5() { - assertTrue(new NopolExample().productLowerThan100(9, 9)); - } - - @Test - public void test_6() { - assertTrue(new NopolExample().productLowerThan100(0, 1)); - } - - @Test - public void test_7() { - assertFalse(new NopolExample().productLowerThan100(5, 50)); - } - - @Test - public void test_8() { - assertFalse(new NopolExample().productLowerThan100(50, 50)); - } - - @Test - public void test_9() { - assertFalse(new NopolExample().productLowerThan100(101, 1)); - } - - @Test - public void test_10() { - assertFalse(new NopolExample().productLowerThan100(8451, 4897)); - } - - public void test_11() { - assertTrue(new NopolExample().productLowerThan100(50, 1)); - } - - public void test_12() { - assertFalse(new NopolExample().productLowerThan100(50, 3)); - } -}