1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/v/tests/methods_on_interfaces_test.v

21 lines
315 B
V

struct Cat {
breed string
}
interface Animal {
breed string
}
fn (a Animal) info() string {
return "I'm a ${a.breed} ${typeof(a).name}"
}
fn new_animal(breed string) Animal {
return &Cat{breed}
}
fn test_methods_on_interfaces() {
mut a := new_animal('persian')
assert a.info() == "I'm a persian Animal"
}