Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more tests for stack usage.
  • Loading branch information
markshannon committed Apr 14, 2021
commit a5afaad0785ad3e42dc3b3c21b69f7299f9d3988
26 changes: 26 additions & 0 deletions Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,32 @@ def test_if_else(self):
def test_binop(self):
self.check_stack_size("x + " * self.N + "x")

def test_list(self):
self.check_stack_size("[" + "x, " * self.N + "x]")

def test_tuple(self):
self.check_stack_size("(" + "x, " * self.N + "x)")

def test_set(self):
self.check_stack_size("{" + "x, " * self.N + "x}")

def test_dict(self):
self.check_stack_size("{" + "x:x, " * self.N + "x:x}")

def test_func_args(self):
self.check_stack_size("f(" + "x, " * self.N + ")")

def test_func_kwargs(self):
kwargs = (f'a{i}=x' for i in range(self.N))
self.check_stack_size("f(" + ", ".join(kwargs) + ")")

def test_func_args(self):
self.check_stack_size("o.m(" + "x, " * self.N + ")")

def test_meth_kwargs(self):
kwargs = (f'a{i}=x' for i in range(self.N))
self.check_stack_size("o.m(" + ", ".join(kwargs) + ")")

def test_func_and(self):
code = "def f(x):\n"
code += " x and x\n" * self.N
Expand Down