| 28 | } |
| 29 | |
| 30 | pub fn handle_roundtrip(catalog: &TestCatalog, input: &str) -> String { |
| 31 | let output = match try_parse_mir(catalog, input) { |
| 32 | Ok(expr) => expr.debug_explain(&ExplainConfig::default(), Some(catalog)), |
| 33 | Err(err) => return err, |
| 34 | }; |
| 35 | |
| 36 | if strip_comments(input).trim() == output.trim() { |
| 37 | "roundtrip OK\n".to_string() |
| 38 | } else { |
| 39 | format!( |
| 40 | "roundtrip produced a different output:\n~~~ expected:\n{}\n~~~ actual:\n{}\n~~~\n", |
| 41 | strip_comments(input), |
| 42 | output |
| 43 | ) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | fn strip_comments(s: &str) -> String { |
| 48 | let mut r = "".to_string(); |