src/test/01-Basic/168-depend-mutual.ck
raw| 1 | // mutual recursion + dependency tracking |
| 2 | |
| 3 | // shared variable init |
| 4 | 5 => int n; |
| 5 | |
| 6 | // this should work |
| 7 | foo(); |
| 8 | |
| 9 | // foo(), calls bar() |
| 10 | fun void foo() |
| 11 | { |
| 12 | // condition |
| 13 | if( n > 0 ) |
| 14 | { |
| 15 | n--; |
| 16 | bar(); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | // bar(), calls foo() |
| 21 | fun void bar() |
| 22 | { |
| 23 | // condition |
| 24 | if( n > 0 ) |
| 25 | { |
| 26 | n--; |
| 27 | foo(); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | if( n == 0 ) <<< "success" >>>; |