From 1622c8f2daa2694b80451acc9268037eff2a8486 Mon Sep 17 00:00:00 2001 From: Zanie Date: Fri, 14 Jul 2023 11:59:43 -0500 Subject: [PATCH] Add multiline type alias tests with line continuations --- parser/src/parser.rs | 8 +++ ...parser__tests__parse_type_declaration.snap | 72 +++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/parser/src/parser.rs b/parser/src/parser.rs index b3914bf..58ff722 100644 --- a/parser/src/parser.rs +++ b/parser/src/parser.rs @@ -912,6 +912,14 @@ type X[T: (int, str), *Ts, **P] = (T, Ts, P) type type = int type match = int type case = int + +# multine definitions +type \ + X = int +type X \ + = int +type X = \ + int "#; insta::assert_debug_snapshot!(ast::Suite::parse(source, "").unwrap()); } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__parse_type_declaration.snap b/parser/src/snapshots/rustpython_parser__parser__tests__parse_type_declaration.snap index 1391b80..bb8eae8 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__parse_type_declaration.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__parse_type_declaration.snap @@ -634,4 +634,76 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" ), }, ), + TypeAlias( + StmtTypeAlias { + range: 367..382, + name: Name( + ExprName { + range: 375..376, + id: Identifier( + "X", + ), + ctx: Load, + }, + ), + type_params: [], + value: Name( + ExprName { + range: 379..382, + id: Identifier( + "int", + ), + ctx: Load, + }, + ), + }, + ), + TypeAlias( + StmtTypeAlias { + range: 383..398, + name: Name( + ExprName { + range: 388..389, + id: Identifier( + "X", + ), + ctx: Load, + }, + ), + type_params: [], + value: Name( + ExprName { + range: 395..398, + id: Identifier( + "int", + ), + ctx: Load, + }, + ), + }, + ), + TypeAlias( + StmtTypeAlias { + range: 399..414, + name: Name( + ExprName { + range: 404..405, + id: Identifier( + "X", + ), + ctx: Load, + }, + ), + type_params: [], + value: Name( + ExprName { + range: 411..414, + id: Identifier( + "int", + ), + ctx: Load, + }, + ), + }, + ), ]