| 1 | // vtest vflags: -cov .vtmp_cov_issue_24842 |
| 2 | module main |
| 3 | |
| 4 | import term.ui as tui |
| 5 | |
| 6 | enum ThemeSlot { |
| 7 | primary |
| 8 | } |
| 9 | |
| 10 | struct CoverageClosureCtx { |
| 11 | active_fg_color tui.Color |
| 12 | on_draw_cb fn (int, int, string, tui.Color, ?tui.Color) |
| 13 | on_draw_rect_cb fn (int, int, int, int) |
| 14 | } |
| 15 | |
| 16 | fn test_cov_struct_init_with_closures_and_index_or() { |
| 17 | palette := map[ThemeSlot]tui.Color{} |
| 18 | key := ThemeSlot.primary |
| 19 | mut drawn := []int{} |
| 20 | mut drawn_ref := &drawn |
| 21 | _ = CoverageClosureCtx{ |
| 22 | active_fg_color: palette[key] or { |
| 23 | tui.Color{ |
| 24 | r: 1 |
| 25 | g: 2 |
| 26 | b: 3 |
| 27 | } |
| 28 | } |
| 29 | on_draw_cb: fn [mut drawn_ref] (x int, y int, text string, fg tui.Color, bg ?tui.Color) { |
| 30 | drawn_ref << x + y + text.len + fg.r |
| 31 | _ = bg |
| 32 | } |
| 33 | on_draw_rect_cb: fn [mut drawn_ref] (x int, y int, width int, height int) { |
| 34 | drawn_ref << x + y + width + height |
| 35 | } |
| 36 | } |
| 37 | assert true |
| 38 | } |
| 39 | |