mirror of
https://github.com/python/cpython.git
synced 2026-06-03 02:00:19 -04:00
e1578ce204
roundtrip(): Show the offending syntax tree when things break; this makes
it a little easier to debug the module by adding test cases.
(Still need better tests for this module, but there's not enough time
today.)
68 lines
1.3 KiB
Plaintext
68 lines
1.3 KiB
Plaintext
test_parser
|
|
Expressions:
|
|
expr: foo(1)
|
|
expr: [1, 2, 3]
|
|
expr: [x**3 for x in range(20)]
|
|
expr: [x**3 for x in range(20) if x % 3]
|
|
expr: foo(*args)
|
|
expr: foo(*args, **kw)
|
|
expr: foo(**kw)
|
|
expr: foo(key=value)
|
|
expr: foo(key=value, *args)
|
|
expr: foo(key=value, *args, **kw)
|
|
expr: foo(key=value, **kw)
|
|
expr: foo(a, b, c, *args)
|
|
expr: foo(a, b, c, *args, **kw)
|
|
expr: foo(a, b, c, **kw)
|
|
expr: foo + bar
|
|
expr: lambda: 0
|
|
expr: lambda x: 0
|
|
expr: lambda *y: 0
|
|
expr: lambda *y, **z: 0
|
|
expr: lambda **z: 0
|
|
expr: lambda x, y: 0
|
|
expr: lambda foo=bar: 0
|
|
expr: lambda foo=bar, spaz=nifty+spit: 0
|
|
expr: lambda foo=bar, **z: 0
|
|
expr: lambda foo=bar, blaz=blat+2, **z: 0
|
|
expr: lambda foo=bar, blaz=blat+2, *y, **z: 0
|
|
expr: lambda x, *y, **z: 0
|
|
|
|
Statements:
|
|
suite: print
|
|
suite: print 1
|
|
suite: print 1,
|
|
suite: print >>fp
|
|
suite: print >>fp, 1
|
|
suite: print >>fp, 1,
|
|
suite: a
|
|
suite: a = b
|
|
suite: a = b = c = d = e
|
|
suite: a += b
|
|
suite: a -= b
|
|
suite: a *= b
|
|
suite: a /= b
|
|
suite: a %= b
|
|
suite: a &= b
|
|
suite: a |= b
|
|
suite: a ^= b
|
|
suite: a <<= b
|
|
suite: a >>= b
|
|
suite: a **= b
|
|
suite: def f(): pass
|
|
suite: def f(foo=bar): pass
|
|
|
|
Invalid parse trees:
|
|
|
|
<junk>
|
|
caught expected exception for invalid tree
|
|
|
|
print >>fp,
|
|
caught expected exception for invalid tree
|
|
|
|
a,,c
|
|
caught expected exception for invalid tree
|
|
|
|
a $= b
|
|
caught expected exception for invalid tree
|