From 6c88a9537ae829cd8a4b92312e115c311e6beb42 Mon Sep 17 00:00:00 2001 From: ThePrimeAgain Date: Wed, 14 Jan 2026 18:32:30 -0700 Subject: fuzzy_find: for agents stuff --- lua/99/test/fill_in_function.cpp_spec.lua | 220 +++++++++++++++--------------- 1 file changed, 110 insertions(+), 110 deletions(-) (limited to 'lua/99/test/fill_in_function.cpp_spec.lua') diff --git a/lua/99/test/fill_in_function.cpp_spec.lua b/lua/99/test/fill_in_function.cpp_spec.lua index 9edf550..3cb67b5 100644 --- a/lua/99/test/fill_in_function.cpp_spec.lua +++ b/lua/99/test/fill_in_function.cpp_spec.lua @@ -12,122 +12,122 @@ local eq = assert.are.same --- @param lang string? --- @return _99.test.Provider, number local function setup(content, row, col, lang) - assert(lang, "lang must be provided") - local provider = test_utils.TestProvider.new() - _99.setup({ - provider = provider, - logger = { - error_cache_level = Levels.ERROR, - type = "print", - }, - }) - - local buffer = test_utils.create_file(content, lang, row, col) - return provider, buffer + assert(lang, "lang must be provided") + local provider = test_utils.TestProvider.new() + _99.setup({ + provider = provider, + logger = { + error_cache_level = Levels.ERROR, + type = "print", + }, + }) + + local buffer = test_utils.create_file(content, lang, row, col) + return provider, buffer end --- @param buffer number --- @return string[] local function read(buffer) - return vim.api.nvim_buf_get_lines(buffer, 0, -1, false) + return vim.api.nvim_buf_get_lines(buffer, 0, -1, false) end describe("fill_in_function", function() - it("fill in cpp function", function() - local cpp_content = { - "", - "uint32_t test() { }", - } - local provider, buffer = setup(cpp_content, 2, 5, "cpp") - local state = _99.__get_state() - - _99.fill_in_function() - - eq(1, state:active_request_count()) - eq(cpp_content, read(buffer)) - - provider:resolve("success", "uint32_t test() {\n return 42;\n}") - test_utils.next_frame() - - local expected_state = { - "", - "uint32_t test() {", - " return 42;", - "}", - } - eq(expected_state, read(buffer)) - eq(0, state:active_request_count()) - end) - - it("fill in cpp concept with requires clause", function() - local cpp_content = { - "", - "template ", - "concept Callback = requires(T cb) {", - " // Invocation must return an int", - "};", - } - - local provider, buffer = setup(cpp_content, 3, 10, "cpp") - local state = _99.__get_state() - - _99.fill_in_function() - - eq(1, state:active_request_count()) - eq(cpp_content, read(buffer)) - - provider:resolve( - "success", - "concept Callback = requires(T cb) {\n { cb() } -> std::same_as;\n};" - ) - test_utils.next_frame() - - local expected_state = { - "", - "template ", - "concept Callback = requires(T cb) {", - " { cb() } -> std::same_as;", - "};", - } - eq(expected_state, read(buffer)) - eq(0, state:active_request_count()) - end) - - it("fill in nested lambda inside a function", function() - local cpp_content = { - "", - "auto test() -> void", - "{", - " const auto say_42 = []() -> int {", - " // TODO: return 42", - " };", - "}", - } - - local provider, buffer = setup(cpp_content, 4, 20, "cpp") - local state = _99.__get_state() - - _99.fill_in_function() - - eq(1, state:active_request_count()) - eq(cpp_content, read(buffer)) - - provider:resolve( - "success", - "const auto say_42 = []() -> int {\n return 42;\n };" - ) - test_utils.next_frame() - - local expected_state = { - "", - "auto test() -> void", - "{", - " const auto say_42 = []() -> int {", - " return 42;", - " };", - "}", - } - eq(expected_state, read(buffer)) - eq(0, state:active_request_count()) - end) + it("fill in cpp function", function() + local cpp_content = { + "", + "uint32_t test() { }", + } + local provider, buffer = setup(cpp_content, 2, 5, "cpp") + local state = _99.__get_state() + + _99.fill_in_function() + + eq(1, state:active_request_count()) + eq(cpp_content, read(buffer)) + + provider:resolve("success", "uint32_t test() {\n return 42;\n}") + test_utils.next_frame() + + local expected_state = { + "", + "uint32_t test() {", + " return 42;", + "}", + } + eq(expected_state, read(buffer)) + eq(0, state:active_request_count()) + end) + + it("fill in cpp concept with requires clause", function() + local cpp_content = { + "", + "template ", + "concept Callback = requires(T cb) {", + " // Invocation must return an int", + "};", + } + + local provider, buffer = setup(cpp_content, 3, 10, "cpp") + local state = _99.__get_state() + + _99.fill_in_function() + + eq(1, state:active_request_count()) + eq(cpp_content, read(buffer)) + + provider:resolve( + "success", + "concept Callback = requires(T cb) {\n { cb() } -> std::same_as;\n};" + ) + test_utils.next_frame() + + local expected_state = { + "", + "template ", + "concept Callback = requires(T cb) {", + " { cb() } -> std::same_as;", + "};", + } + eq(expected_state, read(buffer)) + eq(0, state:active_request_count()) + end) + + it("fill in nested lambda inside a function", function() + local cpp_content = { + "", + "auto test() -> void", + "{", + " const auto say_42 = []() -> int {", + " // TODO: return 42", + " };", + "}", + } + + local provider, buffer = setup(cpp_content, 4, 20, "cpp") + local state = _99.__get_state() + + _99.fill_in_function() + + eq(1, state:active_request_count()) + eq(cpp_content, read(buffer)) + + provider:resolve( + "success", + "const auto say_42 = []() -> int {\n return 42;\n };" + ) + test_utils.next_frame() + + local expected_state = { + "", + "auto test() -> void", + "{", + " const auto say_42 = []() -> int {", + " return 42;", + " };", + "}", + } + eq(expected_state, read(buffer)) + eq(0, state:active_request_count()) + end) end) -- cgit v1.3-3-g829e