v2 / vlib / v / tests / fns / anon_fn_with_option_test.v
30 lines · 26 sloc · 494 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1struct Response {}
2
3pub struct Route {
4 handler fn (mut App) Response
5 middlewares []fn (mut app App) ?Response
6}
7
8struct App {
9 routes []Route
10}
11
12pub fn check_auth(mut app App) ?Response {
13 return none
14}
15
16fn test_anon_fn_with_option() {
17 app := App{
18 routes: [
19 Route{
20 middlewares: [
21 check_auth,
22 ]
23 },
24 ]
25 }
26 println(app)
27 app_str := '${app}'
28 assert app_str.contains('handler: fn (mut App) Response')
29 assert app_str.contains('middlewares: [fn (mut App) ?Response]')
30}
31