[mirror] Make your go dev experience better github.com/olexsmir/gopher.nvim
neovim golang
at main 1.7 kB view raw
1local t = require "spec.testutils" 2local child, T, comment = t.setup "comment" 3 4local function do_the_test(fixture, pos) 5 local rs = t.setup_test("comment/" .. fixture, child, pos) 6 child.cmd "GoCmt" 7 child.cmd "write" 8 9 t.eq(t.readfile(rs.tmp), rs.fixtures.output) 10 t.cleanup(rs) 11end 12 13comment["should add comment to package"] = function() 14 do_the_test("package", { 1, 1 }) 15end 16 17comment["should add comment to struct"] = function() 18 do_the_test("struct", { 4, 1 }) 19end 20 21comment["should add a comment on struct field"] = function() 22 do_the_test("struct_fields", { 5, 8 }) 23end 24 25comment["should add a comment on var struct field"] = function() 26 do_the_test("var_struct_fields", { 6, 4 }) 27end 28 29comment["should add a comment on one field of many structs"] = function() 30 do_the_test("many_structs_fields", { 10, 4 }) 31end 32 33comment["should add comment to function"] = function() 34 do_the_test("func", { 3, 1 }) 35end 36 37comment["should add comment to method"] = function() 38 do_the_test("method", { 5, 1 }) 39end 40 41comment["should add comment to interface"] = function() 42 do_the_test("interface", { 3, 6 }) 43end 44 45comment["should add comment on interface method"] = function() 46 do_the_test("interface_method", { 4, 2 }) 47end 48 49comment["should add a comment on interface with many method"] = function() 50 do_the_test("interface_many_method", { 5, 2 }) 51end 52 53comment["should add a comment on a var"] = function() 54 do_the_test("var", { 4, 2 }) 55end 56 57comment["should add a comment on a short declared var"] = function() 58 do_the_test("svar", { 4, 8 }) 59end 60 61comment["otherwise should add // above cursor"] = function() 62 do_the_test("empty", { 1, 1 }) 63end 64 65return T