mirror of
https://github.com/fluencelabs/aquavm
synced 2025-04-25 07:12:16 +00:00
Implement RawString in testing-framework
Keep original string type to avoid incorrect transformed script generation.
This commit is contained in:
parent
7b746e3288
commit
c38a1b9343
@ -54,6 +54,7 @@ pub(crate) enum Sexp {
|
||||
List(Vec<Sexp>),
|
||||
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}"#"##),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ fn parse_raw_string(inp: Input<'_>) -> IResult<Input<'_>, 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]
|
||||
|
@ -98,7 +98,7 @@ impl<R: AirRunner> Transformer<'_, R> {
|
||||
self.transform(child, test_init_parameters).await;
|
||||
}
|
||||
}
|
||||
Sexp::Embed(_) | Sexp::Symbol(_) | Sexp::String(_) => {}
|
||||
Sexp::Embed(_) | Sexp::Symbol(_) | Sexp::String(_) | Sexp::RawString(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user