src/test/01-Basic/228-dangle-ref-recurse.ck
raw| 1 | // test dangling object cleanup on recursive functions that return Objects |
| 2 | |
| 3 | // test object |
| 4 | Object foo; |
| 5 | |
| 6 | // a recrusive function |
| 7 | fun Object get( int i ) |
| 8 | { |
| 9 | // stop recursion |
| 10 | if( i == 10 ) return foo; |
| 11 | // calls |
| 12 | get(i+1), get(i+1), get(i+1); |
| 13 | // another call |
| 14 | return get(i+1); |
| 15 | } |
| 16 | |
| 17 | // get started |
| 18 | get(0); |
| 19 | |
| 20 | // check |
| 21 | if( Machine.refcount(foo) == 1 ) <<< "success" >>>; |
| 22 |