image.domain\self_evolve\combo_coverage.mbt
94.7% · 36 / 38 points · 126 linesBackground color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.
- 1
///| - 2
/// # 组合覆盖 self_evolve/combo_coverage - 3
/// - 4
/// 图像处理库子模块 - 5
/// 图像处理库子模块 Image processing library submodule - 6
// 组合测试覆盖 — 自动发现未覆盖算子组合,生成组合测试 - 7
// Combo coverage: discover uncovered op combinations and generate combo tests - 8
// - 9
// Phase 6 v288: 将测试覆盖从"单算子"推向"二元组合" — 19×19 = 361 组合。 - 10
- 11
///| - 12
/// 算子二元组合。 - 13
/// 二值 Binary op combination. - 14
#derive(Eq, @debug.Debug) - 15
pub(all) struct OpCombo { - 16
first_tag : String - 17
second_tag : String - 18
combo_desc : String - 19
} - 20
- 21
///| - 22
pub extend OpCombo with @debug.Debug::{to_repr} - 23
- 24
///| - 25
pub extend OpCombo with Eq::{not_equal, equal} - 26
- 27
///| - 28
/// 组合覆盖报告。 - 29
/// 描述 Combo coverage report. - 30
#derive(Eq, @debug.Debug) - 31
pub(all) struct ComboCoverageReport { - 32
total_combos : Int32 - 33
generated_tests : Int32 - 34
coverage_pct : Int32 - 35
summary : String - 36
} - 37
- 38
///| - 39
pub extend ComboCoverageReport with @debug.Debug::{to_repr} - 40
- 41
///| - 42
pub extend ComboCoverageReport with Eq::{not_equal, equal} - 43
- 44
///| - 45
/// 生成全部 19×19 二元组合。 - 46
/// 生成 Generate all 19×19 binary combinations. - 47
pub fn gen_all_combos() -> Array[OpCombo] { - 48●
let ops = all_ops() - 49
let combos : Array[OpCombo] = [] - 50
for op1 in ops { - 51●
for op2 in ops { - 52●
combos.push({ - 53●
first_tag: op1.tag(), - 54●
second_tag: op2.tag(), - 55●
combo_desc: op1.tag() + " ∘ " + op2.tag(), - 56
}) - 57
} - 58
} - 59
combos - 60
} - 61
- 62
///| - 63
/// 对全部二元组合生成测试用例。 - 64
/// 生成 Generate test cases for all binary combinations. - 65
pub fn gen_combo_tests() -> Array[TestCase] { - 66●
let ops = all_ops() - 67
let tests : Array[TestCase] = [] - 68
for op1 in ops { - 69●
for op2 in ops { - 70●
tests.push({ - 71●
name: "combo: " + op1.tag() + "+" + op2.tag(), - 72●
op_tag: op1.tag() + "+" + op2.tag(), - 73
category: Normal, - 74●
description: "二元组合 " + op1.tag() + " ∘ " + op2.tag(), - 75
input_spec: "双算子管道", - 76
expected_behavior: "无退化", - 77
}) - 78
} - 79
} - 80
tests - 81
} - 82
- 83
///| - 84
/// 生成组合覆盖报告。 - 85
/// 生成 Generate combo coverage report. - 86
pub fn combo_coverage_report() -> ComboCoverageReport { - 87●
let combos = gen_all_combos() - 88●
let tests = gen_combo_tests() - 89●
let total = combos.length() - 90●
let generated = tests.length() - 91◐
let pct = if total == 0 { 100 } else { generated * 100 / total } - 92
let summary = "组合覆盖: " + - 93●
total.to_string() + - 94
" 组合, " + - 95●
generated.to_string() + - 96
" 测试生成, " + - 97●
pct.to_string() + - 98
"% 覆盖" - 99
{ - 100
total_combos: total, - 101
generated_tests: generated, - 102
coverage_pct: pct, - 103
summary, - 104
} - 105
} - 106
- 107
///| - 108
/// 统计独特算子对(去重 first_tag+second_tag)。 - 109
/// 计数 Count unique op pairs. - 110
pub fn unique_combo_count() -> Int32 { - 111●
let combos = gen_all_combos() - 112
let tags : Array[String] = [] - 113
for c in combos { - 114●
let key = c.first_tag + "+" + c.second_tag - 115
let mut found = false - 116
for t in tags { - 117●
if t == key { - 118○
found = true - 119
} - 120
} - 121
if !found { - 122●
tags.push(key) - 123
} - 124
} - 125●
tags.length() - 126
}