1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/compiler/tests/interface_test.v
2019-09-01 14:05:03 +03:00

32 lines
336 B
V

struct Dog {
}
fn (d Dog) speak() {
println('dog.speak()')
}
fn (d Dog) name() string {
return 'old gray'
}
interface Speaker {
name() string
speak()
}
interface Speak2er {
speak()
name() string
}
fn perform_speak(s Speaker) bool {
s.speak()
return true
}
fn test_perform_speak() {
d := Dog{}
assert perform_speak(d)
}