2024-09-12 09:06:12 +00:00
fun repeat ( n f ) {
2024-01-02 15:45:34 +00:00
while ( > n 0 ) {
f ;
set n ( - n 1 ) ;
};
};
2022-03-06 00:39:13 +00:00
2024-09-12 09:06:12 +00:00
fun test - non - local - ret - 1 ( k ) {
2024-01-02 15:45:34 +00:00
repeat 10 ( fun ( ) {
set k ( + k 2 ) ;
2024-08-22 09:10:41 +00:00
if ( = k 28 ) { revert k };
2024-01-02 15:45:34 +00:00
}) ;
2022-03-06 00:39:13 +00:00
2024-01-02 15:45:34 +00:00
return k ;
};
2022-03-06 00:39:13 +00:00
2024-01-02 15:45:34 +00:00
set a ( test - non - local - ret - 1 20 ) ;
2024-09-03 03:18:08 +00:00
if (~ = a 28 ) { printf "ERROR: a must be 28\n" } \
2024-01-14 15:47:01 +00:00
else { printf "OK %d\n" a };
2022-03-06 00:39:13 +00:00
2024-01-02 15:45:34 +00:00
set a ( test - non - local - ret - 1 21 ) ;
2024-09-03 03:18:08 +00:00
if (~ = a 41 ) { printf "ERROR: a must be 41\n" } \
2024-01-02 15:45:34 +00:00
else { printf "OK %d\n" a };
2022-03-06 00:39:13 +00:00
2024-09-12 09:06:12 +00:00
fun dd ( ) { return ( - 99999999999999991111111111111111111111111111111111111111 . 111111111 999999999999999999999999999999 . 999999999999 ) }
2022-02-19 17:26:26 +00:00
2024-09-12 09:06:12 +00:00
fun ee ( ) { return ( + 1111111111111111111111111111111111111111111111111 999999999999999999999999999999999999999999 ) }
fun ff ( ) { return 999 };
## test a normal block return with a fixed point decimal
set a ( dd ) ;
if (~ = a 99999999999999991111111110111111111111111111111111111111 . 111111111001 ) { printf "ERROR: a must be 99999999999999991111111110111111111111111111111111111111.111111111001\n" } \
else { printf "OK %f\n" a };
## test a normal block return with a large integer
set a ( ee ) ;
if (~ = a 1111112111111111111111111111111111111111111111110 ) { printf "ERROR: a must be 1111112111111111111111111111111111111111111111110\n" } \
else { printf "OK %d\n" a };
2022-02-19 17:26:26 +00:00
2023-11-11 08:57:18 +00:00
## test a normal block return
2024-01-02 15:45:34 +00:00
set a ( ff ) ;
2024-09-03 03:18:08 +00:00
if (~ = a 999 ) { printf "ERROR: a must be 999\n" } \
2024-01-02 15:45:34 +00:00
else { printf "OK %d\n" a };
2022-02-19 17:26:26 +00:00
2023-11-11 08:57:18 +00:00
## return from top-level
2024-01-02 15:45:34 +00:00
return 10 ;
printf "ERROR: this line must not be printed\n" ;