You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
@@ -98,6 +98,16 @@ check-bytecode-2.4:
|
|||||||
check-bytecode-2.5:
|
check-bytecode-2.5:
|
||||||
$(PYTHON) test_pythonlib.py --bytecode-2.5
|
$(PYTHON) test_pythonlib.py --bytecode-2.5
|
||||||
|
|
||||||
|
#: Get grammar coverage for Python 2.6
|
||||||
|
grammar-coverage-2.6:
|
||||||
|
SPARK_PARSER_COVERAGE=/tmp/spark-grammar-26.cover $(PYTHON) test_pythonlib.py --bytecode-2.6
|
||||||
|
SPARK_PARSER_COVERAGE=/tmp/spark-grammar-26.cover $(PYTHON) test_pyenvlib.py --2.6.9
|
||||||
|
|
||||||
|
#: Get grammar coverage for Python 2.7
|
||||||
|
grammar-coverage-2.7:
|
||||||
|
SPARK_PARSER_COVERAGE=/tmp/spark-grammar-27.cover $(PYTHON) test_pythonlib.py --bytecode-2.7
|
||||||
|
SPARK_PARSER_COVERAGE=/tmp/spark-grammar-27.cover $(PYTHON) test_pyenvlib.py --2.7.13
|
||||||
|
|
||||||
#: Check deparsing Python 2.6
|
#: Check deparsing Python 2.6
|
||||||
check-bytecode-2.6:
|
check-bytecode-2.6:
|
||||||
$(PYTHON) test_pythonlib.py --bytecode-2.6 --weak-verify
|
$(PYTHON) test_pythonlib.py --bytecode-2.6 --weak-verify
|
||||||
|
BIN
test/bytecode_2.6/01_ops.pyc
Normal file
BIN
test/bytecode_2.6/01_ops.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_2.7/01_ops.pyc
Normal file
BIN
test/bytecode_2.7/01_ops.pyc
Normal file
Binary file not shown.
10
test/simple_source/bug22/01_ops.py
Normal file
10
test/simple_source/bug22/01_ops.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Statements to beef up grammar coverage rules
|
||||||
|
# Force "inplace" ops
|
||||||
|
y = +10 # UNARY_POSITIVE
|
||||||
|
y /= 1 # INPLACE_DIVIDE
|
||||||
|
y %= 4 # INPLACE_MODULO
|
||||||
|
y **= 1 # INPLACE POWER
|
||||||
|
y >>= 2 # INPLACE_RSHIFT
|
||||||
|
y <<= 2 # INPLACE_LSHIFT
|
||||||
|
y //= 1 # INPLACE_TRUE_DIVIDE
|
||||||
|
`y` # UNARY_CONVERT - No in Python 3.x
|
@@ -30,7 +30,7 @@ from fnmatch import fnmatch
|
|||||||
TEST_VERSIONS=('2.3.7', '2.4.6', '2.5.6', '2.6.9',
|
TEST_VERSIONS=('2.3.7', '2.4.6', '2.5.6', '2.6.9',
|
||||||
'pypy-2.4.0', 'pypy-2.6.1',
|
'pypy-2.4.0', 'pypy-2.6.1',
|
||||||
'pypy-5.0.1', 'pypy-5.3.1',
|
'pypy-5.0.1', 'pypy-5.3.1',
|
||||||
'2.7.10', '2.7.11', '2.7.12',
|
'2.7.10', '2.7.11', '2.7.12', '2.7.13',
|
||||||
'3.0.1', '3.1.5', '3.2.6',
|
'3.0.1', '3.1.5', '3.2.6',
|
||||||
'3.3.5', '3.3.6',
|
'3.3.5', '3.3.6',
|
||||||
'3.4.2', '3.5.1', '3.6.0')
|
'3.4.2', '3.5.1', '3.6.0')
|
||||||
@@ -106,28 +106,40 @@ def do_tests(src_dir, patterns, target_dir, start_with=None, do_verify=False):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import getopt, sys
|
import getopt, sys
|
||||||
|
|
||||||
do_verify = False
|
do_coverage = do_verify = False
|
||||||
test_dirs = []
|
test_dirs = []
|
||||||
start_with = None
|
start_with = None
|
||||||
|
|
||||||
test_options_keys = list(test_options.keys())
|
test_options_keys = list(test_options.keys())
|
||||||
test_options_keys.sort()
|
test_options_keys.sort()
|
||||||
opts, args = getopt.getopt(sys.argv[1:], '',
|
opts, args = getopt.getopt(sys.argv[1:], '',
|
||||||
['start-with=', 'verify', 'weak-verify', 'all', ] \
|
['start-with=', 'verify', 'weak-verify',
|
||||||
|
'coverage', 'all', ] \
|
||||||
+ test_options_keys )
|
+ test_options_keys )
|
||||||
|
vers = ''
|
||||||
for opt, val in opts:
|
for opt, val in opts:
|
||||||
if opt == '--verify':
|
if opt == '--verify':
|
||||||
do_verify = True
|
do_verify = True
|
||||||
if opt == '--weak-verify':
|
if opt == '--weak-verify':
|
||||||
do_verify = 'weak'
|
do_verify = 'weak'
|
||||||
|
if opt == '--coverage':
|
||||||
|
do_coverage = True
|
||||||
elif opt == '--start-with':
|
elif opt == '--start-with':
|
||||||
start_with = val
|
start_with = val
|
||||||
elif opt[2:] in test_options_keys:
|
elif opt[2:] in test_options_keys:
|
||||||
test_dirs.append(test_options[opt[2:]])
|
triple = test_options[opt[2:]]
|
||||||
|
vers = triple[-1]
|
||||||
|
test_dirs.append(triple)
|
||||||
elif opt == '--all':
|
elif opt == '--all':
|
||||||
|
vers = 'all'
|
||||||
for val in test_options_keys:
|
for val in test_options_keys:
|
||||||
test_dirs.append(test_options[val])
|
test_dirs.append(test_options[val])
|
||||||
|
|
||||||
|
if do_coverage:
|
||||||
|
os.environ['SPARK_PARSER_COVERAGE'] = (
|
||||||
|
'/tmp/spark-grammar-%s.cover' % vers
|
||||||
|
)
|
||||||
|
|
||||||
for src_dir, pattern, target_dir in test_dirs:
|
for src_dir, pattern, target_dir in test_dirs:
|
||||||
if os.path.exists(src_dir):
|
if os.path.exists(src_dir):
|
||||||
target_dir = os.path.join(target_base, target_dir)
|
target_dir = os.path.join(target_base, target_dir)
|
||||||
|
@@ -190,6 +190,7 @@ if __name__ == '__main__':
|
|||||||
test_options_keys.sort()
|
test_options_keys.sort()
|
||||||
opts, args = getopt.getopt(sys.argv[1:], '',
|
opts, args = getopt.getopt(sys.argv[1:], '',
|
||||||
['start-with=', 'verify', 'weak-verify', 'all', 'compile',
|
['start-with=', 'verify', 'weak-verify', 'all', 'compile',
|
||||||
|
'coverage',
|
||||||
'no-rm'] \
|
'no-rm'] \
|
||||||
+ test_options_keys )
|
+ test_options_keys )
|
||||||
if not opts: help()
|
if not opts: help()
|
||||||
@@ -198,7 +199,8 @@ if __name__ == '__main__':
|
|||||||
'do_compile': False,
|
'do_compile': False,
|
||||||
'do_verify': False,
|
'do_verify': False,
|
||||||
'start_with': None,
|
'start_with': None,
|
||||||
'rmtree' : True
|
'rmtree' : True,
|
||||||
|
'coverage' : False
|
||||||
}
|
}
|
||||||
|
|
||||||
for opt, val in opts:
|
for opt, val in opts:
|
||||||
@@ -217,11 +219,18 @@ if __name__ == '__main__':
|
|||||||
elif opt == '--all':
|
elif opt == '--all':
|
||||||
for val in test_options_keys:
|
for val in test_options_keys:
|
||||||
test_dirs.append(test_options[val])
|
test_dirs.append(test_options[val])
|
||||||
|
elif opt == '--coverage':
|
||||||
|
test_opts['coverage'] = True
|
||||||
else:
|
else:
|
||||||
help()
|
help()
|
||||||
pass
|
pass
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if test_opts['coverage']:
|
||||||
|
os.environ['SPARK_PARSER_COVERAGE'] = (
|
||||||
|
'/tmp/spark-grammar-%s.cover' % test_dirs[0][-1]
|
||||||
|
)
|
||||||
|
|
||||||
last_compile_version = None
|
last_compile_version = None
|
||||||
for src_dir, pattern, target_dir, compiled_version in test_dirs:
|
for src_dir, pattern, target_dir, compiled_version in test_dirs:
|
||||||
if os.path.isdir(src_dir):
|
if os.path.isdir(src_dir):
|
||||||
|
@@ -73,7 +73,7 @@ TABLE_DIRECT = {
|
|||||||
'BINARY_MULTIPLY': ( '*' ,),
|
'BINARY_MULTIPLY': ( '*' ,),
|
||||||
'BINARY_DIVIDE': ( '/' ,),
|
'BINARY_DIVIDE': ( '/' ,),
|
||||||
'BINARY_MATRIX_MULTIPLY': ( '@' ,),
|
'BINARY_MATRIX_MULTIPLY': ( '@' ,),
|
||||||
'BINARY_TRUE_DIVIDE': ( '/' ,),
|
'BINARY_TRUE_DIVIDE': ( '/' ,), # Not in <= 2.1
|
||||||
'BINARY_FLOOR_DIVIDE': ( '//' ,),
|
'BINARY_FLOOR_DIVIDE': ( '//' ,),
|
||||||
'BINARY_MODULO': ( '%%',),
|
'BINARY_MODULO': ( '%%',),
|
||||||
'BINARY_POWER': ( '**',),
|
'BINARY_POWER': ( '**',),
|
||||||
@@ -87,7 +87,7 @@ TABLE_DIRECT = {
|
|||||||
'INPLACE_MULTIPLY': ( '*=' ,),
|
'INPLACE_MULTIPLY': ( '*=' ,),
|
||||||
'INPLACE_MATRIX_MULTIPLY': ( '@=' ,),
|
'INPLACE_MATRIX_MULTIPLY': ( '@=' ,),
|
||||||
'INPLACE_DIVIDE': ( '/=' ,),
|
'INPLACE_DIVIDE': ( '/=' ,),
|
||||||
'INPLACE_TRUE_DIVIDE': ( '/=' ,),
|
'INPLACE_TRUE_DIVIDE': ( '/=' ,), # Not in <= 2.1; 2.6 generates INPLACE_DIVIDE only?
|
||||||
'INPLACE_FLOOR_DIVIDE': ( '//=' ,),
|
'INPLACE_FLOOR_DIVIDE': ( '//=' ,),
|
||||||
'INPLACE_MODULO': ( '%%=',),
|
'INPLACE_MODULO': ( '%%=',),
|
||||||
'INPLACE_POWER': ( '**=',),
|
'INPLACE_POWER': ( '**=',),
|
||||||
|
Reference in New Issue
Block a user