v2 / vlib / v / tests / fns / anon_fn_redefinition_test.v
24 lines · 20 sloc · 407 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1const default_logger = Example{}
2
3struct Example {
4 structs []Another = [Another{}]
5}
6
7pub struct Another {
8 function fn (string) = fn (value string) {
9 println('${value}')
10 }
11}
12
13pub fn (e Example) useless() string {
14 return 'ok'
15}
16
17fn test_anon_fn_redefinition() {
18 e1 := Example{}
19 assert e1.useless() == 'ok'
20 e2 := Example{}
21 assert e2.useless() == 'ok'
22 e3 := Example{}
23 assert e3.useless() == 'ok'
24}
25