-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CFE parser test cases for metadata in for-in loops with patterns.
Bug: #50035 Change-Id: I336b391c9102e4e6dd3eabce1051763e3bc797d4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273621 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
- Loading branch information
1 parent
b0ca324
commit 7a3aa5c
Showing
10 changed files
with
360 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
pkg/front_end/parser_testcases/patterns/pattern_inForIn_element_withMetadata.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
void f(x) => [for (@annotation var (a, b) in x) 0]; |
48 changes: 48 additions & 0 deletions
48
pkg/front_end/parser_testcases/patterns/pattern_inForIn_element_withMetadata.dart.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
beginCompilationUnit(void) | ||
beginMetadataStar(void) | ||
endMetadataStar(0) | ||
beginTopLevelMember(void) | ||
beginTopLevelMethod(, null, null) | ||
handleVoidKeyword(void) | ||
handleIdentifier(f, topLevelFunctionDeclaration) | ||
handleNoTypeVariables(() | ||
beginFormalParameters((, MemberKind.TopLevelMethod) | ||
beginMetadataStar(x) | ||
endMetadataStar(0) | ||
beginFormalParameter(x, MemberKind.TopLevelMethod, null, null, null) | ||
handleNoType(() | ||
handleIdentifier(x, formalParameterDeclaration) | ||
handleFormalParameterWithoutValue()) | ||
endFormalParameter(null, null, null, x, null, null, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
endFormalParameters(1, (, ), MemberKind.TopLevelMethod) | ||
handleAsyncModifier(null, null) | ||
handleNoTypeArguments([) | ||
beginForControlFlow(null, for) | ||
beginMetadataStar(@) | ||
beginMetadata(@) | ||
handleIdentifier(annotation, metadataReference) | ||
handleNoTypeArguments(var) | ||
handleNoArguments(var) | ||
endMetadata(@, null, var) | ||
endMetadataStar(1) | ||
handleNoType(() | ||
handleVariablePattern(null, a) | ||
handlePatternField(null) | ||
handleNoType(,) | ||
handleVariablePattern(null, b) | ||
handlePatternField(null) | ||
handleRecordPattern((, 2) | ||
beginForInExpression(x) | ||
handleIdentifier(x, expression) | ||
handleNoTypeArguments()) | ||
handleNoArguments()) | ||
handleSend(x, )) | ||
endForInExpression()) | ||
handleForInLoopParts(null, for, (, var, in) | ||
handleLiteralInt(0) | ||
endForInControlFlow(0) | ||
handleLiteralList(1, [, null, ]) | ||
handleExpressionFunctionBody(=>, ;) | ||
endTopLevelMethod(void, null, ;) | ||
endTopLevelDeclaration() | ||
endCompilationUnit(1, ) |
117 changes: 117 additions & 0 deletions
117
...nd/parser_testcases/patterns/pattern_inForIn_element_withMetadata.dart.intertwined.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
parseUnit(void) | ||
skipErrorTokens(void) | ||
listener: beginCompilationUnit(void) | ||
syntheticPreviousToken(void) | ||
parseTopLevelDeclarationImpl(, Instance of 'DirectiveContext') | ||
parseMetadataStar() | ||
listener: beginMetadataStar(void) | ||
listener: endMetadataStar(0) | ||
parseTopLevelMemberImpl() | ||
listener: beginTopLevelMember(void) | ||
parseTopLevelMethod(, null, null, , Instance of 'VoidType', null, f, false) | ||
listener: beginTopLevelMethod(, null, null) | ||
listener: handleVoidKeyword(void) | ||
ensureIdentifierPotentiallyRecovered(void, topLevelFunctionDeclaration, false) | ||
listener: handleIdentifier(f, topLevelFunctionDeclaration) | ||
parseMethodTypeVar(f) | ||
listener: handleNoTypeVariables(() | ||
parseGetterOrFormalParameters(f, f, false, MemberKind.TopLevelMethod) | ||
parseFormalParameters(f, MemberKind.TopLevelMethod) | ||
parseFormalParametersRest((, MemberKind.TopLevelMethod) | ||
listener: beginFormalParameters((, MemberKind.TopLevelMethod) | ||
parseFormalParameter((, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
parseMetadataStar(() | ||
listener: beginMetadataStar(x) | ||
listener: endMetadataStar(0) | ||
listener: beginFormalParameter(x, MemberKind.TopLevelMethod, null, null, null) | ||
listener: handleNoType(() | ||
ensureIdentifier((, formalParameterDeclaration) | ||
listener: handleIdentifier(x, formalParameterDeclaration) | ||
listener: handleFormalParameterWithoutValue()) | ||
listener: endFormalParameter(null, null, null, x, null, null, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
listener: endFormalParameters(1, (, ), MemberKind.TopLevelMethod) | ||
parseAsyncModifierOpt()) | ||
listener: handleAsyncModifier(null, null) | ||
inPlainSync() | ||
parseFunctionBody(), false, false) | ||
parseExpressionFunctionBody(=>, false) | ||
parseExpression(=>) | ||
looksLikeOuterPatternEquals(=>) | ||
skipOuterPattern(=>) | ||
parsePrecedenceExpression(=>, 1, true) | ||
parseUnaryExpression(=>, true) | ||
parsePrimary(=>, expression) | ||
listener: handleNoTypeArguments([) | ||
parseLiteralListSuffix(=>, null) | ||
listener: beginForControlFlow(null, for) | ||
parseForLoopPartsStart(null, for, ForPartsContext(null)) | ||
parseExpressionStatementOrDeclaration((, ForPartsContext(null)) | ||
parseMetadataStar(() | ||
listener: beginMetadataStar(@) | ||
parseMetadata(() | ||
listener: beginMetadata(@) | ||
ensureIdentifier(@, metadataReference) | ||
listener: handleIdentifier(annotation, metadataReference) | ||
parseQualifiedRestOpt(annotation, metadataContinuation) | ||
listener: handleNoTypeArguments(var) | ||
parseArgumentsOpt(annotation) | ||
listener: handleNoArguments(var) | ||
listener: endMetadata(@, null, var) | ||
listener: endMetadataStar(1) | ||
parseExpressionStatementOrDeclarationAfterModifiers(var, (, null, var, null, ForPartsContext(null)) | ||
skipOuterPattern(var) | ||
parsePattern(var, precedence: 1, isRefutableContext: false) | ||
parsePrimaryPattern(var, isRefutableContext: false) | ||
parseParenthesizedPatternOrRecordPattern(var, isRefutableContext: false) | ||
parsePattern((, precedence: 1, isRefutableContext: false) | ||
parsePrimaryPattern((, isRefutableContext: false) | ||
parseVariablePattern((, typeInfo: Instance of 'NoType') | ||
listener: handleNoType(() | ||
listener: handleVariablePattern(null, a) | ||
listener: handlePatternField(null) | ||
parsePattern(,, precedence: 1, isRefutableContext: false) | ||
parsePrimaryPattern(,, isRefutableContext: false) | ||
parseVariablePattern(,, typeInfo: Instance of 'NoType') | ||
listener: handleNoType(,) | ||
listener: handleVariablePattern(null, b) | ||
listener: handlePatternField(null) | ||
ensureCloseParen(b, () | ||
listener: handleRecordPattern((, 2) | ||
parseForInLoopPartsRest(), null, for, var, null) | ||
listener: beginForInExpression(x) | ||
parseExpression(in) | ||
looksLikeOuterPatternEquals(in) | ||
skipOuterPattern(in) | ||
skipObjectPatternRest(x) | ||
parsePrecedenceExpression(in, 1, true) | ||
parseUnaryExpression(in, true) | ||
parsePrimary(in, expression) | ||
parseSendOrFunctionLiteral(in, expression) | ||
parseSend(in, expression) | ||
isNextIdentifier(in) | ||
ensureIdentifier(in, expression) | ||
listener: handleIdentifier(x, expression) | ||
listener: handleNoTypeArguments()) | ||
parseArgumentsOpt(x) | ||
listener: handleNoArguments()) | ||
listener: handleSend(x, )) | ||
ensureCloseParen(x, () | ||
listener: endForInExpression()) | ||
listener: handleForInLoopParts(null, for, (, var, in) | ||
parseExpression()) | ||
looksLikeOuterPatternEquals()) | ||
skipOuterPattern()) | ||
parsePrecedenceExpression(), 1, true) | ||
parseUnaryExpression(), true) | ||
parsePrimary(), expression) | ||
parseLiteralInt()) | ||
listener: handleLiteralInt(0) | ||
listener: endForInControlFlow(0) | ||
listener: handleLiteralList(1, [, null, ]) | ||
ensureSemicolon(]) | ||
listener: handleExpressionFunctionBody(=>, ;) | ||
inGenerator() | ||
listener: endTopLevelMethod(void, null, ;) | ||
listener: endTopLevelDeclaration() | ||
reportAllErrorTokens(void) | ||
listener: endCompilationUnit(1, ) |
5 changes: 5 additions & 0 deletions
5
...ont_end/parser_testcases/patterns/pattern_inForIn_element_withMetadata.dart.parser.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
void f(x) => [for (@annotation var (a, b) in x) 0]; | ||
|
||
|
||
void[KeywordToken] f[StringToken]([BeginToken]x[StringToken])[SimpleToken] =>[SimpleToken] [[BeginToken]for[KeywordToken] ([BeginToken]@[SimpleToken]annotation[StringToken] var[KeywordToken] ([BeginToken]a[StringToken],[SimpleToken] b[StringToken])[SimpleToken] in[KeywordToken] x[StringToken])[SimpleToken] 0[StringToken]][SimpleToken];[SimpleToken] | ||
[SimpleToken] |
5 changes: 5 additions & 0 deletions
5
...nt_end/parser_testcases/patterns/pattern_inForIn_element_withMetadata.dart.scanner.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
void f(x) => [for (@annotation var (a, b) in x) 0]; | ||
|
||
|
||
void[KeywordToken] f[StringToken]([BeginToken]x[StringToken])[SimpleToken] =>[SimpleToken] [[BeginToken]for[KeywordToken] ([BeginToken]@[SimpleToken]annotation[StringToken] var[KeywordToken] ([BeginToken]a[StringToken],[SimpleToken] b[StringToken])[SimpleToken] in[KeywordToken] x[StringToken])[SimpleToken] 0[StringToken]][SimpleToken];[SimpleToken] | ||
[SimpleToken] |
3 changes: 3 additions & 0 deletions
3
pkg/front_end/parser_testcases/patterns/pattern_inForIn_statement_withMetadata.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
void f(x) { | ||
for (@annotation var (a, b) in x) {} | ||
} |
50 changes: 50 additions & 0 deletions
50
pkg/front_end/parser_testcases/patterns/pattern_inForIn_statement_withMetadata.dart.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
beginCompilationUnit(void) | ||
beginMetadataStar(void) | ||
endMetadataStar(0) | ||
beginTopLevelMember(void) | ||
beginTopLevelMethod(, null, null) | ||
handleVoidKeyword(void) | ||
handleIdentifier(f, topLevelFunctionDeclaration) | ||
handleNoTypeVariables(() | ||
beginFormalParameters((, MemberKind.TopLevelMethod) | ||
beginMetadataStar(x) | ||
endMetadataStar(0) | ||
beginFormalParameter(x, MemberKind.TopLevelMethod, null, null, null) | ||
handleNoType(() | ||
handleIdentifier(x, formalParameterDeclaration) | ||
handleFormalParameterWithoutValue()) | ||
endFormalParameter(null, null, null, x, null, null, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
endFormalParameters(1, (, ), MemberKind.TopLevelMethod) | ||
handleAsyncModifier(null, null) | ||
beginBlockFunctionBody({) | ||
beginForStatement(for) | ||
beginMetadataStar(@) | ||
beginMetadata(@) | ||
handleIdentifier(annotation, metadataReference) | ||
handleNoTypeArguments(var) | ||
handleNoArguments(var) | ||
endMetadata(@, null, var) | ||
endMetadataStar(1) | ||
handleNoType(() | ||
handleVariablePattern(null, a) | ||
handlePatternField(null) | ||
handleNoType(,) | ||
handleVariablePattern(null, b) | ||
handlePatternField(null) | ||
handleRecordPattern((, 2) | ||
beginForInExpression(x) | ||
handleIdentifier(x, expression) | ||
handleNoTypeArguments()) | ||
handleNoArguments()) | ||
handleSend(x, )) | ||
endForInExpression()) | ||
handleForInLoopParts(null, for, (, var, in) | ||
beginForInBody({) | ||
beginBlock({, BlockKind(statement)) | ||
endBlock(0, {, }, BlockKind(statement)) | ||
endForInBody(}) | ||
endForIn(}) | ||
endBlockFunctionBody(1, {, }) | ||
endTopLevelMethod(void, null, }) | ||
endTopLevelDeclaration() | ||
endCompilationUnit(1, ) |
113 changes: 113 additions & 0 deletions
113
.../parser_testcases/patterns/pattern_inForIn_statement_withMetadata.dart.intertwined.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
parseUnit(void) | ||
skipErrorTokens(void) | ||
listener: beginCompilationUnit(void) | ||
syntheticPreviousToken(void) | ||
parseTopLevelDeclarationImpl(, Instance of 'DirectiveContext') | ||
parseMetadataStar() | ||
listener: beginMetadataStar(void) | ||
listener: endMetadataStar(0) | ||
parseTopLevelMemberImpl() | ||
listener: beginTopLevelMember(void) | ||
parseTopLevelMethod(, null, null, , Instance of 'VoidType', null, f, false) | ||
listener: beginTopLevelMethod(, null, null) | ||
listener: handleVoidKeyword(void) | ||
ensureIdentifierPotentiallyRecovered(void, topLevelFunctionDeclaration, false) | ||
listener: handleIdentifier(f, topLevelFunctionDeclaration) | ||
parseMethodTypeVar(f) | ||
listener: handleNoTypeVariables(() | ||
parseGetterOrFormalParameters(f, f, false, MemberKind.TopLevelMethod) | ||
parseFormalParameters(f, MemberKind.TopLevelMethod) | ||
parseFormalParametersRest((, MemberKind.TopLevelMethod) | ||
listener: beginFormalParameters((, MemberKind.TopLevelMethod) | ||
parseFormalParameter((, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
parseMetadataStar(() | ||
listener: beginMetadataStar(x) | ||
listener: endMetadataStar(0) | ||
listener: beginFormalParameter(x, MemberKind.TopLevelMethod, null, null, null) | ||
listener: handleNoType(() | ||
ensureIdentifier((, formalParameterDeclaration) | ||
listener: handleIdentifier(x, formalParameterDeclaration) | ||
listener: handleFormalParameterWithoutValue()) | ||
listener: endFormalParameter(null, null, null, x, null, null, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
listener: endFormalParameters(1, (, ), MemberKind.TopLevelMethod) | ||
parseAsyncModifierOpt()) | ||
listener: handleAsyncModifier(null, null) | ||
inPlainSync() | ||
parseFunctionBody(), false, false) | ||
listener: beginBlockFunctionBody({) | ||
notEofOrValue(}, for) | ||
parseStatement({) | ||
parseStatementX({) | ||
parseForStatement({, null) | ||
listener: beginForStatement(for) | ||
parseForLoopPartsStart(null, for, ForPartsContext(null)) | ||
parseExpressionStatementOrDeclaration((, ForPartsContext(null)) | ||
parseMetadataStar(() | ||
listener: beginMetadataStar(@) | ||
parseMetadata(() | ||
listener: beginMetadata(@) | ||
ensureIdentifier(@, metadataReference) | ||
listener: handleIdentifier(annotation, metadataReference) | ||
parseQualifiedRestOpt(annotation, metadataContinuation) | ||
listener: handleNoTypeArguments(var) | ||
parseArgumentsOpt(annotation) | ||
listener: handleNoArguments(var) | ||
listener: endMetadata(@, null, var) | ||
listener: endMetadataStar(1) | ||
parseExpressionStatementOrDeclarationAfterModifiers(var, (, null, var, null, ForPartsContext(null)) | ||
skipOuterPattern(var) | ||
parsePattern(var, precedence: 1, isRefutableContext: false) | ||
parsePrimaryPattern(var, isRefutableContext: false) | ||
parseParenthesizedPatternOrRecordPattern(var, isRefutableContext: false) | ||
parsePattern((, precedence: 1, isRefutableContext: false) | ||
parsePrimaryPattern((, isRefutableContext: false) | ||
parseVariablePattern((, typeInfo: Instance of 'NoType') | ||
listener: handleNoType(() | ||
listener: handleVariablePattern(null, a) | ||
listener: handlePatternField(null) | ||
parsePattern(,, precedence: 1, isRefutableContext: false) | ||
parsePrimaryPattern(,, isRefutableContext: false) | ||
parseVariablePattern(,, typeInfo: Instance of 'NoType') | ||
listener: handleNoType(,) | ||
listener: handleVariablePattern(null, b) | ||
listener: handlePatternField(null) | ||
ensureCloseParen(b, () | ||
listener: handleRecordPattern((, 2) | ||
parseForInRest(), null, for, var, null) | ||
parseForInLoopPartsRest(), null, for, var, null) | ||
listener: beginForInExpression(x) | ||
parseExpression(in) | ||
looksLikeOuterPatternEquals(in) | ||
skipOuterPattern(in) | ||
skipObjectPatternRest(x) | ||
parsePrecedenceExpression(in, 1, true) | ||
parseUnaryExpression(in, true) | ||
parsePrimary(in, expression) | ||
parseSendOrFunctionLiteral(in, expression) | ||
parseSend(in, expression) | ||
isNextIdentifier(in) | ||
ensureIdentifier(in, expression) | ||
listener: handleIdentifier(x, expression) | ||
listener: handleNoTypeArguments()) | ||
parseArgumentsOpt(x) | ||
listener: handleNoArguments()) | ||
listener: handleSend(x, )) | ||
ensureCloseParen(x, () | ||
listener: endForInExpression()) | ||
listener: handleForInLoopParts(null, for, (, var, in) | ||
listener: beginForInBody({) | ||
parseStatement()) | ||
parseStatementX()) | ||
parseBlock(), BlockKind(statement)) | ||
ensureBlock(), null, null) | ||
listener: beginBlock({, BlockKind(statement)) | ||
notEofOrValue(}, }) | ||
listener: endBlock(0, {, }, BlockKind(statement)) | ||
listener: endForInBody(}) | ||
listener: endForIn(}) | ||
notEofOrValue(}, }) | ||
listener: endBlockFunctionBody(1, {, }) | ||
listener: endTopLevelMethod(void, null, }) | ||
listener: endTopLevelDeclaration() | ||
reportAllErrorTokens(void) | ||
listener: endCompilationUnit(1, ) |
9 changes: 9 additions & 0 deletions
9
...t_end/parser_testcases/patterns/pattern_inForIn_statement_withMetadata.dart.parser.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
void f(x) { | ||
for (@annotation var (a, b) in x) {} | ||
} | ||
|
||
|
||
void[KeywordToken] f[StringToken]([BeginToken]x[StringToken])[SimpleToken] {[BeginToken] | ||
for[KeywordToken] ([BeginToken]@[SimpleToken]annotation[StringToken] var[KeywordToken] ([BeginToken]a[StringToken],[SimpleToken] b[StringToken])[SimpleToken] in[KeywordToken] x[StringToken])[SimpleToken] {[BeginToken]}[SimpleToken] | ||
}[SimpleToken] | ||
[SimpleToken] |
9 changes: 9 additions & 0 deletions
9
..._end/parser_testcases/patterns/pattern_inForIn_statement_withMetadata.dart.scanner.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
void f(x) { | ||
for (@annotation var (a, b) in x) {} | ||
} | ||
|
||
|
||
void[KeywordToken] f[StringToken]([BeginToken]x[StringToken])[SimpleToken] {[BeginToken] | ||
for[KeywordToken] ([BeginToken]@[SimpleToken]annotation[StringToken] var[KeywordToken] ([BeginToken]a[StringToken],[SimpleToken] b[StringToken])[SimpleToken] in[KeywordToken] x[StringToken])[SimpleToken] {[BeginToken]}[SimpleToken] | ||
}[SimpleToken] | ||
[SimpleToken] |