From: <zy...@us...> - 2009-05-08 05:51:45
|
Revision: 6317 http://jython.svn.sourceforge.net/jython/?rev=6317&view=rev Author: zyasoft Date: 2009-05-08 05:51:42 +0000 (Fri, 08 May 2009) Log Message: ----------- Added limited testing of org.python.core.PyBytecode (PBC-VM) Added Paths: ----------- trunk/jython/Lib/test/output/test_types_pyc trunk/jython/Lib/test/pbcvm/ trunk/jython/Lib/test/pbcvm/test/ trunk/jython/Lib/test/pbcvm/test/README trunk/jython/Lib/test/pbcvm/test/__init__.py trunk/jython/Lib/test/pbcvm/test/test_builtin_pyc.pyc trunk/jython/Lib/test/pbcvm/test/test_exceptions_pyc.pyc trunk/jython/Lib/test/pbcvm/test/test_types_pyc.pyc trunk/jython/Lib/test/test_pbcvm.py Added: trunk/jython/Lib/test/output/test_types_pyc =================================================================== --- trunk/jython/Lib/test/output/test_types_pyc (rev 0) +++ trunk/jython/Lib/test/output/test_types_pyc 2009-05-08 05:51:42 UTC (rev 6317) @@ -0,0 +1,15 @@ +test_types_pyc +6. Built-in types +6.1 Truth value testing +6.2 Boolean operations +6.3 Comparisons +6.4 Numeric types (mostly conversions) +6.4.1 32-bit integers +6.4.2 Long integers +6.4.3 Floating point numbers +6.5 Sequence types +6.5.1 Strings +6.5.2 Tuples [see test_tuple.py] +6.5.3 Lists [see test_list.py] +6.6 Mappings == Dictionaries [see test_dict.py] +Buffers Added: trunk/jython/Lib/test/pbcvm/test/README =================================================================== --- trunk/jython/Lib/test/pbcvm/test/README (rev 0) +++ trunk/jython/Lib/test/pbcvm/test/README 2009-05-08 05:51:42 UTC (rev 6317) @@ -0,0 +1 @@ +Contains precompiled pyc files for testing org.python.core.PyBytecode by test_pbcvm - don't delete! Added: trunk/jython/Lib/test/pbcvm/test/__init__.py =================================================================== --- trunk/jython/Lib/test/pbcvm/test/__init__.py (rev 0) +++ trunk/jython/Lib/test/pbcvm/test/__init__.py 2009-05-08 05:51:42 UTC (rev 6317) @@ -0,0 +1 @@ +# mock test directory Added: trunk/jython/Lib/test/pbcvm/test/test_builtin_pyc.pyc =================================================================== (Binary files differ) Property changes on: trunk/jython/Lib/test/pbcvm/test/test_builtin_pyc.pyc ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/jython/Lib/test/pbcvm/test/test_exceptions_pyc.pyc =================================================================== (Binary files differ) Property changes on: trunk/jython/Lib/test/pbcvm/test/test_exceptions_pyc.pyc ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/jython/Lib/test/pbcvm/test/test_types_pyc.pyc =================================================================== (Binary files differ) Property changes on: trunk/jython/Lib/test/pbcvm/test/test_types_pyc.pyc ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/jython/Lib/test/test_pbcvm.py =================================================================== --- trunk/jython/Lib/test/test_pbcvm.py (rev 0) +++ trunk/jython/Lib/test/test_pbcvm.py 2009-05-08 05:51:42 UTC (rev 6317) @@ -0,0 +1,71 @@ +import inspect +import os.path +import sys +import unittest +from test import test_support +from regrtest import runtest + +def make_fib_function(): + from org.python.core import PyBytecode, PyFunction + co_argcount = 1 + co_nlocals = 1 + co_stacksize = 4 + co_flags = 67 + co_code = '|\x00\x00d\x01\x00j\x02\x00p\r\x00\x01|\x00\x00d\x02\x00j\x02\x00o\x08\x00\x01d\x02\x00Sn\x1d\x00\x01t\x00\x00|\x00\x00d\x03\x00\x18\x83\x01\x00t\x00\x00|\x00\x00d\x02\x00\x18\x83\x01\x00\x17Sd\x00\x00S' + co_consts = (None, 0, 1, 2) + co_names = ('fib',) + co_varnames = ('x',) + co_filename = '<fib test code>' + co_name = 'fib' + co_firstlineno = 1 + co_lnotab = '\x00\x01\x1a\x01\x08\x02' + co_freevars = () + co_cellvars = () + + c = PyBytecode( + co_argcount, co_nlocals, co_stacksize, co_flags, + co_code, co_consts, co_names, co_varnames, + co_filename, co_name, co_firstlineno, co_lnotab, co_freevars, co_cellvars) + + return PyFunction(c, globals()) + +fib = make_fib_function() + +class PyBytecodeTest(unittest.TestCase): + + def test_fib(self): + expected_fib = [1,1,2,3,5,8,13,21,34,55] + for i in range(10): + self.assertEquals(fib(i), expected_fib[i]) + +class AdhocRegrtest(unittest.TestCase): + + def setUp(self): + self.old_verbosity = test_support.verbose + test_support.verbose = 0 + import pycimport + sys.path.insert(0, os.path.join(os.path.split(inspect.getfile(self.__class__))[0], 'pbcvm')) + + def test_regrtest_pyc(self): + for test in ( + # change the names a bit so we don't have to worry about module unloading or spawning a separate JVM + # however, this testing approach too limits the tests that can be run, so we should rewrite to + # use subprocess asap + 'test_types_pyc', + 'test_exceptions_pyc'): + ok = runtest(test, generate=False, verbose=False, quiet=True, testdir=None, + huntrleaks=False, junit_xml=None) + self.assertTrue(ok > 0) + + def tearDown(self): + # typical unsafe ops we have to do in testing... + test_support.verbose = self.old_verbosity + sys.path.pop(0) + sys.meta_path.pop(0) + + +def test_main(): + test_support.run_unittest(PyBytecodeTest, AdhocRegrtest) + +if __name__ == "__main__": + test_main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |