Skip to content

Commit a45a34e

Browse files
committed
tests/stress: Add test to verify the GC can trace nested objects.
1 parent 7d5c753 commit a45a34e

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

tests/run-tests

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ def run_tests(pyb, tests, args, base_path="."):
366366
skip_tests.add('micropython/heapalloc_traceback.py') # because native doesn't have proper traceback info
367367
skip_tests.add('micropython/heapalloc_iter.py') # requires generators
368368
skip_tests.add('micropython/schedule.py') # native code doesn't check pending events
369+
skip_tests.add('stress/gc_trace.py') # requires yield
369370

370371
for test_file in tests:
371372
test_file = test_file.replace('\\', '/')

tests/stress/gc_trace.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# test that the GC can trace nested objects
2+
3+
try:
4+
import gc
5+
except ImportError:
6+
print("SKIP")
7+
raise SystemExit
8+
9+
# test a big shallow object pointing to many unique objects
10+
lst = [[i] for i in range(200)]
11+
gc.collect()
12+
print(lst)
13+
14+
# test a deep object
15+
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)]
16+
gc.collect()
17+
print(lst)

0 commit comments

Comments
 (0)