Browse Source

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

accumulation-v4.7
Joachim Klein 7 years ago
committed by Joachim Klein
parent
commit
32b870eba9
  1. 23
      prism/src/parser/ast/Property.java

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

@ -205,17 +205,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.doublesAreEqual(((Double) constValToMatch).doubleValue(), DefinedConstant.parseDouble(constVal));
} else if (constValToMatch instanceof Double) {
try {
match = PrismUtils.doublesAreEqual(((Double) constValToMatch).doubleValue(), DefinedConstant.parseDouble(constVal));
} 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