v2 / vlib / v / tests / builtin_arrays / array_of_interfaces_equality_test.v
31 lines · 26 sloc · 379 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1interface IObject {
2 foo()
3}
4
5struct Foo {}
6
7fn (f Foo) foo() {
8}
9
10struct Array {
11mut:
12 array []IObject
13}
14
15fn (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
24fn 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