test(impl): add all possible cases
This commit is contained in:
parent
1203550399
commit
498072b5dc
10 changed files with 65 additions and 16 deletions
3
spec/fixtures/impl/closer_input.go
vendored
Normal file
3
spec/fixtures/impl/closer_input.go
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type CloserTest struct{}
|
||||||
8
spec/fixtures/impl/closer_output.go
vendored
Normal file
8
spec/fixtures/impl/closer_output.go
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type CloserTest2 struct{}
|
||||||
|
|
||||||
|
func (closertest *CloserTest2) Close() error {
|
||||||
|
panic("not implemented") // TODO: Implement
|
||||||
|
}
|
||||||
|
|
||||||
3
spec/fixtures/impl/impl_input.go
vendored
3
spec/fixtures/impl/impl_input.go
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
type Tester struct{}
|
|
||||||
8
spec/fixtures/impl/impl_output.go
vendored
8
spec/fixtures/impl/impl_output.go
vendored
|
|
@ -1,8 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
type Tester2 struct{}
|
|
||||||
|
|
||||||
func (w *Tester2) Write(p []byte) (n int, err error) {
|
|
||||||
panic("not implemented") // TODO: Implement
|
|
||||||
}
|
|
||||||
|
|
||||||
3
spec/fixtures/impl/reader_input.go
vendored
Normal file
3
spec/fixtures/impl/reader_input.go
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type Read struct{}
|
||||||
8
spec/fixtures/impl/reader_output.go
vendored
Normal file
8
spec/fixtures/impl/reader_output.go
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
func (r Read2) Read(p []byte) (n int, err error) {
|
||||||
|
panic("not implemented") // TODO: Implement
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type Read2 struct{}
|
||||||
3
spec/fixtures/impl/writer_input.go
vendored
Normal file
3
spec/fixtures/impl/writer_input.go
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type WriterTest struct{}
|
||||||
8
spec/fixtures/impl/writer_output.go
vendored
Normal file
8
spec/fixtures/impl/writer_output.go
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type WriterTest2 struct{}
|
||||||
|
|
||||||
|
func (w *WriterTest2) Write(p []byte) (n int, err error) {
|
||||||
|
panic("not implemented") // TODO: Implement
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -10,9 +10,9 @@ local T = MiniTest.new_set {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
T["impl"] = MiniTest.new_set {}
|
T["impl"] = MiniTest.new_set {}
|
||||||
T["impl"]["works"] = function()
|
T["impl"]["works w io.Writer"] = function()
|
||||||
local tmp = t.tmpfile()
|
local tmp = t.tmpfile()
|
||||||
local fixtures = t.fixtures.read "impl/impl"
|
local fixtures = t.fixtures.read "impl/writer"
|
||||||
t.fixtures.write(tmp, fixtures.input)
|
t.fixtures.write(tmp, fixtures.input)
|
||||||
|
|
||||||
child.cmd("silent edit " .. tmp)
|
child.cmd("silent edit " .. tmp)
|
||||||
|
|
@ -21,7 +21,34 @@ T["impl"]["works"] = function()
|
||||||
child.cmd "write"
|
child.cmd "write"
|
||||||
|
|
||||||
-- since "impl" won't implement interface if it's already implemented i went with this hack
|
-- since "impl" won't implement interface if it's already implemented i went with this hack
|
||||||
local rhs = fixtures.output:gsub("Tester2", "Tester")
|
local rhs = fixtures.output:gsub("Test2", "Test")
|
||||||
|
t.eq(t.readfile(tmp), rhs)
|
||||||
|
end
|
||||||
|
|
||||||
|
T["impl"]["works r Read io.Reader"] = function()
|
||||||
|
local tmp = t.tmpfile()
|
||||||
|
local fixtures = t.fixtures.read "impl/reader"
|
||||||
|
t.fixtures.write(tmp, fixtures.input)
|
||||||
|
|
||||||
|
child.cmd("silent edit " .. tmp)
|
||||||
|
child.cmd "GoImpl r Read io.Reader"
|
||||||
|
child.cmd "write"
|
||||||
|
|
||||||
|
local rhs = fixtures.output:gsub("Read2", "Read")
|
||||||
|
t.eq(t.readfile(tmp), rhs)
|
||||||
|
end
|
||||||
|
|
||||||
|
T["impl"]["works io.Closer"] = function()
|
||||||
|
local tmp = t.tmpfile()
|
||||||
|
local fixtures = t.fixtures.read "impl/closer"
|
||||||
|
t.fixtures.write(tmp, fixtures.input)
|
||||||
|
|
||||||
|
child.cmd("silent edit " .. tmp)
|
||||||
|
child.fn.setpos(".", { child.fn.bufnr "%", 3, 6, 0 })
|
||||||
|
child.cmd "GoImpl io.Closer"
|
||||||
|
child.cmd "write"
|
||||||
|
|
||||||
|
local rhs = fixtures.output:gsub("Test2", "Test")
|
||||||
t.eq(t.readfile(tmp), rhs)
|
t.eq(t.readfile(tmp), rhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ local T = MiniTest.new_set {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
T["struct_tags"] = MiniTest.new_set {}
|
T["struct_tags"] = MiniTest.new_set {}
|
||||||
T["struct_tags"]["add"] = function()
|
T["struct_tags"]["works add"] = function()
|
||||||
local tmp = t.tmpfile()
|
local tmp = t.tmpfile()
|
||||||
local fixtures = t.fixtures.read "tags/add"
|
local fixtures = t.fixtures.read "tags/add"
|
||||||
t.fixtures.write(tmp, fixtures.input)
|
t.fixtures.write(tmp, fixtures.input)
|
||||||
|
|
@ -22,7 +22,7 @@ T["struct_tags"]["add"] = function()
|
||||||
t.eq(t.readfile(tmp), fixtures.output)
|
t.eq(t.readfile(tmp), fixtures.output)
|
||||||
end
|
end
|
||||||
|
|
||||||
T["struct_tags"]["remove"] = function()
|
T["struct_tags"]["works remove"] = function()
|
||||||
local tmp = t.tmpfile()
|
local tmp = t.tmpfile()
|
||||||
local fixtures = t.fixtures.read "tags/remove"
|
local fixtures = t.fixtures.read "tags/remove"
|
||||||
t.fixtures.write(tmp, fixtures.input)
|
t.fixtures.write(tmp, fixtures.input)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue