v2 / vlib / v / tests / generics / generics_interface_decl_test.v
37 lines · 28 sloc · 594 bytes · 0daf39837b49e2b8618136fda79f290ffc3a1605
Raw
1interface Depends {
2 depends() []Depends
3}
4
5struct Signal[T] {
6}
7
8fn (x Signal[T]) depends() []Depends {
9 return []
10}
11
12struct Add[T] {
13 a Signal[T]
14 b Signal[T]
15}
16
17fn (a Add[T]) depends() []Depends {
18 return [a.a, a.b]
19}
20
21fn test_generics_interface_decl() {
22 assert true
23}
24
25type Action[A, B] = fn (v1 A, v2 B)
26
27interface PropWithListener[T] {
28 listen_state(action Action[T, bool])
29}
30
31fn noop_string_state_action(_ string, _ bool) {}
32
33fn test_generics_interface_decl_with_fn_type_concrete_param() {
34 action := Action[string, bool](noop_string_state_action)
35 action('ready', true)
36 assert true
37}
38