test(impl): add test

This commit is contained in:
Oleksandr Smirnov 2025-02-17 20:16:56 +02:00
parent 7a8fd2e273
commit 1203550399
No known key found for this signature in database
3 changed files with 25 additions and 0 deletions

3
spec/fixtures/impl/impl_input.go vendored Normal file
View file

@ -0,0 +1,3 @@
package main
type Tester struct{}

8
spec/fixtures/impl/impl_output.go vendored Normal file
View file

@ -0,0 +1,8 @@
package main
type Tester2 struct{}
func (w *Tester2) Write(p []byte) (n int, err error) {
panic("not implemented") // TODO: Implement
}

View file

@ -10,5 +10,19 @@ local T = MiniTest.new_set {
}, },
} }
T["impl"] = MiniTest.new_set {} T["impl"] = MiniTest.new_set {}
T["impl"]["works"] = function()
local tmp = t.tmpfile()
local fixtures = t.fixtures.read "impl/impl"
t.fixtures.write(tmp, fixtures.input)
child.cmd("silent edit " .. tmp)
child.fn.setpos(".", { child.fn.bufnr "%", 3, 6, 0 })
child.cmd "GoImpl w io.Writer"
child.cmd "write"
-- since "impl" won't implement interface if it's already implemented i went with this hack
local rhs = fixtures.output:gsub("Tester2", "Tester")
t.eq(t.readfile(tmp), rhs)
end
return T return T