tests/stress: Add test to verify the GC can trace nested objects.

This commit is contained in:
Damien George 2018-04-04 13:58:57 +10:00
parent 7d5c753b17
commit a45a34ec31
2 changed files with 18 additions and 0 deletions

View File

@ -366,6 +366,7 @@ def run_tests(pyb, tests, args, base_path="."):
skip_tests.add('micropython/heapalloc_traceback.py') # because native doesn't have proper traceback info
skip_tests.add('micropython/heapalloc_iter.py') # requires generators
skip_tests.add('micropython/schedule.py') # native code doesn't check pending events
skip_tests.add('stress/gc_trace.py') # requires yield
for test_file in tests:
test_file = test_file.replace('\\', '/')

17
tests/stress/gc_trace.py Normal file
View File

@ -0,0 +1,17 @@
# test that the GC can trace nested objects
try:
import gc
except ImportError:
print("SKIP")
raise SystemExit
# test a big shallow object pointing to many unique objects
lst = [[i] for i in range(200)]
gc.collect()
print(lst)
# test a deep object
lst = [[[[[(i, j, k, l)] for i in range(3)] for j in range(3)] for k in range(3)] for l in range(3)]
gc.collect()
print(lst)