test_parser 2.17 KB
Newer Older
1 2
test_parser
Expressions:
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
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
18 19 20 21 22 23 24 25 26 27 28 29
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
30 31

Statements:
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
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
52
suite: def f(): pass
53 54 55
suite: def f(*args): pass
suite: def f(*args, **kw): pass
suite: def f(**kw): pass
56
suite: def f(foo=bar): pass
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
suite: def f(foo=bar, *args): pass
suite: def f(foo=bar, *args, **kw): pass
suite: def f(foo=bar, **kw): pass
suite: def f(a, b): pass
suite: def f(a, b, *args): pass
suite: def f(a, b, *args, **kw): pass
suite: def f(a, b, **kw): pass
suite: def f(a, b, foo=bar): pass
suite: def f(a, b, foo=bar, *args): pass
suite: def f(a, b, foo=bar, *args, **kw): pass
suite: def f(a, b, foo=bar, **kw): pass
suite: from sys.path import *
suite: from sys.path import dirname
suite: from sys.path import dirname as my_dirname
suite: from sys.path import dirname, basename
suite: from sys.path import dirname as my_dirname, basename
suite: from sys.path import dirname, basename as my_basename
suite: import sys
suite: import sys as system
suite: import sys, math
suite: import sys as system, math
suite: import sys, math as my_math
79 80 81 82 83 84 85 86 87 88 89

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
90 91 92

a $= b
caught expected exception for invalid tree