summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThePrimeAgain <theprimeagain@theprimeagain.com>2025-12-04 06:29:58 -0700
committerThePrimeAgain <theprimeagain@theprimeagain.com>2025-12-04 06:29:58 -0700
commit9b01699960cb6efbdd81762bd630e8451c2c2ed5 (patch)
treedaebc3bf8099bc68ea97c0c2e586a855deaa3fc3
parent51b69a298234ac527cee052906efc1d88acc1f8c (diff)
downloada4-9b01699960cb6efbdd81762bd630e8451c2c2ed5.tar.xz
a4-9b01699960cb6efbdd81762bd630e8451c2c2ed5.zip
test harness almost in place
-rw-r--r--lua/99/geo.lua7
-rw-r--r--lua/99/test/integration_spec.lua (renamed from lua/99/test/integration.spec.lua)17
-rw-r--r--lua/99/test/test_content.lua14
-rw-r--r--lua/99/test/test_utils.lua6
-rw-r--r--scratch/refresh.lua27
-rw-r--r--scripts/tests/minimal.vim5
6 files changed, 53 insertions, 23 deletions
diff --git a/lua/99/geo.lua b/lua/99/geo.lua
index 8a95505..d5a804c 100644
--- a/lua/99/geo.lua
+++ b/lua/99/geo.lua
@@ -72,6 +72,13 @@ function Point:from_cursor()
return point
end
+--- @param ns_id string
+---@param buffer number
+---@param mark_id string
+function Point:from_extmark(ns_id, buffer, mark_id)
+ local row, col = vim.api.nvim_buf_get_extmark_by_id(buffer, ns_id, mark_id)
+end
+
--- @param row number
---@param col number
--- @return Point
diff --git a/lua/99/test/integration.spec.lua b/lua/99/test/integration_spec.lua
index a47dc3b..0a9a6bb 100644
--- a/lua/99/test/integration.spec.lua
+++ b/lua/99/test/integration_spec.lua
@@ -1,8 +1,8 @@
-- luacheck: globals describe it assert
local _99 = require("99")
local test_utils = require("99.test.test_utils")
-local M = {}
local eq = assert.are.same
+local test_content = require("99.test.test_content")
--- @param content string[]
--- @return _99.Provider, number
@@ -24,7 +24,7 @@ end
describe("fill_in_function", function()
it("should fill in function that multiple lines", function()
- local p, buffer = setup(M.empty_function_2_lines)
+ local p, buffer = setup(test_content.empty_function_2_lines)
_99.fill_in_function()
local expected_state = {
@@ -39,16 +39,3 @@ describe("fill_in_function", function()
eq(expected_state, r(buffer))
end)
end)
-
-M.empty_function_2_lines = {
- "",
- "function foo()",
- "end",
- "",
-}
-
-M.empty_function_single_line = {
- "",
- "function foo() end",
- "",
-}
diff --git a/lua/99/test/test_content.lua b/lua/99/test/test_content.lua
new file mode 100644
index 0000000..5980b8e
--- /dev/null
+++ b/lua/99/test/test_content.lua
@@ -0,0 +1,14 @@
+local M = {}
+M.empty_function_2_lines = {
+ "",
+ "function foo()",
+ "end",
+ "",
+}
+
+M.empty_function_single_line = {
+ "",
+ "function foo() end",
+ "",
+}
+return M
diff --git a/lua/99/test/test_utils.lua b/lua/99/test/test_utils.lua
index 5e19bec..1240c63 100644
--- a/lua/99/test/test_utils.lua
+++ b/lua/99/test/test_utils.lua
@@ -7,13 +7,13 @@ M.created_files = {}
--- @field context _99.Context
--- @field observer _99.ProviderObserver?
---- @class _99.test.Provider
+--- @class _99.test.Provider : _99.Provider
--- @field request _99.test.ProviderRequest?
local TestProvider = {}
TestProvider.__index = TestProvider
function TestProvider.new()
- return setmetatable({})
+ return setmetatable({}, TestProvider)
end
--- @param query string
@@ -70,12 +70,14 @@ end
---@param row number?
---@param col number?
function M.create_file(contents, file_type, row, col)
+ assert(type(contents) == "table", "contents must be a table of strings")
file_type = file_type or "lua"
local bufnr = vim.api.nvim_create_buf(false, false)
vim.api.nvim_set_current_buf(bufnr)
vim.bo[bufnr].ft = file_type
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, contents)
+ print("row", row or 1, "col", col or 0)
vim.api.nvim_win_set_cursor(0, { row or 1, col or 0 })
table.insert(M.created_files, bufnr)
diff --git a/scratch/refresh.lua b/scratch/refresh.lua
index c90f76f..5347b0f 100644
--- a/scratch/refresh.lua
+++ b/scratch/refresh.lua
@@ -1,8 +1,23 @@
-local function pick_a_number_that_is_42()
- return 42
-end
+R("99")
+
+function foo() end
-function return_42()
- local number = pick_a_number_that_is_42()
- return number
+local ns_id = vim.api.nvim_create_namespace("turd-ferg")
+local function add_virtual_text()
+ vim.api.nvim_buf_clear_namespace(0, ns_id, 0, -1)
+ vim.api.nvim_buf_set_extmark(0, ns_id, 2, 0, {
+ virt_lines = {
+ {
+ { "foo bar 1", "Comment" },
+ },
+ {
+ { "foo bar 2", "error" },
+ },
+ {
+ { "foo bar 4", "Comment" },
+ },
+ },
+ })
end
+
+add_virtual_text()
diff --git a/scripts/tests/minimal.vim b/scripts/tests/minimal.vim
new file mode 100644
index 0000000..f8c036d
--- /dev/null
+++ b/scripts/tests/minimal.vim
@@ -0,0 +1,5 @@
+set noswapfile
+set rtp+=.
+set rtp+=../plenary.nvim
+runtime! plugin/plenary.vim
+