From 838211660cd8f3d7c3e3c334f8753466cd70622a Mon Sep 17 00:00:00 2001 From: Ge Wang Date: Thu, 26 Oct 2023 00:09:24 -0700 Subject: [PATCH] add unit test 228 --- src/test/01-Basic/228-dangle-ref-recurse.ck | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/test/01-Basic/228-dangle-ref-recurse.ck diff --git a/src/test/01-Basic/228-dangle-ref-recurse.ck b/src/test/01-Basic/228-dangle-ref-recurse.ck new file mode 100644 index 000000000..205f66fa6 --- /dev/null +++ b/src/test/01-Basic/228-dangle-ref-recurse.ck @@ -0,0 +1,22 @@ +// test dangling object cleanup on recursive functions that return Objects + +// test object +Object foo; + +// a recrusive function +fun Object get( int i ) +{ + // stop recursion + if( i == 10 ) return foo; + // calls + get(i+1), get(i+1), get(i+1); + // another call + return get(i+1); +} + +// get started +get(0); + +// check +if( Machine.refcount(foo) == 1 ) <<< "success" >>>; +