MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / handle_roundtrip

Function handle_roundtrip

src/expr-parser/src/command.rs:30–45  ·  view source on GitHub ↗
(catalog: &TestCatalog, input: &str)

Source from the content-addressed store, hash-verified

28}
29
30pub 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
47fn strip_comments(s: &str) -> String {
48 let mut r = "".to_string();

Callers 1

run_roundtrip_testsFunction · 0.85

Calls 5

try_parse_mirFunction · 0.85
strip_commentsFunction · 0.85
debug_explainMethod · 0.45
trimMethod · 0.45
to_stringMethod · 0.45

Tested by 1

run_roundtrip_testsFunction · 0.68