src/test/01-Basic/229-dangle-ref-spork.ck
raw| 1 | // verify no dangling reference with sporked |
| 2 | // functions that return Objects |
| 3 | |
| 4 | Object foo; |
| 5 | |
| 6 | // function that returns an Object |
| 7 | fun Object get() |
| 8 | { |
| 9 | return foo; |
| 10 | } |
| 11 | |
| 12 | // spork |
| 13 | spork ~ get(); |
| 14 | |
| 15 | // give sporked function a chance to run |
| 16 | 10::ms => now; |
| 17 | |
| 18 | // check reference count |
| 19 | if( Machine.refcount(foo) == 1 ) <<< "success" >>>; |