| 1 | interface IExample { |
| 2 | thing() bool |
| 3 | } |
| 4 | |
| 5 | struct Foo {} |
| 6 | |
| 7 | fn (n Foo) thing() bool { |
| 8 | return true |
| 9 | } |
| 10 | |
| 11 | struct Test { |
| 12 | a IExample |
| 13 | } |
| 14 | |
| 15 | fn new() Test { |
| 16 | return Test{Foo{}} |
| 17 | } |
| 18 | |
| 19 | fn test_struct_auto_eq_gen_interface_case() { |
| 20 | w1 := new() |
| 21 | w2 := new() |
| 22 | assert w1 == w2 |
| 23 | } |
| 24 | |
| 25 | // For https://github.com/vlang/v/issues/16074 |
| 26 | pub interface Logger { |
| 27 | mut: |
| 28 | info(s string) |
| 29 | } |
| 30 | |
| 31 | struct LogContainer { |
| 32 | name string |
| 33 | mut: |
| 34 | logger &Logger = unsafe { nil } |
| 35 | } |
| 36 | |
| 37 | fn test_comparing_struct_with_pointers_to_interface_values_autogenerates_working_eq_method() { |
| 38 | assert LogContainer{ |
| 39 | name: 'abc' |
| 40 | } == LogContainer{ |
| 41 | name: 'abc' |
| 42 | } |
| 43 | } |
| 44 | |