diff --git a/crates/testing-framework/src/transform/mod.rs b/crates/testing-framework/src/transform/mod.rs index 1473aec3..38e209aa 100644 --- a/crates/testing-framework/src/transform/mod.rs +++ b/crates/testing-framework/src/transform/mod.rs @@ -54,6 +54,7 @@ pub(crate) enum Sexp { List(Vec), Symbol(String), String(String), + RawString(String), } impl Sexp { @@ -69,6 +70,10 @@ impl Sexp { Self::String(value.to_string()) } + pub(crate) fn raw_string(value: impl ToString) -> Self { + Self::RawString(value.to_string()) + } + pub(crate) fn canon(peer: Sexp, stream: Sexp, target: Sexp) -> Self { Self::Canon(Box::new(Canon { peer, @@ -103,6 +108,9 @@ impl Sexp { Sexp::String(ref s) => Err(format!( r#"cannot attach a service definition to a string: "{s:?}""# )), + Sexp::RawString(ref s) => Err(format!( + r#"cannot attach a service definition to a raw string: "{s:?}""# + )), } } } @@ -138,9 +146,9 @@ impl std::fmt::Display for Sexp { Sexp::Embed(embed) => { write!( f, - "(embed [{args}] #"{script}"#{var})", + r##"(embed [{args}] {script}{var})"##, args = embed.args.iter().format(" "), - script = embed.script, + script = dbg!(&embed.script), var = match &embed.var { Some(var) => format!(" {var}"), None => "".to_owned(), @@ -150,6 +158,7 @@ impl std::fmt::Display for Sexp { Sexp::List(items) => write!(f, "({})", items.iter().format(" ")), Sexp::Symbol(symbol) => write!(f, "{symbol}"), Sexp::String(string) => write!(f, r#""{string}""#), + Sexp::RawString(string) => write!(f, r##"#"{string}"#"##), } } } diff --git a/crates/testing-framework/src/transform/parser.rs b/crates/testing-framework/src/transform/parser.rs index 7480a30f..036bf94e 100644 --- a/crates/testing-framework/src/transform/parser.rs +++ b/crates/testing-framework/src/transform/parser.rs @@ -161,7 +161,7 @@ fn parse_raw_string(inp: Input<'_>) -> IResult, Sexp, ParseError<'_>> )), ), ), - Sexp::string, + Sexp::raw_string, )(inp) } @@ -525,13 +525,13 @@ mod tests { #[tokio::test] async fn test_empty_raw_string() { let res = Sexp::from_str(r##"#""#"##); - assert_eq!(res, Ok(Sexp::string(""))); + assert_eq!(res, Ok(Sexp::raw_string(""))); } #[tokio::test] async fn test_raw_string() { let res = Sexp::from_str(r##"#"str " ing"#"##); - assert_eq!(res, Ok(Sexp::string("str \" ing"))); + assert_eq!(res, Ok(Sexp::raw_string("str \" ing"))); } #[tokio::test] diff --git a/crates/testing-framework/src/transform/walker.rs b/crates/testing-framework/src/transform/walker.rs index 6054f7a6..670ed034 100644 --- a/crates/testing-framework/src/transform/walker.rs +++ b/crates/testing-framework/src/transform/walker.rs @@ -98,7 +98,7 @@ impl Transformer<'_, R> { self.transform(child, test_init_parameters).await; } } - Sexp::Embed(_) | Sexp::Symbol(_) | Sexp::String(_) => {} + Sexp::Embed(_) | Sexp::Symbol(_) | Sexp::String(_) | Sexp::RawString(_) => {} } }