| 22 | const OPTIMIZER_RULE_REFERENCE: &str = include_str!("optimizer_rule_reference.md"); |
| 23 | |
| 24 | fn documented_rules(section_heading: &str) -> Vec<String> { |
| 25 | let mut in_section = false; |
| 26 | let mut names = vec![]; |
| 27 | |
| 28 | for line in OPTIMIZER_RULE_REFERENCE.lines() { |
| 29 | if line == section_heading { |
| 30 | in_section = true; |
| 31 | continue; |
| 32 | } |
| 33 | |
| 34 | if in_section && line.starts_with("### ") { |
| 35 | break; |
| 36 | } |
| 37 | |
| 38 | if !in_section || !line.starts_with('|') || line.contains("---") { |
| 39 | continue; |
| 40 | } |
| 41 | |
| 42 | let columns: Vec<_> = line.split('|').map(str::trim).collect(); |
| 43 | |
| 44 | if columns.len() < 4 || columns[1] == "order" { |
| 45 | continue; |
| 46 | } |
| 47 | |
| 48 | names.push(columns[2].trim_matches('`').to_string()); |
| 49 | } |
| 50 | |
| 51 | names |
| 52 | } |
| 53 | |
| 54 | #[test] |
| 55 | fn analyzer_rules_match_documented_order() { |