| 1 | interface IObject { |
| 2 | foo() |
| 3 | } |
| 4 | |
| 5 | struct Foo {} |
| 6 | |
| 7 | fn (f Foo) foo() { |
| 8 | } |
| 9 | |
| 10 | struct Array { |
| 11 | mut: |
| 12 | array []IObject |
| 13 | } |
| 14 | |
| 15 | fn (a Array) contains(x IObject) bool { |
| 16 | for element in a.array { |
| 17 | if element == x { |
| 18 | return true |
| 19 | } |
| 20 | } |
| 21 | return false |
| 22 | } |
| 23 | |
| 24 | fn test_array_of_interfaces_equality() { |
| 25 | foo := Foo{} |
| 26 | mut ary := Array{} |
| 27 | ary.array << foo |
| 28 | ret := ary.contains(foo) |
| 29 | println(ret) |
| 30 | assert ret |
| 31 | } |
| 32 |