Debian Codegraph @

src/test/04-Stress/return-test.ck

raw
1 // function return stress test (run with --silent)
2
3 // recursion max depth
4 25 => int MAX_DEPTH;
5
6 // f1
7 fun int f1( int depth )
8 {
9 if( depth >= MAX_DEPTH ) return 1;
10 if(maybe) return f2( depth+1 );
11 return 1;
12 }
13
14 // f2
15 fun int f2( int depth )
16 {
17 if( depth >= MAX_DEPTH ) return 2;
18 if(maybe) return f1( depth+1 );
19 return 2;
20 }
21
22 // test duration
23 now + 5::second => time later;
24 while(now < later)
25 {
26 f1(1); f2(1);
27 1::samp => now;
28 }
29
30 // if we got here then yay
31 <<< "success" >>>;