| 1 | type HandlerFn = fn () |
| 2 | |
| 3 | fn new_static_router(route_not_found_handler ?fn ()) fn () { |
| 4 | return route_not_found_handler or { |
| 5 | fn () {} |
| 6 | } |
| 7 | } |
| 8 | |
| 9 | fn new_static_router2(route_not_found_handler ?HandlerFn) fn () { |
| 10 | return route_not_found_handler or { |
| 11 | fn () {} |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | fn test_option_fn_alias_decl_with_none() { |
| 16 | b := new_static_router2(none) |
| 17 | $if b is $function { |
| 18 | assert true |
| 19 | } $else { |
| 20 | assert false |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | fn test_option_fn_decl_with_none() { |
| 25 | a := new_static_router(none) |
| 26 | $if a is $function { |
| 27 | assert true |
| 28 | } $else { |
| 29 | assert false |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | fn test_option_fn_passing_normal() { |
| 34 | anon_1 := fn () { |
| 35 | println(1) |
| 36 | } |
| 37 | c := new_static_router(anon_1) |
| 38 | assert c == anon_1 |
| 39 | } |
| 40 | |
| 41 | fn test_option_fn_passing_to_alias() { |
| 42 | anon_2 := fn () { |
| 43 | println(2) |
| 44 | } |
| 45 | d := new_static_router(anon_2) |
| 46 | assert d == anon_2 |
| 47 | } |
| 48 | |