Commit d9967b59 by Maxime Perrotin

### Fix regression in decision branch coverage

parent 62e7b074
 ... @@ -3504,6 +3504,7 @@ def decision(root, parent, context): ... @@ -3504,6 +3504,7 @@ def decision(root, parent, context): if not q_basic.kind.startswith(('Integer', 'Real')): if not q_basic.kind.startswith(('Integer', 'Real')): # Check numeric questions - ignore others # Check numeric questions - ignore others continue continue delta = 1 if q_basic.kind.startswith('Integer') else 1e-10 # numeric type -> find the range covered by this answer # numeric type -> find the range covered by this answer if a_basic.Min != a_basic.Max: if a_basic.Min != a_basic.Max: # Not a constant or a raw number, range is not fix # Not a constant or a raw number, range is not fix ... @@ -3522,13 +3523,13 @@ def decision(root, parent, context): ... @@ -3522,13 +3523,13 @@ def decision(root, parent, context): elif ans.openRangeOp == ogAST.ExprLt: elif ans.openRangeOp == ogAST.ExprLt: # answer < X means covered range is [min; X[ # answer < X means covered range is [min; X[ if qmin < val_a: if qmin < val_a: covered_ranges[ans].append((qmin, val_a - 1e-10)) covered_ranges[ans].append((qmin, val_a - delta)) else: else: reachable = False reachable = False elif ans.openRangeOp == ogAST.ExprGt: elif ans.openRangeOp == ogAST.ExprGt: # answer > X means covered range is ]X; max] # answer > X means covered range is ]X; max] if qmax > val_a: if qmax > val_a: covered_ranges[ans].append((val_a + 1e-10, qmax)) covered_ranges[ans].append((val_a + delta, qmax)) else: else: reachable = False reachable = False elif ans.openRangeOp == ogAST.ExprGe: elif ans.openRangeOp == ogAST.ExprGe: ... @@ -3545,12 +3546,12 @@ def decision(root, parent, context): ... @@ -3545,12 +3546,12 @@ def decision(root, parent, context): elif ans.openRangeOp == ogAST.ExprNeq: elif ans.openRangeOp == ogAST.ExprNeq: # answer != X means covered range is [min; X[;]X; max] # answer != X means covered range is [min; X[;]X; max] if qmin == val_a: if qmin == val_a: covered_ranges[ans].append((qmin + 1e-10, qmax)) covered_ranges[ans].append((qmin + delta, qmax)) elif qmax == val_a: elif qmax == val_a: covered_ranges[ans].append((qmin, qmax - 1e-10)) covered_ranges[ans].append((qmin, qmax - delta)) elif qmin < val_a < qmax: elif qmin < val_a < qmax: covered_ranges[ans].append((qmin, val_a - 1e-10)) covered_ranges[ans].append((qmin, val_a - delta)) covered_ranges[ans].append((val_a + 1e-10, qmax)) covered_ranges[ans].append((val_a + delta, qmax)) else: else: warnings.append(['Condition is always true: {} /= {}' warnings.append(['Condition is always true: {} /= {}' .format(dec.inputString, .format(dec.inputString, ... @@ -3596,6 +3597,7 @@ def decision(root, parent, context): ... @@ -3596,6 +3597,7 @@ def decision(root, parent, context): q_basic = find_basic_type(dec.question.exprType) q_basic = find_basic_type(dec.question.exprType) if not q_basic.kind.startswith(('Integer', 'Real')): if not q_basic.kind.startswith(('Integer', 'Real')): continue continue delta = 1 if q_basic.kind.startswith('Integer') else 1e-10 # numeric type -> find the range covered by this answer # numeric type -> find the range covered by this answer a0_basic = find_basic_type(ans.closedRange[0].exprType) a0_basic = find_basic_type(ans.closedRange[0].exprType) a1_basic = find_basic_type(ans.closedRange[1].exprType) a1_basic = find_basic_type(ans.closedRange[1].exprType) ... @@ -3611,12 +3613,12 @@ def decision(root, parent, context): ... @@ -3611,12 +3613,12 @@ def decision(root, parent, context): if a0_val < qmin: if a0_val < qmin: qwarn.append('Decision "{dec}": ' qwarn.append('Decision "{dec}": ' 'Range {a0} .. {qmin} is unreachable' 'Range {a0} .. {qmin} is unreachable' .format(a0=a0_val, qmin=round(qmin - 1e-10, 9), .format(a0=a0_val, qmin=round(qmin - delta, 9), dec=dec.inputString)) dec=dec.inputString)) if a1_val > qmax: if a1_val > qmax: qwarn.append('Decision "{dec}": ' qwarn.append('Decision "{dec}": ' 'Range {qmax} .. {a1} is unreachable' 'Range {qmax} .. {a1} is unreachable' .format(qmax=round(qmax + 1e-10), a1=a1_val, .format(qmax=round(qmax + delta), a1=a1_val, dec=dec.inputString)) dec=dec.inputString)) if (a0_val < qmin and a1_val < qmin) or (a0_val > qmax and if (a0_val < qmin and a1_val < qmin) or (a0_val > qmax and a1_val > qmax): a1_val > qmax): ... @@ -3658,8 +3660,8 @@ def decision(root, parent, context): ... @@ -3658,8 +3660,8 @@ def decision(root, parent, context): continue continue for mina, maxa in ranges: for mina, maxa in ranges: for minq, maxq in q_ranges: for minq, maxq in q_ranges: left = (minq, min(maxq, mina - 1e-10)) left = (minq, min(maxq, mina - delta)) right = (max(minq, maxa + 1e-10), maxq) right = (max(minq, maxa + delta), maxq) if mina > minq and maxa < maxq: if mina > minq and maxa < maxq: new_q_ranges.extend([left, right]) new_q_ranges.extend([left, right]) elif mina <= minq and maxa >= maxq: elif mina <= minq and maxa >= maxq: ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!