diff --git a/spec/fixtures/impl/closer_input.go b/spec/fixtures/impl/closer_input.go new file mode 100644 index 0000000..e4d5f52 --- /dev/null +++ b/spec/fixtures/impl/closer_input.go @@ -0,0 +1,3 @@ +package main + +type CloserTest struct{} diff --git a/spec/fixtures/impl/closer_output.go b/spec/fixtures/impl/closer_output.go new file mode 100644 index 0000000..5e976f3 --- /dev/null +++ b/spec/fixtures/impl/closer_output.go @@ -0,0 +1,8 @@ +package main + +type CloserTest2 struct{} + +func (closertest *CloserTest2) Close() error { + panic("not implemented") // TODO: Implement +} + diff --git a/spec/fixtures/impl/impl_input.go b/spec/fixtures/impl/impl_input.go deleted file mode 100644 index 0310f84..0000000 --- a/spec/fixtures/impl/impl_input.go +++ /dev/null @@ -1,3 +0,0 @@ -package main - -type Tester struct{} diff --git a/spec/fixtures/impl/impl_output.go b/spec/fixtures/impl/impl_output.go deleted file mode 100644 index 26673a5..0000000 --- a/spec/fixtures/impl/impl_output.go +++ /dev/null @@ -1,8 +0,0 @@ -package main - -type Tester2 struct{} - -func (w *Tester2) Write(p []byte) (n int, err error) { - panic("not implemented") // TODO: Implement -} - diff --git a/spec/fixtures/impl/reader_input.go b/spec/fixtures/impl/reader_input.go new file mode 100644 index 0000000..ebc8eff --- /dev/null +++ b/spec/fixtures/impl/reader_input.go @@ -0,0 +1,3 @@ +package main + +type Read struct{} diff --git a/spec/fixtures/impl/reader_output.go b/spec/fixtures/impl/reader_output.go new file mode 100644 index 0000000..26df873 --- /dev/null +++ b/spec/fixtures/impl/reader_output.go @@ -0,0 +1,8 @@ +package main + +func (r Read2) Read(p []byte) (n int, err error) { + panic("not implemented") // TODO: Implement +} + + +type Read2 struct{} diff --git a/spec/fixtures/impl/writer_input.go b/spec/fixtures/impl/writer_input.go new file mode 100644 index 0000000..ef034cc --- /dev/null +++ b/spec/fixtures/impl/writer_input.go @@ -0,0 +1,3 @@ +package main + +type WriterTest struct{} diff --git a/spec/fixtures/impl/writer_output.go b/spec/fixtures/impl/writer_output.go new file mode 100644 index 0000000..19e8f6e --- /dev/null +++ b/spec/fixtures/impl/writer_output.go @@ -0,0 +1,8 @@ +package main + +type WriterTest2 struct{} + +func (w *WriterTest2) Write(p []byte) (n int, err error) { + panic("not implemented") // TODO: Implement +} + diff --git a/spec/integration/impl_test.lua b/spec/integration/impl_test.lua index cf6620c..9ff57d8 100644 --- a/spec/integration/impl_test.lua +++ b/spec/integration/impl_test.lua @@ -10,9 +10,9 @@ local T = MiniTest.new_set { }, } T["impl"] = MiniTest.new_set {} -T["impl"]["works"] = function() +T["impl"]["works w io.Writer"] = function() local tmp = t.tmpfile() - local fixtures = t.fixtures.read "impl/impl" + local fixtures = t.fixtures.read "impl/writer" t.fixtures.write(tmp, fixtures.input) child.cmd("silent edit " .. tmp) @@ -21,7 +21,34 @@ T["impl"]["works"] = function() 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") + 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) end diff --git a/spec/integration/struct_tags_test.lua b/spec/integration/struct_tags_test.lua index b0b1344..0d22a00 100644 --- a/spec/integration/struct_tags_test.lua +++ b/spec/integration/struct_tags_test.lua @@ -10,7 +10,7 @@ local T = 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 fixtures = t.fixtures.read "tags/add" t.fixtures.write(tmp, fixtures.input) @@ -22,7 +22,7 @@ T["struct_tags"]["add"] = function() t.eq(t.readfile(tmp), fixtures.output) end -T["struct_tags"]["remove"] = function() +T["struct_tags"]["works remove"] = function() local tmp = t.tmpfile() local fixtures = t.fixtures.read "tags/remove" t.fixtures.write(tmp, fixtures.input)