[Python-checkins] r62823 - python/branches/tlee-ast-optimize/Lib/test/test_optimizer.py
thomas.lee
python-checkins at python.org
Wed May 7 15:30:49 CEST 2008
Author: thomas.lee
Date: Wed May 7 15:30:49 2008
New Revision: 62823
Log:
Add the return/yield None tests back in. Not time to abandon them just yet.
Modified:
python/branches/tlee-ast-optimize/Lib/test/test_optimizer.py
Modified: python/branches/tlee-ast-optimize/Lib/test/test_optimizer.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_optimizer.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_optimizer.py Wed May 7 15:30:49 2008
@@ -169,6 +169,31 @@
self.assertEqual(3, len(ast.body[0].body))
self.assertEqual(_ast.Pass, ast.body[0].body[2].__class__)
+ def test_yield_none_becomes_yield(self):
+ code = """
+def foo():
+ yield None
+"""
+
+ ast = self.compileast(code)
+ self.assertEqual(1, len(ast.body))
+ self.assertEqual(1, len(ast.body[0].body))
+ self.assertEqual(_ast.Expr, ast.body[0].body[0].__class__)
+ self.assertEqual(_ast.Yield, ast.body[0].body[0].value.__class__)
+ self.assertEqual(None, ast.body[0].body[0].value.value)
+
+ def test_return_none_becomes_return(self):
+ code = """
+def foo():
+ return None
+"""
+
+ ast = self.compileast(code)
+ self.assertEqual(1, len(ast.body))
+ self.assertEqual(1, len(ast.body[0].body))
+ self.assertEqual(_ast.Return, ast.body[0].body[0].__class__)
+ self.assertEqual(None, ast.body[0].body[0].value)
+
def test_main():
test_support.run_unittest(AstOptimizerTest)
More information about the Python-checkins
mailing list