From 32b870eba96de8f950fd4558f26a960709269a0c Mon Sep 17 00:00:00 2001 From: Joachim Klein Date: Fri, 12 Oct 2018 14:24:54 +0200 Subject: [PATCH] imported patch catch-malformed-constants-in-results.patch --- prism/src/parser/ast/Property.java | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/prism/src/parser/ast/Property.java b/prism/src/parser/ast/Property.java index 4fec06c1..3c8275ba 100644 --- a/prism/src/parser/ast/Property.java +++ b/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;