summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_peepholer.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_peepholer.py')
-rw-r--r--Lib/test/test_peepholer.py62
1 files changed, 31 insertions, 31 deletions
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index 1543f3b..5696500 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -25,9 +25,9 @@ class TestTranforms(unittest.TestCase):
del x
asm = disassemble(unot)
for elem in ('UNARY_NOT', 'POP_JUMP_IF_FALSE'):
- self.assert_(elem not in asm)
+ self.assertTrue(elem not in asm)
for elem in ('POP_JUMP_IF_TRUE',):
- self.assert_(elem in asm)
+ self.assertTrue(elem in asm)
def test_elim_inversion_of_is_or_in(self):
for line, elem in (
@@ -37,7 +37,7 @@ class TestTranforms(unittest.TestCase):
('not a not in b', '(in)',),
):
asm = dis_single(line)
- self.assert_(elem in asm)
+ self.assertTrue(elem in asm)
def test_global_as_constant(self):
# LOAD_GLOBAL None/True/False --> LOAD_CONST None/True/False
@@ -54,14 +54,14 @@ class TestTranforms(unittest.TestCase):
for func, name in ((f, 'None'), (g, 'True'), (h, 'False')):
asm = disassemble(func)
for elem in ('LOAD_GLOBAL',):
- self.assert_(elem not in asm)
+ self.assertTrue(elem not in asm)
for elem in ('LOAD_CONST', '('+name+')'):
- self.assert_(elem in asm)
+ self.assertTrue(elem in asm)
def f():
'Adding a docstring made this test fail in Py2.5.0'
return None
- self.assert_('LOAD_CONST' in disassemble(f))
- self.assert_('LOAD_GLOBAL' not in disassemble(f))
+ self.assertTrue('LOAD_CONST' in disassemble(f))
+ self.assertTrue('LOAD_GLOBAL' not in disassemble(f))
def test_while_one(self):
# Skip over: LOAD_CONST trueconst POP_JUMP_IF_FALSE xx
@@ -71,9 +71,9 @@ class TestTranforms(unittest.TestCase):
return list
asm = disassemble(f)
for elem in ('LOAD_CONST', 'POP_JUMP_IF_FALSE'):
- self.assert_(elem not in asm)
+ self.assertTrue(elem not in asm)
for elem in ('JUMP_ABSOLUTE',):
- self.assert_(elem in asm)
+ self.assertTrue(elem in asm)
def test_pack_unpack(self):
for line, elem in (
@@ -82,9 +82,9 @@ class TestTranforms(unittest.TestCase):
('a, b, c = a, b, c', 'ROT_THREE',),
):
asm = dis_single(line)
- self.assert_(elem in asm)
- self.assert_('BUILD_TUPLE' not in asm)
- self.assert_('UNPACK_TUPLE' not in asm)
+ self.assertTrue(elem in asm)
+ self.assertTrue('BUILD_TUPLE' not in asm)
+ self.assertTrue('UNPACK_TUPLE' not in asm)
def test_folding_of_tuples_of_constants(self):
for line, elem in (
@@ -95,8 +95,8 @@ class TestTranforms(unittest.TestCase):
('((1, 2), 3, 4)', '(((1, 2), 3, 4))'),
):
asm = dis_single(line)
- self.assert_(elem in asm)
- self.assert_('BUILD_TUPLE' not in asm)
+ self.assertTrue(elem in asm)
+ self.assertTrue('BUILD_TUPLE' not in asm)
# Bug 1053819: Tuple of constants misidentified when presented with:
# . . . opcode_with_arg 100 unary_opcode BUILD_TUPLE 1 . . .
@@ -134,17 +134,17 @@ class TestTranforms(unittest.TestCase):
('a = 13 | 7', '(15)'), # binary or
):
asm = dis_single(line)
- self.assert_(elem in asm, asm)
- self.assert_('BINARY_' not in asm)
+ self.assertTrue(elem in asm, asm)
+ self.assertTrue('BINARY_' not in asm)
# Verify that unfoldables are skipped
asm = dis_single('a=2+"b"')
- self.assert_('(2)' in asm)
- self.assert_("('b')" in asm)
+ self.assertTrue('(2)' in asm)
+ self.assertTrue("('b')" in asm)
# Verify that large sequences do not result from folding
asm = dis_single('a="x"*1000')
- self.assert_('(1000)' in asm)
+ self.assertTrue('(1000)' in asm)
def test_folding_of_unaryops_on_constants(self):
for line, elem in (
@@ -152,8 +152,8 @@ class TestTranforms(unittest.TestCase):
('~-2', '(1)'), # unary invert
):
asm = dis_single(line)
- self.assert_(elem in asm, asm)
- self.assert_('UNARY_' not in asm)
+ self.assertTrue(elem in asm, asm)
+ self.assertTrue('UNARY_' not in asm)
# Verify that unfoldables are skipped
for line, elem in (
@@ -161,16 +161,16 @@ class TestTranforms(unittest.TestCase):
('~"abc"', "('abc')"), # unary invert
):
asm = dis_single(line)
- self.assert_(elem in asm, asm)
- self.assert_('UNARY_' in asm)
+ self.assertTrue(elem in asm, asm)
+ self.assertTrue('UNARY_' in asm)
def test_elim_extra_return(self):
# RETURN LOAD_CONST None RETURN --> RETURN
def f(x):
return x
asm = disassemble(f)
- self.assert_('LOAD_CONST' not in asm)
- self.assert_('(None)' not in asm)
+ self.assertTrue('LOAD_CONST' not in asm)
+ self.assertTrue('(None)' not in asm)
self.assertEqual(asm.split().count('RETURN_VALUE'), 1)
def test_elim_jump_to_return(self):
@@ -178,8 +178,8 @@ class TestTranforms(unittest.TestCase):
def f(cond, true_value, false_value):
return true_value if cond else false_value
asm = disassemble(f)
- self.assert_('JUMP_FORWARD' not in asm)
- self.assert_('JUMP_ABSOLUTE' not in asm)
+ self.assertTrue('JUMP_FORWARD' not in asm)
+ self.assertTrue('JUMP_ABSOLUTE' not in asm)
self.assertEqual(asm.split().count('RETURN_VALUE'), 2)
def test_elim_jump_after_return1(self):
@@ -194,8 +194,8 @@ class TestTranforms(unittest.TestCase):
return 5
return 6
asm = disassemble(f)
- self.assert_('JUMP_FORWARD' not in asm)
- self.assert_('JUMP_ABSOLUTE' not in asm)
+ self.assertTrue('JUMP_FORWARD' not in asm)
+ self.assertTrue('JUMP_ABSOLUTE' not in asm)
self.assertEqual(asm.split().count('RETURN_VALUE'), 6)
def test_elim_jump_after_return2(self):
@@ -204,7 +204,7 @@ class TestTranforms(unittest.TestCase):
while 1:
if cond1: return 4
asm = disassemble(f)
- self.assert_('JUMP_FORWARD' not in asm)
+ self.assertTrue('JUMP_FORWARD' not in asm)
# There should be one jump for the while loop.
self.assertEqual(asm.split().count('JUMP_ABSOLUTE'), 1)
self.assertEqual(asm.split().count('RETURN_VALUE'), 2)
@@ -215,7 +215,7 @@ class TestTranforms(unittest.TestCase):
pass
return g
asm = disassemble(f)
- self.assert_('BINARY_ADD' not in asm)
+ self.assertTrue('BINARY_ADD' not in asm)
def test_main(verbose=None):