1# Tests for the 'tokenize' module. 2# Large bits stolen from test_grammar.py. 3 4# Comments 5"#" 6#' 7#" 8#\ 9 # 10 # abc 11'''# 12#''' 13 14x = 1 # 15 16# Balancing continuation 17 18a = (3, 4, 19 5, 6) 20y = [3, 4, 21 5] 22z = {'a':5, 23 'b':6} 24x = (len(`y`) + 5*x - a[ 25 3 ] 26 - x + len({ 27 } 28 ) 29 ) 30 31# Backslash means line continuation: 32x = 1 \ 33+ 1 34 35# Backslash does not means continuation in comments :\ 36x = 0 37 38# Ordinary integers 390xff <> 255 400377 <> 255 412147483647 != 017777777777 42-2147483647-1 != 020000000000 43037777777777 != -1 440xffffffff != -1 45 46# Long integers 47x = 0L 48x = 0l 49x = 0xffffffffffffffffL 50x = 0xffffffffffffffffl 51x = 077777777777777777L 52x = 077777777777777777l 53x = 123456789012345678901234567890L 54x = 123456789012345678901234567890l 55 56# Floating-point numbers 57x = 3.14 58x = 314. 59x = 0.314 60# XXX x = 000.314 61x = .314 62x = 3e14 63x = 3E14 64x = 3e-14 65x = 3e+14 66x = 3.e14 67x = .3e14 68x = 3.1e4 69 70# String literals 71x = ''; y = ""; 72x = '\''; y = "'"; 73x = '"'; y = "\""; 74x = "doesn't \"shrink\" does it" 75y = 'doesn\'t "shrink" does it' 76x = "does \"shrink\" doesn't it" 77y = 'does "shrink" doesn\'t it' 78x = """ 79The "quick" 80brown fox 81jumps over 82the 'lazy' dog. 83""" 84y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n' 85y = ''' 86The "quick" 87brown fox 88jumps over 89the 'lazy' dog. 90'''; 91y = "\n\ 92The \"quick\"\n\ 93brown fox\n\ 94jumps over\n\ 95the 'lazy' dog.\n\ 96"; 97y = '\n\ 98The \"quick\"\n\ 99brown fox\n\ 100jumps over\n\ 101the \'lazy\' dog.\n\ 102'; 103x = r'\\' + R'\\' 104x = r'\'' + '' 105y = r''' 106foo bar \\ 107baz''' + R''' 108foo''' 109y = r"""foo 110bar \\ baz 111""" + R'''spam 112''' 113x = u'abc' + U'ABC' 114y = u"abc" + U"ABC" 115x = ur'abc' + Ur'ABC' + uR'ABC' + UR'ABC' 116y = ur"abc" + Ur"ABC" + uR"ABC" + UR"ABC" 117x = ur'\\' + UR'\\' 118x = ur'\'' + '' 119y = ur''' 120foo bar \\ 121baz''' + UR''' 122foo''' 123y = Ur"""foo 124bar \\ baz 125""" + uR'''spam 126''' 127 128# Indentation 129if 1: 130 x = 2 131if 1: 132 x = 2 133if 1: 134 while 0: 135 if 0: 136 x = 2 137 x = 2 138if 0: 139 if 2: 140 while 0: 141 if 1: 142 x = 2 143 144# Operators 145 146def d22(a, b, c=1, d=2): pass 147def d01v(a=1, *restt, **restd): pass 148 149(x, y) <> ({'a':1}, {'b':2}) 150 151# comparison 152if 1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1: pass 153 154# binary 155x = 1 & 1 156x = 1 ^ 1 157x = 1 | 1 158 159# shift 160x = 1 << 1 >> 1 161 162# additive 163x = 1 - 1 + 1 - 1 + 1 164 165# multiplicative 166x = 1 / 1 * 1 % 1 167 168# unary 169x = ~1 ^ 1 & 1 | 1 & 1 ^ -1 170x = -1*1/1 + 1*1 - ---1*1 171 172# selector 173import sys, time 174x = sys.modules['time'].time() 175 176@staticmethod 177def foo(): pass 178 179