Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more tests for nested f-string spec
  • Loading branch information
palaviv committed Dec 27, 2019
commit 8e84a85b0ceeb244f0b8c29b63353c55a2f966cd
12 changes: 7 additions & 5 deletions parser/src/fstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ impl<'a> FStringParser<'a> {
'{' => {
if in_nested {
return Err(ExpressionNestedTooDeeply);
} else {
in_nested = true;
nested = true;
self.chars.next();
continue;
}
in_nested = true;
nested = true;
self.chars.next();
continue;
}
'}' => {
if in_nested {
Expand Down Expand Up @@ -295,6 +294,9 @@ mod tests {
fn test_parse_invalid_fstring() {
assert_eq!(parse_fstring("{"), Err(UnclosedLbrace));
assert_eq!(parse_fstring("}"), Err(UnopenedRbrace));
assert_eq!(parse_fstring("{a:{a:{b}}"), Err(ExpressionNestedTooDeeply));
assert_eq!(parse_fstring("{a:b}}"), Err(UnopenedRbrace));
assert_eq!(parse_fstring("{a:{b}"), Err(UnclosedLbrace));

// TODO: check for InvalidExpression enum?
assert!(parse_fstring("{class}").is_err());
Expand Down