From a45a34ec313d0fb57e2fb1bbacf6e9209483bbe6 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 4 Apr 2018 13:58:57 +1000 Subject: [PATCH] tests/stress: Add test to verify the GC can trace nested objects. --- tests/run-tests | 1 + tests/stress/gc_trace.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/stress/gc_trace.py diff --git a/tests/run-tests b/tests/run-tests index 627fa40dac..ef2f4bc6a5 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -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('\\', '/') diff --git a/tests/stress/gc_trace.py b/tests/stress/gc_trace.py new file mode 100644 index 0000000000..72dc7b6276 --- /dev/null +++ b/tests/stress/gc_trace.py @@ -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)