Browse Source

imported patch catch-malformed-constants-in-results.patch

tud-infrastructure-2018-10-12
Joachim Klein 7 years ago
parent
commit
1a7e4100c7
  1. 23
      prism/src/parser/ast/Property.java

23
prism/src/parser/ast/Property.java

@ -186,17 +186,28 @@ public class Property extends ASTElement
} else {
constValToMatch = constValues.getValueOf(constName);
}
if (constValToMatch == null)
if (constValToMatch == null) {
match = false;
// Check doubles numerically
else if (constValToMatch instanceof Double)
match = PrismUtils.doublesAreCloseRel(((Double) constValToMatch).doubleValue(), DefinedConstant.parseDouble(constVal), 1e-10);
} else if (constValToMatch instanceof Double) {
try {
match = PrismUtils.doublesAreCloseRel(((Double) constValToMatch).doubleValue(), DefinedConstant.parseDouble(constVal), 1e-10);
} catch (NumberFormatException e) {
// we currently ignore malformed constants
match = false;
}
// if constant is exact rational number, compare exactly
else if (constValToMatch instanceof BigRational)
match = BigRational.from(constVal).equals(constValToMatch);
} else if (constValToMatch instanceof BigRational) {
try {
match = BigRational.from(constVal).equals(constValToMatch);
} catch (NumberFormatException e) {
// we currently ignore malformed constants
match = false;
}
// Otherwise just check for exact string match for now
else
} else {
match = constValToMatch.toString().equals(constVal);
}
// We need all constants to match
allMatch &= match;

Loading…
Cancel
Save