Commit 775e2437 authored by Benjamin Peterson's avatar Benjamin Peterson

revert changes in inappropiate branch

parent 19449cb0
...@@ -20,21 +20,21 @@ class TokenTests(unittest.TestCase): ...@@ -20,21 +20,21 @@ class TokenTests(unittest.TestCase):
# Backslash means line continuation: # Backslash means line continuation:
x = 1 \ x = 1 \
+ 1 + 1
self.assertEqual(x, 2, 'backslash for line continuation') self.assertEquals(x, 2, 'backslash for line continuation')
# Backslash does not means continuation in comments :\ # Backslash does not means continuation in comments :\
x = 0 x = 0
self.assertEqual(x, 0, 'backslash ending comment') self.assertEquals(x, 0, 'backslash ending comment')
def testPlainIntegers(self): def testPlainIntegers(self):
self.assertEqual(0xff, 255) self.assertEquals(0xff, 255)
self.assertEqual(0377, 255) self.assertEquals(0377, 255)
self.assertEqual(2147483647, 017777777777) self.assertEquals(2147483647, 017777777777)
# "0x" is not a valid literal # "0x" is not a valid literal
self.assertRaises(SyntaxError, eval, "0x") self.assertRaises(SyntaxError, eval, "0x")
from sys import maxint from sys import maxint
if maxint == 2147483647: if maxint == 2147483647:
self.assertEqual(-2147483647-1, -020000000000) self.assertEquals(-2147483647-1, -020000000000)
# XXX -2147483648 # XXX -2147483648
self.assert_(037777777777 > 0) self.assert_(037777777777 > 0)
self.assert_(0xffffffff > 0) self.assert_(0xffffffff > 0)
...@@ -44,7 +44,7 @@ class TokenTests(unittest.TestCase): ...@@ -44,7 +44,7 @@ class TokenTests(unittest.TestCase):
except OverflowError: except OverflowError:
self.fail("OverflowError on huge integer literal %r" % s) self.fail("OverflowError on huge integer literal %r" % s)
elif maxint == 9223372036854775807: elif maxint == 9223372036854775807:
self.assertEqual(-9223372036854775807-1, -01000000000000000000000) self.assertEquals(-9223372036854775807-1, -01000000000000000000000)
self.assert_(01777777777777777777777 > 0) self.assert_(01777777777777777777777 > 0)
self.assert_(0xffffffffffffffff > 0) self.assert_(0xffffffffffffffff > 0)
for s in '9223372036854775808', '02000000000000000000000', \ for s in '9223372036854775808', '02000000000000000000000', \
...@@ -97,28 +97,28 @@ jumps over ...@@ -97,28 +97,28 @@ jumps over
the 'lazy' dog. the 'lazy' dog.
""" """
y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n' y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n'
self.assertEqual(x, y) self.assertEquals(x, y)
y = ''' y = '''
The "quick" The "quick"
brown fox brown fox
jumps over jumps over
the 'lazy' dog. the 'lazy' dog.
''' '''
self.assertEqual(x, y) self.assertEquals(x, y)
y = "\n\ y = "\n\
The \"quick\"\n\ The \"quick\"\n\
brown fox\n\ brown fox\n\
jumps over\n\ jumps over\n\
the 'lazy' dog.\n\ the 'lazy' dog.\n\
" "
self.assertEqual(x, y) self.assertEquals(x, y)
y = '\n\ y = '\n\
The \"quick\"\n\ The \"quick\"\n\
brown fox\n\ brown fox\n\
jumps over\n\ jumps over\n\
the \'lazy\' dog.\n\ the \'lazy\' dog.\n\
' '
self.assertEqual(x, y) self.assertEquals(x, y)
class GrammarTests(unittest.TestCase): class GrammarTests(unittest.TestCase):
...@@ -154,18 +154,18 @@ class GrammarTests(unittest.TestCase): ...@@ -154,18 +154,18 @@ class GrammarTests(unittest.TestCase):
def f3(two, arguments): pass def f3(two, arguments): pass
def f4(two, (compound, (argument, list))): pass def f4(two, (compound, (argument, list))): pass
def f5((compound, first), two): pass def f5((compound, first), two): pass
self.assertEqual(f2.func_code.co_varnames, ('one_argument',)) self.assertEquals(f2.func_code.co_varnames, ('one_argument',))
self.assertEqual(f3.func_code.co_varnames, ('two', 'arguments')) self.assertEquals(f3.func_code.co_varnames, ('two', 'arguments'))
if sys.platform.startswith('java'): if sys.platform.startswith('java'):
self.assertEqual(f4.func_code.co_varnames, self.assertEquals(f4.func_code.co_varnames,
('two', '(compound, (argument, list))', 'compound', 'argument', ('two', '(compound, (argument, list))', 'compound', 'argument',
'list',)) 'list',))
self.assertEqual(f5.func_code.co_varnames, self.assertEquals(f5.func_code.co_varnames,
('(compound, first)', 'two', 'compound', 'first')) ('(compound, first)', 'two', 'compound', 'first'))
else: else:
self.assertEqual(f4.func_code.co_varnames, self.assertEquals(f4.func_code.co_varnames,
('two', '.1', 'compound', 'argument', 'list')) ('two', '.1', 'compound', 'argument', 'list'))
self.assertEqual(f5.func_code.co_varnames, self.assertEquals(f5.func_code.co_varnames,
('.0', 'two', 'compound', 'first')) ('.0', 'two', 'compound', 'first'))
def a1(one_arg,): pass def a1(one_arg,): pass
def a2(two, args,): pass def a2(two, args,): pass
...@@ -201,10 +201,10 @@ class GrammarTests(unittest.TestCase): ...@@ -201,10 +201,10 @@ class GrammarTests(unittest.TestCase):
# ceval unpacks the formal arguments into the first argcount names; # ceval unpacks the formal arguments into the first argcount names;
# thus, the names nested inside tuples must appear after these names. # thus, the names nested inside tuples must appear after these names.
if sys.platform.startswith('java'): if sys.platform.startswith('java'):
self.assertEqual(v3.func_code.co_varnames, ('a', '(b, c)', 'rest', 'b', 'c')) self.assertEquals(v3.func_code.co_varnames, ('a', '(b, c)', 'rest', 'b', 'c'))
else: else:
self.assertEqual(v3.func_code.co_varnames, ('a', '.1', 'rest', 'b', 'c')) self.assertEquals(v3.func_code.co_varnames, ('a', '.1', 'rest', 'b', 'c'))
self.assertEqual(v3(1, (2, 3), 4), (1, 2, 3, (4,))) self.assertEquals(v3(1, (2, 3), 4), (1, 2, 3, (4,)))
def d01(a=1): pass def d01(a=1): pass
d01() d01()
d01(1) d01(1)
...@@ -285,7 +285,7 @@ class GrammarTests(unittest.TestCase): ...@@ -285,7 +285,7 @@ class GrammarTests(unittest.TestCase):
# keyword arguments after *arglist # keyword arguments after *arglist
def f(*args, **kwargs): def f(*args, **kwargs):
return args, kwargs return args, kwargs
self.assertEqual(f(1, x=2, *[3, 4], y=5), ((1, 3, 4), self.assertEquals(f(1, x=2, *[3, 4], y=5), ((1, 3, 4),
{'x':2, 'y':5})) {'x':2, 'y':5}))
self.assertRaises(SyntaxError, eval, "f(1, *(2,3), 4)") self.assertRaises(SyntaxError, eval, "f(1, *(2,3), 4)")
self.assertRaises(SyntaxError, eval, "f(1, x=2, *(3,4), x=5)") self.assertRaises(SyntaxError, eval, "f(1, x=2, *(3,4), x=5)")
...@@ -297,15 +297,15 @@ class GrammarTests(unittest.TestCase): ...@@ -297,15 +297,15 @@ class GrammarTests(unittest.TestCase):
def testLambdef(self): def testLambdef(self):
### lambdef: 'lambda' [varargslist] ':' test ### lambdef: 'lambda' [varargslist] ':' test
l1 = lambda : 0 l1 = lambda : 0
self.assertEqual(l1(), 0) self.assertEquals(l1(), 0)
l2 = lambda : a[d] # XXX just testing the expression l2 = lambda : a[d] # XXX just testing the expression
l3 = lambda : [2 < x for x in [-1, 3, 0L]] l3 = lambda : [2 < x for x in [-1, 3, 0L]]
self.assertEqual(l3(), [0, 1, 0]) self.assertEquals(l3(), [0, 1, 0])
l4 = lambda x = lambda y = lambda z=1 : z : y() : x() l4 = lambda x = lambda y = lambda z=1 : z : y() : x()
self.assertEqual(l4(), 1) self.assertEquals(l4(), 1)
l5 = lambda x, y, z=2: x + y + z l5 = lambda x, y, z=2: x + y + z
self.assertEqual(l5(1, 2), 5) self.assertEquals(l5(1, 2), 5)
self.assertEqual(l5(1, 2, 3), 6) self.assertEquals(l5(1, 2, 3), 6)
check_syntax_error(self, "lambda x: x = 2") check_syntax_error(self, "lambda x: x = 2")
check_syntax_error(self, "lambda (None,): None") check_syntax_error(self, "lambda (None,): None")
...@@ -558,7 +558,7 @@ hello world ...@@ -558,7 +558,7 @@ hello world
try: try:
assert 0, "msg" assert 0, "msg"
except AssertionError, e: except AssertionError, e:
self.assertEqual(e.args[0], "msg") self.assertEquals(e.args[0], "msg")
else: else:
if __debug__: if __debug__:
self.fail("AssertionError not raised by assert 0") self.fail("AssertionError not raised by assert 0")
...@@ -592,7 +592,7 @@ hello world ...@@ -592,7 +592,7 @@ hello world
x = 1 x = 1
else: else:
x = 2 x = 2
self.assertEqual(x, 2) self.assertEquals(x, 2)
def testFor(self): def testFor(self):
# 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite] # 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite]
...@@ -745,7 +745,7 @@ hello world ...@@ -745,7 +745,7 @@ hello world
d[1,2,3] = 4 d[1,2,3] = 4
L = list(d) L = list(d)
L.sort() L.sort()
self.assertEqual(str(L), '[1, (1,), (1, 2), (1, 2, 3)]') self.assertEquals(str(L), '[1, (1,), (1, 2), (1, 2, 3)]')
def testAtoms(self): def testAtoms(self):
### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING ### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING
......
...@@ -20,23 +20,23 @@ class TokenTests(unittest.TestCase): ...@@ -20,23 +20,23 @@ class TokenTests(unittest.TestCase):
# Backslash means line continuation: # Backslash means line continuation:
x = 1 \ x = 1 \
+ 1 + 1
self.assertEqual(x, 2, 'backslash for line continuation') self.assertEquals(x, 2, 'backslash for line continuation')
# Backslash does not means continuation in comments :\ # Backslash does not means continuation in comments :\
x = 0 x = 0
self.assertEqual(x, 0, 'backslash ending comment') self.assertEquals(x, 0, 'backslash ending comment')
def testPlainIntegers(self): def testPlainIntegers(self):
self.assertEqual(type(000), type(0)) self.assertEquals(type(000), type(0))
self.assertEqual(0xff, 255) self.assertEquals(0xff, 255)
self.assertEqual(0o377, 255) self.assertEquals(0o377, 255)
self.assertEqual(2147483647, 0o17777777777) self.assertEquals(2147483647, 0o17777777777)
self.assertEqual(0b1001, 9) self.assertEquals(0b1001, 9)
# "0x" is not a valid literal # "0x" is not a valid literal
self.assertRaises(SyntaxError, eval, "0x") self.assertRaises(SyntaxError, eval, "0x")
from sys import maxsize from sys import maxsize
if maxsize == 2147483647: if maxsize == 2147483647:
self.assertEqual(-2147483647-1, -0o20000000000) self.assertEquals(-2147483647-1, -0o20000000000)
# XXX -2147483648 # XXX -2147483648
self.assert_(0o37777777777 > 0) self.assert_(0o37777777777 > 0)
self.assert_(0xffffffff > 0) self.assert_(0xffffffff > 0)
...@@ -48,7 +48,7 @@ class TokenTests(unittest.TestCase): ...@@ -48,7 +48,7 @@ class TokenTests(unittest.TestCase):
except OverflowError: except OverflowError:
self.fail("OverflowError on huge integer literal %r" % s) self.fail("OverflowError on huge integer literal %r" % s)
elif maxsize == 9223372036854775807: elif maxsize == 9223372036854775807:
self.assertEqual(-9223372036854775807-1, -0o1000000000000000000000) self.assertEquals(-9223372036854775807-1, -0o1000000000000000000000)
self.assert_(0o1777777777777777777777 > 0) self.assert_(0o1777777777777777777777 > 0)
self.assert_(0xffffffffffffffff > 0) self.assert_(0xffffffffffffffff > 0)
self.assert_(0b11111111111111111111111111111111111111111111111111111111111111 > 0) self.assert_(0b11111111111111111111111111111111111111111111111111111111111111 > 0)
...@@ -103,28 +103,28 @@ jumps over ...@@ -103,28 +103,28 @@ jumps over
the 'lazy' dog. the 'lazy' dog.
""" """
y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n' y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n'
self.assertEqual(x, y) self.assertEquals(x, y)
y = ''' y = '''
The "quick" The "quick"
brown fox brown fox
jumps over jumps over
the 'lazy' dog. the 'lazy' dog.
''' '''
self.assertEqual(x, y) self.assertEquals(x, y)
y = "\n\ y = "\n\
The \"quick\"\n\ The \"quick\"\n\
brown fox\n\ brown fox\n\
jumps over\n\ jumps over\n\
the 'lazy' dog.\n\ the 'lazy' dog.\n\
" "
self.assertEqual(x, y) self.assertEquals(x, y)
y = '\n\ y = '\n\
The \"quick\"\n\ The \"quick\"\n\
brown fox\n\ brown fox\n\
jumps over\n\ jumps over\n\
the \'lazy\' dog.\n\ the \'lazy\' dog.\n\
' '
self.assertEqual(x, y) self.assertEquals(x, y)
def testEllipsis(self): def testEllipsis(self):
x = ... x = ...
...@@ -165,8 +165,8 @@ class GrammarTests(unittest.TestCase): ...@@ -165,8 +165,8 @@ class GrammarTests(unittest.TestCase):
f1(*(), **{}) f1(*(), **{})
def f2(one_argument): pass def f2(one_argument): pass
def f3(two, arguments): pass def f3(two, arguments): pass
self.assertEqual(f2.__code__.co_varnames, ('one_argument',)) self.assertEquals(f2.__code__.co_varnames, ('one_argument',))
self.assertEqual(f3.__code__.co_varnames, ('two', 'arguments')) self.assertEquals(f3.__code__.co_varnames, ('two', 'arguments'))
def a1(one_arg,): pass def a1(one_arg,): pass
def a2(two, args,): pass def a2(two, args,): pass
def v0(*rest): pass def v0(*rest): pass
...@@ -287,37 +287,37 @@ class GrammarTests(unittest.TestCase): ...@@ -287,37 +287,37 @@ class GrammarTests(unittest.TestCase):
# keyword arguments after *arglist # keyword arguments after *arglist
def f(*args, **kwargs): def f(*args, **kwargs):
return args, kwargs return args, kwargs
self.assertEqual(f(1, x=2, *[3, 4], y=5), ((1, 3, 4), self.assertEquals(f(1, x=2, *[3, 4], y=5), ((1, 3, 4),
{'x':2, 'y':5})) {'x':2, 'y':5}))
self.assertRaises(SyntaxError, eval, "f(1, *(2,3), 4)") self.assertRaises(SyntaxError, eval, "f(1, *(2,3), 4)")
self.assertRaises(SyntaxError, eval, "f(1, x=2, *(3,4), x=5)") self.assertRaises(SyntaxError, eval, "f(1, x=2, *(3,4), x=5)")
# argument annotation tests # argument annotation tests
def f(x) -> list: pass def f(x) -> list: pass
self.assertEqual(f.__annotations__, {'return': list}) self.assertEquals(f.__annotations__, {'return': list})
def f(x:int): pass def f(x:int): pass
self.assertEqual(f.__annotations__, {'x': int}) self.assertEquals(f.__annotations__, {'x': int})
def f(*x:str): pass def f(*x:str): pass
self.assertEqual(f.__annotations__, {'x': str}) self.assertEquals(f.__annotations__, {'x': str})
def f(**x:float): pass def f(**x:float): pass
self.assertEqual(f.__annotations__, {'x': float}) self.assertEquals(f.__annotations__, {'x': float})
def f(x, y:1+2): pass def f(x, y:1+2): pass
self.assertEqual(f.__annotations__, {'y': 3}) self.assertEquals(f.__annotations__, {'y': 3})
def f(a, b:1, c:2, d): pass def f(a, b:1, c:2, d): pass
self.assertEqual(f.__annotations__, {'b': 1, 'c': 2}) self.assertEquals(f.__annotations__, {'b': 1, 'c': 2})
def f(a, b:1, c:2, d, e:3=4, f=5, *g:6): pass def f(a, b:1, c:2, d, e:3=4, f=5, *g:6): pass
self.assertEqual(f.__annotations__, self.assertEquals(f.__annotations__,
{'b': 1, 'c': 2, 'e': 3, 'g': 6}) {'b': 1, 'c': 2, 'e': 3, 'g': 6})
def f(a, b:1, c:2, d, e:3=4, f=5, *g:6, h:7, i=8, j:9=10, def f(a, b:1, c:2, d, e:3=4, f=5, *g:6, h:7, i=8, j:9=10,
**k:11) -> 12: pass **k:11) -> 12: pass
self.assertEqual(f.__annotations__, self.assertEquals(f.__annotations__,
{'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9, {'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9,
'k': 11, 'return': 12}) 'k': 11, 'return': 12})
# Check for SF Bug #1697248 - mixing decorators and a return annotation # Check for SF Bug #1697248 - mixing decorators and a return annotation
def null(x): return x def null(x): return x
@null @null
def f(x) -> list: pass def f(x) -> list: pass
self.assertEqual(f.__annotations__, {'return': list}) self.assertEquals(f.__annotations__, {'return': list})
# test MAKE_CLOSURE with a variety of oparg's # test MAKE_CLOSURE with a variety of oparg's
closure = 1 closure = 1
...@@ -333,20 +333,20 @@ class GrammarTests(unittest.TestCase): ...@@ -333,20 +333,20 @@ class GrammarTests(unittest.TestCase):
def testLambdef(self): def testLambdef(self):
### lambdef: 'lambda' [varargslist] ':' test ### lambdef: 'lambda' [varargslist] ':' test
l1 = lambda : 0 l1 = lambda : 0
self.assertEqual(l1(), 0) self.assertEquals(l1(), 0)
l2 = lambda : a[d] # XXX just testing the expression l2 = lambda : a[d] # XXX just testing the expression
l3 = lambda : [2 < x for x in [-1, 3, 0]] l3 = lambda : [2 < x for x in [-1, 3, 0]]
self.assertEqual(l3(), [0, 1, 0]) self.assertEquals(l3(), [0, 1, 0])
l4 = lambda x = lambda y = lambda z=1 : z : y() : x() l4 = lambda x = lambda y = lambda z=1 : z : y() : x()
self.assertEqual(l4(), 1) self.assertEquals(l4(), 1)
l5 = lambda x, y, z=2: x + y + z l5 = lambda x, y, z=2: x + y + z
self.assertEqual(l5(1, 2), 5) self.assertEquals(l5(1, 2), 5)
self.assertEqual(l5(1, 2, 3), 6) self.assertEquals(l5(1, 2, 3), 6)
check_syntax_error(self, "lambda x: x = 2") check_syntax_error(self, "lambda x: x = 2")
check_syntax_error(self, "lambda (None,): None") check_syntax_error(self, "lambda (None,): None")
l6 = lambda x, y, *, k=20: x+y+k l6 = lambda x, y, *, k=20: x+y+k
self.assertEqual(l6(1,2), 1+2+20) self.assertEquals(l6(1,2), 1+2+20)
self.assertEqual(l6(1,2,k=10), 1+2+10) self.assertEquals(l6(1,2,k=10), 1+2+10)
### stmt: simple_stmt | compound_stmt ### stmt: simple_stmt | compound_stmt
...@@ -502,7 +502,7 @@ class GrammarTests(unittest.TestCase): ...@@ -502,7 +502,7 @@ class GrammarTests(unittest.TestCase):
try: try:
assert 0, "msg" assert 0, "msg"
except AssertionError as e: except AssertionError as e:
self.assertEqual(e.args[0], "msg") self.assertEquals(e.args[0], "msg")
else: else:
if __debug__: if __debug__:
self.fail("AssertionError not raised by assert 0") self.fail("AssertionError not raised by assert 0")
...@@ -536,7 +536,7 @@ class GrammarTests(unittest.TestCase): ...@@ -536,7 +536,7 @@ class GrammarTests(unittest.TestCase):
x = 1 x = 1
else: else:
x = 2 x = 2
self.assertEqual(x, 2) self.assertEquals(x, 2)
def testFor(self): def testFor(self):
# 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite] # 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite]
...@@ -688,7 +688,7 @@ class GrammarTests(unittest.TestCase): ...@@ -688,7 +688,7 @@ class GrammarTests(unittest.TestCase):
d[1,2,3] = 4 d[1,2,3] = 4
L = list(d) L = list(d)
L.sort(key=lambda x: x if isinstance(x, tuple) else ()) L.sort(key=lambda x: x if isinstance(x, tuple) else ())
self.assertEqual(str(L), '[1, (1,), (1, 2), (1, 2, 3)]') self.assertEquals(str(L), '[1, (1,), (1, 2), (1, 2, 3)]')
def testAtoms(self): def testAtoms(self):
### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictsetmaker] '}' | NAME | NUMBER | STRING ### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictsetmaker] '}' | NAME | NUMBER | STRING
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment