mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-31442 Add tests on handling of line comments inside fragments
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
s = f'''{[
|
||||
# comment
|
||||
]}'''
|
||||
@@ -0,0 +1,22 @@
|
||||
PyFile:MultilineFStringContainsCommentInsideExpression.py
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s
|
||||
PsiElement(Py:IDENTIFIER)('s')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression: {[
|
||||
# comment
|
||||
]}
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('f'''')
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyListLiteralExpression
|
||||
PsiElement(Py:LBRACKET)('[')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# comment')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(Py:RBRACKET)(']')
|
||||
PsiElement(Py:FSTRING_FRAGMENT_END)('}')
|
||||
PsiElement(Py:FSTRING_END)(''''')
|
||||
@@ -0,0 +1,3 @@
|
||||
s = f'''{
|
||||
# comment
|
||||
}'''
|
||||
@@ -0,0 +1,21 @@
|
||||
PyFile:MultilineFStringContainsCommentInsteadOfExpression.py
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s
|
||||
PsiElement(Py:IDENTIFIER)('s')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression: {
|
||||
# comment
|
||||
}
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('f'''')
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PsiErrorElement:expression expected
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# comment')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(Py:FSTRING_FRAGMENT_END)('}')
|
||||
PsiElement(Py:FSTRING_END)(''''')
|
||||
@@ -0,0 +1 @@
|
||||
s = f'{42 # comment}'
|
||||
@@ -0,0 +1,20 @@
|
||||
PyFile:SingleLineFStringContainsCommentInsideExpression.py
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s
|
||||
PsiElement(Py:IDENTIFIER)('s')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression: {42
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('f'')
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
<empty list>
|
||||
PsiErrorElement:Unexpected f-string token
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# comment}'')
|
||||
@@ -0,0 +1 @@
|
||||
s = f'{# comment}'
|
||||
@@ -0,0 +1,19 @@
|
||||
PyFile:SingleLineFStringContainsCommentInsteadOfExpression.py
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s
|
||||
PsiElement(Py:IDENTIFIER)('s')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression: {
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('f'')
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PsiErrorElement:expression expected
|
||||
<empty list>
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
<empty list>
|
||||
PsiErrorElement:Unexpected f-string token
|
||||
<empty list>
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# comment}'')
|
||||
@@ -761,6 +761,22 @@ public class PythonParsingTest extends ParsingTestCase {
|
||||
doTest(LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
public void testSingleLineFStringContainsCommentInsideExpression() {
|
||||
doTest(LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
public void testSingleLineFStringContainsCommentInsteadOfExpression() {
|
||||
doTest(LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
public void testMultilineFStringContainsCommentInsideExpression() {
|
||||
doTest(LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
public void testMultilineFStringContainsCommentInsteadOfExpression() {
|
||||
doTest(LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
// PY-19036
|
||||
public void testAwaitInNonAsyncNestedFunction() {
|
||||
doTest(LanguageLevel.PYTHON35);
|
||||
|
||||
Reference in New Issue
Block a user