forked from jeffoffutt/muJava
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing another rule 43 implementation.
- Loading branch information
Showing
6 changed files
with
58 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,65 @@ | ||
package mujava.util.drule; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.Semaphore; | ||
|
||
public class DRuleUtils { | ||
public enum MOperator { | ||
AOIU, | ||
AOIU, | ||
ASRS | ||
}; | ||
static Map<MOperator, List<MutationInfo>> selectedOperators = new HashMap<>(); | ||
} | ||
|
||
; | ||
static Semaphore sem = new Semaphore(1, true); | ||
static DRuleUtils instance = new DRuleUtils(); | ||
static List<String> allOperatorsSelected = new ArrayList<>(); | ||
static List<MutationInfo> mutationInfoList = new ArrayList<>(); | ||
|
||
DRuleUtils () { | ||
DRuleUtils() { | ||
|
||
} | ||
|
||
public static DRuleUtils access() { | ||
return instance; | ||
} | ||
/** | ||
* Checks whether a certain mutation was done with some operator | ||
* and then removes it from memory | ||
* | ||
* @param operator enum corresponding to the operator intended to lookup | ||
* @param operation the kind of mutation to lookup | ||
*/ | ||
public boolean consumeOperation(MOperator operator, MutationInfo operation) { | ||
boolean r = false; | ||
public boolean addMutation(MutationInfo mutationInfo) { | ||
boolean ret = false; | ||
try { | ||
synchronized (this) { | ||
sem.acquire(); | ||
r = selectedOperators.containsKey(operator) && selectedOperators.get(operator).contains(operation); | ||
if (r) { | ||
selectedOperators.get(operator).remove(operation); | ||
selectedOperators.remove(operator); | ||
if (!mutationInfoList.contains(mutationInfo)) { | ||
ret = true; | ||
mutationInfoList.add(mutationInfo); | ||
} | ||
sem.release(); | ||
} | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
return r; | ||
return ret; | ||
} | ||
|
||
/** | ||
* Inserts a certain mutation that was done with some operator | ||
* and then removes it from memory | ||
* | ||
* @param operator a String corresponding the operator intended to lookup | ||
* @param operation the kind of mutation to lookup | ||
*/ | ||
public boolean insertMutation(MOperator operator, MutationInfo operation) { | ||
boolean r = false; | ||
public boolean containsMutation(MutationInfo mutationInfo) { | ||
boolean ret = false; | ||
try { | ||
synchronized (this) { | ||
sem.acquire(); | ||
if (!selectedOperators.containsKey(operator)) selectedOperators.put(operator, new ArrayList<>()); | ||
if (!selectedOperators.get(operator).contains(operation)) { | ||
selectedOperators.get(operator).add(operation); | ||
r = true; | ||
} | ||
ret = mutationInfoList.contains(mutationInfo); | ||
sem.release(); | ||
} | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
return r; | ||
return ret; | ||
} | ||
|
||
public boolean isOperatorSelected(String op) { | ||
return allOperatorsSelected.contains(op); | ||
} | ||
|
||
public void setSelectedOperators(List<String> allOperatorsSelected) { | ||
this.allOperatorsSelected = allOperatorsSelected; | ||
} | ||
|
||
public static DRuleUtils access() { | ||
return instance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
package mujava.util.drule; | ||
|
||
public interface MutationInfo { | ||
boolean equals(MutationInfo other); | ||
public class MutationInfo { | ||
public enum DRule { | ||
RULE43, | ||
RULE49, | ||
RULE52, | ||
RULE56, | ||
RULE57, | ||
RULE66, | ||
RULE69, | ||
RULE70 | ||
} | ||
|
||
DRule rule; | ||
DRuleUtils.MOperator operator; | ||
String classname; | ||
|
||
public MutationInfo(DRuleUtils.MOperator operator, DRule rule, String classname) { | ||
|
||
} | ||
public boolean equals(MutationInfo other) { | ||
return this.rule.equals(other.rule) && this.operator.equals(other.operator) | ||
&& this.classname.equals(other.classname); | ||
} | ||
} |