Skip to content

Commit

Permalink
Prevent logical errors in IF command, fixes #515
Browse files Browse the repository at this point in the history
- a double compared to not-a-double should not pass (Always fail that)
[for #515 ]
... idea for future: Certain doubles could return true (EG, 1 or higher
passes, below 1 fails?)
- also prevent list arguments like "li@3||2" from becoming "li@3OR2" by
only changing bridges and comparisonoperators when actually needed.
[Related to #519 ]
  • Loading branch information
mcmonkey4eva committed Nov 16, 2013
1 parent 2a1ff83 commit 597b534
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Expand Up @@ -145,11 +145,12 @@ else if (comparable instanceof dList) {
}

else if (comparable instanceof Double) {
compare_as_numbers();
if (comparedto instanceof Double) {
compare_as_numbers();
}
}

else if (comparable instanceof Boolean) {

// Check to make sure comparedto is Boolean
if (comparedto instanceof Boolean) {
// Comparing booleans.. let's do the logic
Expand Down Expand Up @@ -193,7 +194,6 @@ private void compare_as_numbers() {
if (comparable.compareTo(comparedto) < 0) outcome = true;
break;
}

}


Expand Down
Expand Up @@ -63,8 +63,13 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
}

// Replace symbol-operators/bridges with ENUM value for matching
arg.replaceValue(arg.getValue().replace("==", "EQUALS").replace(">=", "OR_MORE").replace("<=", "OR_LESS")
.replace("<", "LESS").replace(">", "MORE").replace("||", "OR").replace("&&", "AND"));
if (arg.getValue().equals("==")) arg.replaceValue("EQUALS");
else if (arg.getValue().equals(">=")) arg.replaceValue("OR_MORE");
else if (arg.getValue().equals("<=")) arg.replaceValue("OR_LESS");
else if (arg.getValue().equals("<")) arg.replaceValue("LESS");
else if (arg.getValue().equals(">")) arg.replaceValue("MORE");
else if (arg.getValue().equals("||")) arg.replaceValue("OR");
else if (arg.getValue().equals("&&")) arg.replaceValue("AND");

// Set bridge
if (arg.matchesEnum(Comparable.Bridge.values())) {
Expand Down

0 comments on commit 597b534

Please sign in to comment.