-- Test cases for parser errors. Each test case consists of two sections.
-- The first section contains [case NAME] followed by the input code, while
-- the second section contains [out] followed by the output from the parser.
--
-- The input file name in errors is "file".
--
-- Comments starting with "--" in this file will be ignored, except for lines
-- starting with "----" that are not ignored. The first two dashes of these
-- lines are interpreted as escapes and removed.

[case testInvalidFunction]
def f()
  pass
[out]
file:1: error: invalid syntax

[case testMissingIndent]
if x:
1
[out]
file:2: error: invalid syntax

[case testUnexpectedIndent]
1
 2
[out]
file:2: error: unexpected indent

[case testInconsistentIndent]
if x:
  1
   1
[out]
file:3: error: unexpected indent

[case testInconsistentIndent2]
if x:
   1
  1
[out]
file:3: error: unindent does not match any outer indentation level

[case testInvalidBinaryOp]
1>
a*
a+1*
[out]
file:1: error: invalid syntax

[case testDoubleStar]
**a
[out]
file:1: error: invalid syntax

[case testInvalidSuperClass]
class A(C[):
  pass
[out]
file:1: error: invalid syntax

[case testMissingSuperClass]
class A(:
  pass
[out]
file:1: error: invalid syntax

[case testUnexpectedEof]
if 1:
[out]
file:1: error: unexpected EOF while parsing

[case testInvalidKeywordArguments1]
f(x=y, z)
[out]
file:1: error: positional argument follows keyword argument

[case testInvalidKeywordArguments2]
f(**x, y)
[out]
file:1: error: positional argument follows keyword argument unpacking

[case testInvalidBareAsteriskAndVarArgs2]
def f(*x: A, *) -> None: pass
[out]
file:1: error: invalid syntax

[case testInvalidBareAsteriskAndVarArgs3]
def f(*, *x: A) -> None: pass
[out]
file:1: error: invalid syntax

[case testInvalidBareAsteriskAndVarArgs4]
def f(*, **x: A) -> None: pass
[out]
file:1: error: named arguments must follow bare *

[case testInvalidBareAsterisk1]
def f(*) -> None: pass
[out]
file:1: error: named arguments must follow bare *

[case testInvalidBareAsterisk2]
def f(x, *) -> None: pass
[out]
file:1: error: named arguments must follow bare *

[case testInvalidFuncDefArgs1]
def f(x = y, x): pass
[out]
file:1: error: non-default argument follows default argument

[case testInvalidFuncDefArgs3]
def f(**x, y):
   pass
[out]
file:1: error: invalid syntax

[case testInvalidFuncDefArgs4]
def f(**x, y=x):
    pass
[out]
file:1: error: invalid syntax

[case testInvalidStringLiteralType]
def f(x:
     'A['
     ) -> None: pass
[out]
file:1: error: syntax error in type comment

[case testInvalidStringLiteralType2]
def f(x:
      'A B'
      ) -> None: pass
[out]
file:1: error: syntax error in type comment

[case testInvalidTypeComment]
0
x = 0 # type: A A
[out]
file:2: error: syntax error in type comment

[case testInvalidTypeComment2]
0
x = 0 # type: A[
[out]
file:2: error: syntax error in type comment

[case testInvalidTypeComment3]
0
x = 0 # type:
[out]
file:2: error: syntax error in type comment

[case testInvalidTypeComment4]
0
x = 0 # type: *
[out]
file:2: error: syntax error in type comment

[case testInvalidMultilineLiteralType]
def f() -> "A\nB": pass
[out]
file:1: error: syntax error in type comment

[case testInvalidSignatureInComment1]
def f(): # type: x
  pass
[out]
file:1: error: syntax error in type comment
file:1: note: Suggestion: wrap argument types in parentheses

[case testInvalidSignatureInComment2]
def f(): # type:
  pass
[out]
file:1: error: syntax error in type comment

[case testInvalidSignatureInComment3]
def f(): # type: (
  pass
[out]
file:1: error: syntax error in type comment

[case testInvalidSignatureInComment4]
def f(): # type: (.
  pass
[out]
file:1: error: syntax error in type comment

[case testInvalidSignatureInComment5]
def f(): # type: (x
  pass
[out]
file:1: error: syntax error in type comment

[case testInvalidSignatureInComment6]
def f(): # type: (x)
  pass
[out]
file:1: error: syntax error in type comment

[case testInvalidSignatureInComment7]
def f(): # type: (x) -
  pass
[out]
file:1: error: syntax error in type comment

[case testInvalidSignatureInComment8]
def f(): # type: (x) ->
  pass
[out]
file:1: error: syntax error in type comment

[case testInvalidSignatureInComment9]
def f(): # type: (x) -> .
  pass
[out]
file:1: error: syntax error in type comment

[case testInvalidSignatureInComment10]
def f(): # type: (x) -> x x
  pass
[out]
file:1: error: syntax error in type comment

[case testDuplicateSignatures1]
def f() -> None: # type: () -> None
  pass
def f(): # type: () -> None
    pass
[out]
file:1: error: Function has duplicate type signatures

[case testDuplicateSignatures2]
def f(x, y: Z): # type: (x, y) -> z
  pass
[out]
file:1: error: Function has duplicate type signatures

[case testTooManyTypes]
def f(x, y): # type: (X, Y, Z) -> z
  pass
[out]
file:1: error: Type signature has too many arguments

[case testTooFewTypes]
def f(x, y): # type: (X) -> z
  pass
[out]
file:1: error: Type signature has too few arguments

[case testCommentFunctionAnnotationVarArgMispatch-skip]
# see mypy issue #1997
def f(x): # type: (*X) -> Y
    pass
def g(*x): # type: (X) -> Y
    pass
[out]
file:1: error: Inconsistent use of '*' in function signature
file:3: error: Inconsistent use of '*' in function signature

[case testCommentFunctionAnnotationVarArgMispatch2-skip]
# see mypy issue #1997
def f(*x, **y): # type: (**X, *Y) -> Z
    pass
def g(*x, **y): # type: (*X, *Y) -> Z
    pass
[out]
file:1: error: Inconsistent use of '*' in function signature
file:3: error: syntax error in type comment
file:3: error: Inconsistent use of '*' in function signature
file:3: error: Inconsistent use of '**' in function signature

[case testPrintStatementInPython3-skip]
print 1
[out]
file:1: error: Missing parentheses in call to 'print'

[case testInvalidConditionInConditionalExpression]
1 if 2, 3 else 4
[out]
file:1: error: invalid syntax

[case testInvalidConditionInConditionalExpression2]
1 if x for y in z else 4
[out]
file:1: error: invalid syntax

[case testInvalidConditionInConditionalExpression2]
1 if x else for y in z
[out]
file:1: error: invalid syntax

[case testYieldFromNotRightParameter]
def f():
    yield from
[out]
file:2: error: invalid syntax

[case testYieldFromAfterReturn]
def f():
    return yield from h()
[out]
file:2: error: invalid syntax

[case testImportDotModule]
import .x
[out]
file:1: error: invalid syntax

[case testImportDot]
import .
[out]
file:1: error: invalid syntax

[case testInvalidFunctionName]
def while(): pass
[out]
file:1: error: invalid syntax

[case testInvalidEllipsis1]
...0
..._
...a
[out]
file:1: error: invalid syntax

[case testBlockStatementInSingleLineIf]
if 1: if 2: pass
[out]
file:1: error: invalid syntax

[case testBlockStatementInSingleLineIf2]
if 1: while 2: pass
[out]
file:1: error: invalid syntax

[case testBlockStatementInSingleLineIf3]
if 1: for x in y: pass
[out]
file:1: error: invalid syntax

[case testUnexpectedEllipsis]
a = a...
[out]
file:1: error: invalid syntax

[case testParseErrorBeforeUnicodeLiteral]
x u'y'
[out]
file:1: error: invalid syntax

[case testParseErrorInExtendedSlicing]
x[:,
[out]
file:1: error: unexpected EOF while parsing

[case testParseErrorInExtendedSlicing2]
x[:,::
[out]
file:1: error: unexpected EOF while parsing

[case testParseErrorInExtendedSlicing3]
x[:,:
[out]
file:1: error: unexpected EOF while parsing

[case testPython2OctalIntLiteralInPython3]
0377
[out]
file:1: error: invalid token

[case testInvalidEncoding]
# foo
# coding: uft-8
[out]
file:0: error: unknown encoding: uft-8

[case testInvalidEncoding2]
# coding=Uft.8
[out]
file:0: error: unknown encoding: Uft.8

[case testInvalidEncoding3]
#!/usr/bin python
# vim: set fileencoding=uft8 :
[out]
file:0: error: unknown encoding: uft8

[case testDoubleEncoding]
# coding: uft8
# coding: utf8
# The first coding cookie should be used and fail.
[out]
file:0: error: unknown encoding: uft8

[case testDoubleEncoding2]
# Again the first cookie should be used and fail.
# coding: uft8
# coding: utf8
[out]
file:0: error: unknown encoding: uft8

[case testLongLiteralInPython3]
2L
0x2L
[out]
file:1: error: invalid syntax

[case testPython2LegacyInequalityInPython3]
1 <> 2
[out]
file:1: error: invalid syntax

[case testLambdaInListComprehensionInPython3]
([ 0 for x in 1, 2 if 3 ])
[out]
file:1: error: invalid syntax

[case testTupleArgListInPython3]
def f(x, (y, z)): pass
[out]
file:1: error: invalid syntax

[case testBackquoteInPython3]
`1 + 2`
[out]
file:1: error: invalid syntax

[case testSmartQuotes]
foo = ‘bar’
[out]
file:1: error: invalid character in identifier

[case testExceptCommaInPython3]
try:
    pass
except KeyError, IndexError:
    pass
[out]
file:3: error: invalid syntax

[case testLocalVarWithTypeOnNextLine]
x = 0
  # type: int
[out]
file:2: error: misplaced type annotation
