fix: 覆盖率统计全面修复 + 5漏洞修正

## 修复内容

### C1: _mark_eval 反向操作符 (coverage.py)
- EVALUATE 约束匹配支持  操作符
- WHEN OTHER 的自动检测(全部 WHEN 被否定时)

### C2: _mark_perform 反向操作符 (coverage.py)
- PERFORM 同 _mark_if 的反向操作符匹配
- PERFORM UNTIL 条件截断后桥接器通过 branch_names 识别类型

### H1: parse_single_condition 传递 fields (coverage.py)
- collect_decision_points 调用时传 fields 参数
- NOT 前缀条件解析 (NOT WS-X > 50 → WS-X <= 50)

### H4: generate_data 输入约束 (__init__.py)
- 文档注明接收原始源码,非预处理后文本

### M1: not_map break (cond.py)
- NOT 操作符映射循环添加 break

## 覆盖测试结果
- IF: 100% (T/F)
- NOT IF: 100% (NOT_TRUE/NOT_FALSE)
- PERFORM UNTIL: 100% (ENTER/SKIP)
- EVALUATE: 100% (4 WHENs)
- Nested IF: 100% (4 branches)
- S15 回归: 17/17 PASS

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
NB-076
2026-06-24 21:14:50 +08:00
parent 7fb9304212
commit e2a8d53e60
6 changed files with 104 additions and 15 deletions
+15
View File
@@ -88,6 +88,21 @@ def parse_single_condition(text, fields=None):
if re.match(r'^[A-Z][A-Z0-9-]*(?:\([^)]*\))?$', fn, re.IGNORECASE):
return (fn, '<>', 'Y')
# NOT at start of condition: NOT WS-X > 50 → WS-X <= 50
# Strip leading NOT, parse the inner condition, invert the operator
if text.upper().startswith('NOT '):
inner = text[4:].strip()
inner_parsed = None
# Try standard regex on inner text
m_inner = re.match(r"^(\w[\w-]*(?:\s*\([^)]*\))?)\s*(>=|<=|<>|>|<|=)\s*(.+)$", inner)
if m_inner:
inv_op_map = {'=': '<>', '<>': '=', '>': '<=', '<': '>=', '>=': '<', '<=': '>'}
f = re.sub(r'\s*([(),])\s*', r'\1', m_inner.group(1))
op = m_inner.group(2)
val = m_inner.group(3).strip().strip("'").strip('"')
inv = inv_op_map.get(op, op)
return (f, inv, val)
# Normalize COBOL NOT-operators: X NOT = Y → X <> Y
normalized = text
not_map = [