v/compiler/tests/interface_test.v

33 lines
350 B
V
Raw Normal View History

struct Dog {
2019-09-04 17:49:46 +02:00
breed string
}
fn (d Dog) speak() {
println('dog.speak()')
}
fn (d Dog) name() string {
return 'old gray'
}
interface Speaker {
name() string
2019-08-31 15:38:13 +02:00
speak()
}
interface Speak2er {
2019-08-31 15:38:13 +02:00
speak()
name() string
}
fn perform_speak(s Speaker) bool {
s.speak()
return true
}
fn test_perform_speak() {
d := Dog{}
assert perform_speak(d)
}