mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-27 15:10:55 +00:00
add a single Python 2.6 source/code test
This commit is contained in:
parent
24c301c489
commit
379aeb8813
@ -11,7 +11,7 @@ check: check-short check-2.7-ok
|
||||
|
||||
#: Run quick tests
|
||||
check-short:
|
||||
$(PYTHON) test_pythonlib.py --base2 --verify $(COMPILE)
|
||||
$(PYTHON) test_pythonlib.py --base-2.7 --verify $(COMPILE)
|
||||
|
||||
#: Run longer Python 2.7's lib files known to be okay
|
||||
check-2.7-ok:
|
||||
|
28
test/base-tests/python2.7/test_applyEquiv.pyc_dis_unverified
Normal file
28
test/base-tests/python2.7/test_applyEquiv.pyc_dis_unverified
Normal file
@ -0,0 +1,28 @@
|
||||
# Embedded file name: /src/external-vcs/github/rocky/uncompyle6/test/base-tests/python2/test_applyEquiv.py
|
||||
|
||||
|
||||
def kwfunc(**kwargs):
|
||||
print kwargs.items()
|
||||
|
||||
|
||||
def argsfunc(*args):
|
||||
print args
|
||||
|
||||
|
||||
def no_apply(*args, **kwargs):
|
||||
print args
|
||||
print kwargs.items()
|
||||
argsfunc(34)
|
||||
foo = argsfunc(*args)
|
||||
argsfunc(*args)
|
||||
argsfunc(34, *args)
|
||||
kwfunc(**kwargs)
|
||||
kwfunc(x=11, **kwargs)
|
||||
no_apply(*args, **kwargs)
|
||||
no_apply(34, *args, **kwargs)
|
||||
no_apply(x=11, *args, **kwargs)
|
||||
no_apply(34, x=11, *args, **kwargs)
|
||||
no_apply(42, 34, x=11, *args, **kwargs)
|
||||
|
||||
|
||||
no_apply(1, 2, 4, 8, a=2, b=3, c=5)
|
@ -0,0 +1,57 @@
|
||||
# Embedded file name: /src/external-vcs/github/rocky/uncompyle6/test/base-tests/python2/test_augmentedAssign.py
|
||||
raise "This program can't be run"
|
||||
a = 1
|
||||
b = 2
|
||||
a += b
|
||||
print a
|
||||
a -= b
|
||||
print a
|
||||
a *= b
|
||||
print a
|
||||
a -= a
|
||||
print a
|
||||
a += 21
|
||||
print a
|
||||
l = [1, 2, 3]
|
||||
l[1] *= 3
|
||||
print l[1]
|
||||
l[1][2][3] = 7
|
||||
l[1][2][3] *= 3
|
||||
l[:] += [9]
|
||||
print l
|
||||
l[:2] += [9]
|
||||
print l
|
||||
l[1:] += [9]
|
||||
print l
|
||||
l[1:4] += [9]
|
||||
print l
|
||||
l += [42, 43]
|
||||
print l
|
||||
a.value = 1
|
||||
a.value += 1
|
||||
a.b.val = 1
|
||||
a.b.val += 1
|
||||
l = []
|
||||
for i in range(3):
|
||||
lj = []
|
||||
for j in range(3):
|
||||
lk = []
|
||||
for k in range(3):
|
||||
lk.append(0)
|
||||
|
||||
lj.append(lk)
|
||||
|
||||
l.append(lj)
|
||||
|
||||
i = j = k = 1
|
||||
|
||||
def f():
|
||||
global i
|
||||
i += 1
|
||||
return i
|
||||
|
||||
|
||||
l[i][j][k] = 1
|
||||
i = 1
|
||||
l[f()][j][k] += 1
|
||||
print i, l
|
39
test/base-tests/python2.7/test_class.pyc_dis_unverified
Normal file
39
test/base-tests/python2.7/test_class.pyc_dis_unverified
Normal file
@ -0,0 +1,39 @@
|
||||
# Embedded file name: /src/external-vcs/github/rocky/uncompyle6/test/base-tests/python2/test_class.py
|
||||
|
||||
|
||||
class A:
|
||||
|
||||
class A1:
|
||||
|
||||
def __init__(self):
|
||||
print 'A1.__init__'
|
||||
|
||||
def foo(self):
|
||||
print 'A1.foo'
|
||||
|
||||
def __init__(self):
|
||||
print 'A.__init__'
|
||||
|
||||
def foo(self):
|
||||
print 'A.foo'
|
||||
|
||||
|
||||
class B:
|
||||
|
||||
def __init__(self):
|
||||
print 'B.__init__'
|
||||
|
||||
def bar(self):
|
||||
print 'B.bar'
|
||||
|
||||
|
||||
class C(A, B):
|
||||
|
||||
def foobar(self):
|
||||
print 'C.foobar'
|
||||
|
||||
|
||||
c = C()
|
||||
c.foo()
|
||||
c.bar()
|
||||
c.foobar()
|
@ -0,0 +1,6 @@
|
||||
# Embedded file name: /src/external-vcs/github/rocky/uncompyle6/test/base-tests/python2/test_divide_future.py
|
||||
from __future__ import division
|
||||
print ' 1 // 2 =', 0
|
||||
print '1.0 // 2.0 =', 0.0
|
||||
print ' 1 / 2 =', 0.5
|
||||
print '1.0 / 2.0 =', 0.5
|
118
test/base-tests/python2.7/test_exceptions.pyc_dis_unverified
Normal file
118
test/base-tests/python2.7/test_exceptions.pyc_dis_unverified
Normal file
@ -0,0 +1,118 @@
|
||||
# Embedded file name: /src/external-vcs/github/rocky/uncompyle6/test/base-tests/python2/test_exceptions.py
|
||||
import dis
|
||||
|
||||
def x11():
|
||||
try:
|
||||
a = 'try except'
|
||||
except:
|
||||
a = 2
|
||||
|
||||
b = '--------'
|
||||
|
||||
|
||||
def x12():
|
||||
try:
|
||||
a = 'try except else(pass)'
|
||||
except:
|
||||
a = 2
|
||||
|
||||
b = '--------'
|
||||
|
||||
|
||||
def x13():
|
||||
try:
|
||||
a = 'try except else(a=3)'
|
||||
except:
|
||||
a = 2
|
||||
else:
|
||||
a = 3
|
||||
|
||||
b = '--------'
|
||||
|
||||
|
||||
def x21():
|
||||
try:
|
||||
a = 'try KeyError'
|
||||
except KeyError:
|
||||
a = 8
|
||||
|
||||
b = '--------'
|
||||
|
||||
|
||||
def x22():
|
||||
try:
|
||||
a = 'try (IdxErr, KeyError) else(pass)'
|
||||
except (IndexError, KeyError):
|
||||
a = 8
|
||||
|
||||
b = '--------'
|
||||
|
||||
|
||||
def x23():
|
||||
try:
|
||||
a = 'try KeyError else(a=9)'
|
||||
except KeyError:
|
||||
a = 8
|
||||
else:
|
||||
a = 9
|
||||
|
||||
b = '--------'
|
||||
|
||||
|
||||
def x31():
|
||||
try:
|
||||
a = 'try KeyError IndexError'
|
||||
except KeyError:
|
||||
a = 8
|
||||
except IndexError:
|
||||
a = 9
|
||||
|
||||
b = '--------'
|
||||
|
||||
|
||||
def x32():
|
||||
try:
|
||||
a = 'try KeyError IndexError else(pass)'
|
||||
except KeyError:
|
||||
a = 8
|
||||
except IndexError:
|
||||
a = 9
|
||||
|
||||
b = '--------'
|
||||
|
||||
|
||||
def x33():
|
||||
try:
|
||||
a = 'try KeyError IndexError else(a=9)'
|
||||
except KeyError:
|
||||
a = 8
|
||||
except IndexError:
|
||||
a = 9
|
||||
else:
|
||||
a = 9
|
||||
|
||||
b = '#################'
|
||||
|
||||
|
||||
def x41():
|
||||
if a == 1:
|
||||
a = 1
|
||||
elif b == 1:
|
||||
b = 1
|
||||
else:
|
||||
c = 1
|
||||
b = '#################'
|
||||
|
||||
|
||||
def x42():
|
||||
if a == 1:
|
||||
a = 1
|
||||
elif b == 1:
|
||||
b = 1
|
||||
else:
|
||||
c = 1
|
||||
xxx = 'mmm'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
dis.dis(xx)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
83
test/ok_2.6/anydbm.py
Normal file
83
test/ok_2.6/anydbm.py
Normal file
@ -0,0 +1,83 @@
|
||||
"""Generic interface to all dbm clones.
|
||||
|
||||
Instead of
|
||||
|
||||
import dbm
|
||||
d = dbm.open(file, 'w', 0666)
|
||||
|
||||
use
|
||||
|
||||
import anydbm
|
||||
d = anydbm.open(file, 'w')
|
||||
|
||||
The returned object is a dbhash, gdbm, dbm or dumbdbm object,
|
||||
dependent on the type of database being opened (determined by whichdb
|
||||
module) in the case of an existing dbm. If the dbm does not exist and
|
||||
the create or new flag ('c' or 'n') was specified, the dbm type will
|
||||
be determined by the availability of the modules (tested in the above
|
||||
order).
|
||||
|
||||
It has the following interface (key and data are strings):
|
||||
|
||||
d[key] = data # store data at key (may override data at
|
||||
# existing key)
|
||||
data = d[key] # retrieve data at key (raise KeyError if no
|
||||
# such key)
|
||||
del d[key] # delete data stored at key (raises KeyError
|
||||
# if no such key)
|
||||
flag = key in d # true if the key exists
|
||||
list = d.keys() # return a list of all existing keys (slow!)
|
||||
|
||||
Future versions may change the order in which implementations are
|
||||
tested for existence, add interfaces to other dbm-like
|
||||
implementations.
|
||||
|
||||
The open function has an optional second argument. This can be 'r',
|
||||
for read-only access, 'w', for read-write access of an existing
|
||||
database, 'c' for read-write access to a new or existing database, and
|
||||
'n' for read-write access to a new database. The default is 'r'.
|
||||
|
||||
Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
|
||||
only if it doesn't exist; and 'n' always creates a new database.
|
||||
|
||||
"""
|
||||
|
||||
class error(Exception):
|
||||
pass
|
||||
|
||||
_names = ['dbhash', 'gdbm', 'dbm', 'dumbdbm']
|
||||
_errors = [error]
|
||||
_defaultmod = None
|
||||
|
||||
for _name in _names:
|
||||
try:
|
||||
_mod = __import__(_name)
|
||||
except ImportError:
|
||||
continue
|
||||
if not _defaultmod:
|
||||
_defaultmod = _mod
|
||||
_errors.append(_mod.error)
|
||||
|
||||
if not _defaultmod:
|
||||
raise ImportError, "no dbm clone found; tried %s" % _names
|
||||
|
||||
error = tuple(_errors)
|
||||
|
||||
def open(file, flag = 'r', mode = 0666):
|
||||
# guess the type of an existing database
|
||||
from whichdb import whichdb
|
||||
result=whichdb(file)
|
||||
if result is None:
|
||||
# db doesn't exist
|
||||
if 'c' in flag or 'n' in flag:
|
||||
# file doesn't exist and the new
|
||||
# flag was used so use default type
|
||||
mod = _defaultmod
|
||||
else:
|
||||
raise error, "need 'c' or 'n' flag to open new db"
|
||||
elif result == "":
|
||||
# db type cannot be determined
|
||||
raise error, "db type could not be determined"
|
||||
else:
|
||||
mod = __import__(result)
|
||||
return mod.open(file, flag, mode)
|
@ -46,22 +46,29 @@ PYOC = ('*.pyc', '*.pyo')
|
||||
|
||||
test_options = {
|
||||
# name: (src_basedir, pattern, output_base_suffix)
|
||||
'test': ['test', PYC, 'test'],
|
||||
'2.7': ['python2.7', PYC, 'python2.7'],
|
||||
'ok-2.7': [os.path.join(src_dir, 'ok_2.7'),
|
||||
PYC, 'ok-2.7'],
|
||||
'base2': [os.path.join(src_dir, 'base-tests', 'python2'),
|
||||
PYC, 'base2'],
|
||||
'test': ['test', PYC, 'test'],
|
||||
'2.7': ['python2.7', PYC, 'python2.7'],
|
||||
'ok-2.6': [os.path.join(src_dir, 'ok_2.6'),
|
||||
PYC, 'ok-2.6'],
|
||||
'ok-2.7': [os.path.join(src_dir, 'ok_2.7'),
|
||||
PYC, 'ok-2.7'],
|
||||
'base-2.7': [os.path.join(src_dir, 'base-tests', 'python2.7'),
|
||||
PYC, 'base_2.7'],
|
||||
}
|
||||
|
||||
#-----
|
||||
|
||||
def help():
|
||||
print("""
|
||||
Usage-Examples:
|
||||
test_pythonlib.py --base2 --verify --compile # compile, decompyle and verify short tests
|
||||
test_pythonlib.py --ok-2.7 --verify # decompile and verify known good python 2.7
|
||||
test_pythonlib.py --2.7 # decompile Python's installed lib files
|
||||
print("""Usage-Examples:
|
||||
|
||||
# compile, decompyle and verify short tests for Python 2.7:
|
||||
test_pythonlib.py --base-2.7 --verify --compile
|
||||
|
||||
# decompile and verify known good python 2.7
|
||||
test_pythonlib.py --ok-2.7 --verify
|
||||
|
||||
# decompile all of Python's installed lib files
|
||||
test_pythonlib.py --2.7
|
||||
""")
|
||||
sys.exit(1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user