mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
GH-111485: Delete the old generator code. (GH-113321)
This commit is contained in:
parent
fae096cd4b
commit
723f4d6698
18 changed files with 210 additions and 3723 deletions
|
@ -15,9 +15,8 @@ def skip_if_different_mount_drives():
|
|||
root_drive = os.path.splitroot(ROOT)[0]
|
||||
cwd_drive = os.path.splitroot(os.getcwd())[0]
|
||||
if root_drive != cwd_drive:
|
||||
# generate_cases.py uses relpath() which raises ValueError if ROOT
|
||||
# and the current working different have different mount drives
|
||||
# (on Windows).
|
||||
# May raise ValueError if ROOT and the current working
|
||||
# different have different mount drives (on Windows).
|
||||
raise unittest.SkipTest(
|
||||
f"the current working directory and the Python source code "
|
||||
f"directory have different mount drives "
|
||||
|
@ -28,10 +27,9 @@ skip_if_different_mount_drives()
|
|||
|
||||
test_tools.skip_if_missing('cases_generator')
|
||||
with test_tools.imports_under_tool('cases_generator'):
|
||||
import generate_cases
|
||||
import analysis
|
||||
import formatting
|
||||
from parsing import StackEffect
|
||||
from analyzer import StackItem
|
||||
import parser
|
||||
from stack import Stack
|
||||
import tier1_generator
|
||||
|
||||
|
||||
|
@ -43,37 +41,24 @@ def handle_stderr():
|
|||
|
||||
class TestEffects(unittest.TestCase):
|
||||
def test_effect_sizes(self):
|
||||
input_effects = [
|
||||
x := StackEffect("x", "", "", ""),
|
||||
y := StackEffect("y", "", "", "oparg"),
|
||||
z := StackEffect("z", "", "", "oparg*2"),
|
||||
stack = Stack()
|
||||
inputs = [
|
||||
x:= StackItem("x", None, "", "1"),
|
||||
y:= StackItem("y", None, "", "oparg"),
|
||||
z:= StackItem("z", None, "", "oparg*2"),
|
||||
]
|
||||
output_effects = [
|
||||
StackEffect("a", "", "", ""),
|
||||
StackEffect("b", "", "", "oparg*4"),
|
||||
StackEffect("c", "", "", ""),
|
||||
outputs = [
|
||||
StackItem("x", None, "", "1"),
|
||||
StackItem("b", None, "", "oparg*4"),
|
||||
StackItem("c", None, "", "1"),
|
||||
]
|
||||
other_effects = [
|
||||
StackEffect("p", "", "", "oparg<<1"),
|
||||
StackEffect("q", "", "", ""),
|
||||
StackEffect("r", "", "", ""),
|
||||
]
|
||||
self.assertEqual(formatting.effect_size(x), (1, ""))
|
||||
self.assertEqual(formatting.effect_size(y), (0, "oparg"))
|
||||
self.assertEqual(formatting.effect_size(z), (0, "oparg*2"))
|
||||
|
||||
self.assertEqual(
|
||||
formatting.list_effect_size(input_effects),
|
||||
(1, "oparg + oparg*2"),
|
||||
)
|
||||
self.assertEqual(
|
||||
formatting.list_effect_size(output_effects),
|
||||
(2, "oparg*4"),
|
||||
)
|
||||
self.assertEqual(
|
||||
formatting.list_effect_size(other_effects),
|
||||
(2, "(oparg<<1)"),
|
||||
)
|
||||
stack.pop(z)
|
||||
stack.pop(y)
|
||||
stack.pop(x)
|
||||
for out in outputs:
|
||||
stack.push(out)
|
||||
self.assertEqual(stack.base_offset.to_c(), "-1 - oparg*2 - oparg")
|
||||
self.assertEqual(stack.top_offset.to_c(), "1 - oparg*2 - oparg + oparg*4")
|
||||
|
||||
|
||||
class TestGeneratedCases(unittest.TestCase):
|
||||
|
@ -104,9 +89,9 @@ class TestGeneratedCases(unittest.TestCase):
|
|||
|
||||
def run_cases_test(self, input: str, expected: str):
|
||||
with open(self.temp_input_filename, "w+") as temp_input:
|
||||
temp_input.write(analysis.BEGIN_MARKER)
|
||||
temp_input.write(parser.BEGIN_MARKER)
|
||||
temp_input.write(input)
|
||||
temp_input.write(analysis.END_MARKER)
|
||||
temp_input.write(parser.END_MARKER)
|
||||
temp_input.flush()
|
||||
|
||||
with handle_stderr():
|
||||
|
@ -636,13 +621,13 @@ class TestGeneratedCases(unittest.TestCase):
|
|||
PyObject *output = NULL;
|
||||
PyObject *zz;
|
||||
cc = stack_pointer[-1];
|
||||
if ((oparg & 1) == 1) { input = stack_pointer[-1 - ((((oparg & 1) == 1) ? 1 : 0))]; }
|
||||
aa = stack_pointer[-2 - ((((oparg & 1) == 1) ? 1 : 0))];
|
||||
if ((oparg & 1) == 1) { input = stack_pointer[-1 - (((oparg & 1) == 1) ? 1 : 0)]; }
|
||||
aa = stack_pointer[-2 - (((oparg & 1) == 1) ? 1 : 0)];
|
||||
output = spam(oparg, input);
|
||||
stack_pointer[-2 - ((((oparg & 1) == 1) ? 1 : 0))] = xx;
|
||||
if (oparg & 2) stack_pointer[-1 - ((((oparg & 1) == 1) ? 1 : 0))] = output;
|
||||
stack_pointer[-1 - ((((oparg & 1) == 1) ? 1 : 0)) + (((oparg & 2) ? 1 : 0))] = zz;
|
||||
stack_pointer += -((((oparg & 1) == 1) ? 1 : 0)) + (((oparg & 2) ? 1 : 0));
|
||||
stack_pointer[-2 - (((oparg & 1) == 1) ? 1 : 0)] = xx;
|
||||
if (oparg & 2) stack_pointer[-1 - (((oparg & 1) == 1) ? 1 : 0)] = output;
|
||||
stack_pointer[-1 - (((oparg & 1) == 1) ? 1 : 0) + ((oparg & 2) ? 1 : 0)] = zz;
|
||||
stack_pointer += -(((oparg & 1) == 1) ? 1 : 0) + ((oparg & 2) ? 1 : 0);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
@ -682,8 +667,8 @@ class TestGeneratedCases(unittest.TestCase):
|
|||
}
|
||||
stack_pointer[-3] = deep;
|
||||
if (oparg) stack_pointer[-2] = extra;
|
||||
stack_pointer[-2 + (((oparg) ? 1 : 0))] = res;
|
||||
stack_pointer += -1 + (((oparg) ? 1 : 0));
|
||||
stack_pointer[-2 + ((oparg) ? 1 : 0)] = res;
|
||||
stack_pointer += -1 + ((oparg) ? 1 : 0);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue