From: <fwi...@us...> - 2009-08-02 17:13:24
|
Revision: 6623 http://jython.svn.sourceforge.net/jython/?rev=6623&view=rev Author: fwierzbicki Date: 2009-08-02 17:13:16 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Moved the rest of the tests that could be moved from test_codeop_jy to test_codeop.py. Modified Paths: -------------- trunk/jython/Lib/test/test_codeop.py trunk/jython/Lib/test/test_codeop_jy.py Modified: trunk/jython/Lib/test/test_codeop.py =================================================================== --- trunk/jython/Lib/test/test_codeop.py 2009-08-02 00:09:03 UTC (rev 6622) +++ trunk/jython/Lib/test/test_codeop.py 2009-08-02 17:13:16 UTC (rev 6623) @@ -108,12 +108,26 @@ av("\n \na**3","eval") av("#a\n#b\na**3","eval") - # From Jython project, not Jython specific + av("\n\na = 1\n\n") + av("\n\nif 1: a=1\n\n") + + av("if 1:\n pass\n if 1:\n pass\n else:\n pass\n") + av("#a\n\n \na=3\n\n") + + av("\n\na**3","eval") + av("\n \na**3","eval") + av("#a\n#b\na**3","eval") + # this failed under Jython 2.2.1 - av("def x():\n try: pass\n finally: [a for a in (1,2)]\n") + av("def f():\n try: pass\n finally: [x for x in (1,2)]\n") + av("def f():\n pass\n#foo\n") + #XXX: works in CPython + if not is_jython: + av("@a.b.c\ndef f():\n pass\n") + def test_incomplete(self): ai = self.assertIncomplete @@ -155,8 +169,6 @@ ai("9+ \\","eval") ai("lambda z: \\","eval") - # From Jython project, not Jython specific - #Did not work in Jython 2.5rc2 see first issue in # http://bugs.jython.org/issue1354 ai("if True:\n if True:\n if True: \n") @@ -266,10 +278,11 @@ ai("a = 'a\\\n") ai("a = 1","eval") - #XXX: Current limitation in PythonPartial.g prevents this from properly - # erroring on Jython. + + # XXX: PythonPartial.g needs to reject this. if not is_jython: ai("a = (","eval") + ai("]","eval") ai("())","eval") ai("[}","eval") @@ -277,17 +290,30 @@ ai("lambda z:","eval") ai("a b","eval") - # From Jython project, not Jython specific ai("return 2.3") ai("if (a == 1 and b = 2): pass") + # XXX: PythonPartial.g needs to reject these. + if not is_jython: + ai("del 1") + ai("del ()") + ai("del (1,)") + ai("del [1]") + ai("del '1'") + ai("[i for i in range(10)] = (1, 2, 3)") + def test_filename(self): self.assertEquals(compile_command("a = 1\n", "abc").co_filename, compile("a = 1\n", "abc", 'single').co_filename) self.assertNotEquals(compile_command("a = 1\n", "abc").co_filename, compile("a = 1\n", "def", 'single').co_filename) + def test_no_universal_newlines(self): + # previously \r was translated due to universal newlines + code = compile_command("'\rfoo\r'", symbol='eval') + self.assertEqual(eval(code), '\rfoo\r') + def test_main(): run_unittest(CodeopTests) Modified: trunk/jython/Lib/test/test_codeop_jy.py =================================================================== --- trunk/jython/Lib/test/test_codeop_jy.py 2009-08-02 00:09:03 UTC (rev 6622) +++ trunk/jython/Lib/test/test_codeop_jy.py 2009-08-02 17:13:16 UTC (rev 6623) @@ -37,38 +37,25 @@ def test_valid(self): av = self.assertValid + # Failed for Jython 2.5a2. See http://bugs.jython.org/issue1116. + # For some reason this tests fails when run from test_codeops#test_valid + # when run from Jython (works in CPython). + av("@a.b.c\ndef f():\n pass") + + # These tests pass on Jython, but fail on CPython. Will need to investigate + # to decide if we need to match CPython. av("\n\n") av("# a\n") - av("\n\na = 1\n\n",values={'a':1}) - av("\n\nif 1: a=1\n\n",values={'a':1}) - - av("def x():\n pass") av("def x():\n pass\n ") av("def x():\n pass\n ") - av("\n\ndef x():\n pass") - - av("if 9==3:\n pass\nelse:\n pass") - av("if 1:\n pass\n if 1:\n pass\n else:\n pass") - av("#a\n\n \na=3\n",values={'a':3}) - - - # these failed under 2.1 - self.eval_d = {'a': 2} - av("\n\na**3","eval",value=8) - av("\n \na**3","eval",value=8) - av("#a\n#b\na**3","eval",value=8) - - # this failed under 2.2.1 - av("def f():\n try: pass\n finally: [x for x in (1,2)]") - - # Failed for Jython 2.5a2. See http://bugs.jython.org/issue1116. - av("@a.b.c\ndef f():\n pass") - av("def f():\n pass\n#foo") + # these tests fail in Jython in test_codeop.py because PythonPartial.g + # erroneously allows them through. Once that is fixed, these tests + # can be deleted. def test_invalid(self): ai = self.assertInvalid @@ -80,17 +67,8 @@ ai("[i for i in range(10)] = (1, 2, 3)") -class CodeopTests(unittest.TestCase): - - def test_no_universal_newlines(self): - # previously \r was translated due to universal newlines - code = codeop.compile_command("'\rfoo\r'", symbol='eval') - self.assertEqual(eval(code), '\rfoo\r') - - def test_main(): - run_unittest(CompileTests, - CodeopTests) + run_unittest(CompileTests) if __name__ == "__main__": This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |