Towards single compilation

This commit is contained in:
rocky
2016-04-17 22:37:05 -04:00
parent 2c7fcf9e62
commit 7e0526d627
5 changed files with 49 additions and 7 deletions

View File

@@ -0,0 +1,22 @@
import pytest
from uncompyle6 import PYTHON_VERSION, PYTHON3, deparse_code
@pytest.mark.skip(reason="Reinstate when we have compiilation single")
def test_single_mode():
single_expressions = (
'i = 1',
'i and (j or k)',
'i += 1',
'i = j % 4',
'i = {}',
'i = []',
'while i < 1 or stop:\n i\n',
'while i < 1 or stop:\n print%s\n' % ('(i)' if PYTHON3 else ' i'),
'for i in range(10):\n i\n',
'for i in range(10):\n for j in range(10):\n i + j\n',
'try:\n i\nexcept Exception:\n j\nelse:\n k\n'
)
for expr in single_expressions:
code = compile(expr + '\n', '<string>', 'single')
assert deparse_code(PYTHON_VERSION, code, compile_mode='single').text == expr + '\n'