From 29c98d4a2f11f9b8df83cc60422fd1945649e219 Mon Sep 17 00:00:00 2001 From: yt2b Date: Sat, 20 Jan 2024 15:30:38 +0900 Subject: [PATCH] Add test --- ...ng__tests__parse_fstring_escaped_brackets.snap | 15 +++++++++++++++ parser/src/string.rs | 7 +++++++ 2 files changed, 22 insertions(+) create mode 100644 parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_escaped_brackets.snap diff --git a/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_escaped_brackets.snap b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_escaped_brackets.snap new file mode 100644 index 0000000..7e458fd --- /dev/null +++ b/parser/src/snapshots/rustpython_parser__string__tests__parse_fstring_escaped_brackets.snap @@ -0,0 +1,15 @@ +--- +source: parser/src/string.rs +expression: parse_ast +--- +[ + Constant( + ExprConstant { + range: 0..10, + value: Str( + "\\{x\\}", + ), + kind: None, + }, + ), +] diff --git a/parser/src/string.rs b/parser/src/string.rs index 3f5f1a2..750eaa7 100644 --- a/parser/src/string.rs +++ b/parser/src/string.rs @@ -960,6 +960,13 @@ mod tests { insta::assert_debug_snapshot!(parse_ast); } + #[test] + fn test_parse_fstring_escaped_brackets() { + let source = "\\{{x\\}}"; + let parse_ast = parse_fstring(source).unwrap(); + insta::assert_debug_snapshot!(parse_ast); + } + #[test] fn test_parse_string_concat() { let source = "'Hello ' 'world'";