more tests fixplurals

pull/130/head
ray-x 2 years ago
parent bc1a1ea33b
commit 362ff2fd37

@ -4,7 +4,7 @@ local ts_utils = require("nvim-treesitter.ts_utils")
local info = require("go.utils").info
local get_node_text = vim.treesitter.query.get_node_text
function fixplurals()
local function fixplurals()
local n = ts_utils.get_node_at_cursor()
local p = n:parent()
if p:type() ~= "parameter_declaration" then

@ -33,6 +33,7 @@ function M.run(args)
end,
}
runner.run(cmd, opts)
return cmd, opts
end
return M

@ -1,5 +0,0 @@
-- guru implements main.go:#70
-- io.go:91:6: implements io.Closer
-- io.go:117:6: implements io.ReadCloser
-- TODO callstack, implements peers pointsto
-- my system freeze whenever I use gruru, it is a bummer

@ -0,0 +1,2 @@
package fixplurals
func func(a, b int){}

@ -0,0 +1,2 @@
package fixplurals
func func(a int, b int){}

@ -0,0 +1,3 @@
module github.com/go.nvim
go 1.18

@ -0,0 +1,43 @@
local _ = require("plenary/busted")
local eq = assert.are.same
local cur_dir = vim.fn.expand("%:p:h")
-- local status = require("plenary.reload").reload_module("go.nvim")
-- status = require("plenary.reload").reload_module("nvim-treesitter")
-- local ulog = require('go.utils').log
describe("should run fixplurals", function()
-- vim.fn.readfile('minimal.vim')
-- vim.fn.writefile(vim.fn.readfile('fixtures/fmt/hello.go'), name)
-- status = require("plenary.reload").reload_module("go.nvim")
it("should run fixplurals", function()
--
local name = vim.fn.tempname() .. ".go"
local path = cur_dir .. "/lua/tests/fixtures/fixplurals/fixp_input.go" -- %:p:h ? %:p
local lines = vim.fn.readfile(path)
vim.fn.writefile(lines, name)
local expected = vim.fn.join(vim.fn.readfile(cur_dir
.. "/lua/tests/fixtures/fixplurals/fixp_golden.go"),
"\n")
local cmd = " silent exe 'e " .. name .. "'"
vim.cmd(cmd)
local bufn = vim.fn.bufnr("")
vim.fn.setpos(".", {bufn, 2, 11, 0})
-- local l = vim.api.nvim_buf_get_lines(0, 0, -1, true)
vim.bo.filetype = "go"
local gofixp = require("go.fixplurals")
gofixp.fixplurals()
vim.wait(100, function()
vim.cmd('w')
end)
local fmt = vim.fn.join(vim.fn.readfile(name), "\n")
vim.fn.assert_equal(fmt, expected)
eq(expected, fmt)
cmd = "bd! " .. name
vim.cmd(cmd)
end)
end)
Loading…
Cancel
Save