From ead1771ca7098503c5c73d36fcd93c6f26f36441 Mon Sep 17 00:00:00 2001 From: Steve Vermeulen Date: Sun, 27 Mar 2022 16:12:51 -0700 Subject: [PATCH 1/9] Updated vim.d.tl to have more content --- types/neovim/template | 51 +++++++++++++++++++++++++++++++- types/neovim/vim.d.tl | 67 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 103 insertions(+), 15 deletions(-) diff --git a/types/neovim/template b/types/neovim/template index 6bd3c52..f2dd7ac 100644 --- a/types/neovim/template +++ b/types/neovim/template @@ -11,9 +11,17 @@ global record vim -- mode: function(): Mode -- ... -- end + + -- TODO: + -- vim.opt + -- vim.opt_global + -- vim.opt_local + -- vim.treesitter + fn: {string:function(...: any): (any)} cmd: function(cmd: string) call: function(func: string, ...: any) + call: function(string, ...: any): any enum Mode "n" -- Normal @@ -65,6 +73,7 @@ global record vim end end notify: function(msg: string, log_level: integer, opts: table) + notify_once: function(msg:string, level:integer, opt:table) paste: function({string}, integer): boolean schedule_wrap: function(function): function deep_equal: function(any, any): boolean @@ -139,6 +148,46 @@ global record vim end regex: function(string): Regex + diff: function(a:string, b:string):string + -- TODO + -- diff: function(a:string, b:string, options:DiffOptions):string | {integer} + + record VersionInfo + api_compatible:integer + api_level:integer + api_prerelease:integer + major:integer + minor:integer + patch:integer + end + + version:function():VersionInfo + + uri_from_bufnr:function(bufnr:integer):string + uri_from_fname:function(path:string):string + uri_to_bufnr:function(uri:string):integer + uri_to_fname:function(uri:string):string + + pretty_print:function(obj:any):string + + region:function(bufnr:integer, pos1:{integer}, pos2:{integer}, regtype:string, inclusive:boolean):{integer:{integer}} + + record filetype + -- TODO - replace table with options record + add: function(filetypes:table) + + match: function(name:string, bufnr:integer) + end + + record mpack + encode: function(obj:any):string + decode: function(str:string):any + end + + record spell + check: function(str:string):{{string | integer}} + end + -- TODO: these are a pitiful approximation of luv's types -- once Teal has some form of type inheritance/composition and luv.d.tl is written -- just steal from that @@ -216,7 +265,6 @@ global record vim fs_mkdir: function(string, integer, function(string, boolean)): boolean | Dir, string, string end - call: function(string, ...: any): any in_fast_event: function(): boolean type NIL = record userdata end -- special nil for filling tables @@ -413,6 +461,7 @@ global record vim end g: {string:any} + go: {string:any} t: {string:any} v: {string:any} env: {string:any} diff --git a/types/neovim/vim.d.tl b/types/neovim/vim.d.tl index 8e0b873..0bbc202 100644 --- a/types/neovim/vim.d.tl +++ b/types/neovim/vim.d.tl @@ -11,9 +11,17 @@ global record vim -- mode: function(): Mode -- ... -- end + + -- TODO: + -- vim.opt + -- vim.opt_global + -- vim.opt_local + -- vim.treesitter + fn: {string:function(...: any): (any)} cmd: function(cmd: string) call: function(func: string, ...: any) + call: function(string, ...: any): any enum Mode "n" -- Normal @@ -65,6 +73,7 @@ global record vim end end notify: function(msg: string, log_level: integer, opts: table) + notify_once: function(msg:string, level:integer, opt:table) paste: function({string}, integer): boolean schedule_wrap: function(function): function deep_equal: function(any, any): boolean @@ -139,6 +148,46 @@ global record vim end regex: function(string): Regex + diff: function(a:string, b:string):string + -- TODO + -- diff: function(a:string, b:string, options:DiffOptions):string | {integer} + + record VersionInfo + api_compatible:integer + api_level:integer + api_prerelease:integer + major:integer + minor:integer + patch:integer + end + + version:function():VersionInfo + + uri_from_bufnr:function(bufnr:integer):string + uri_from_fname:function(path:string):string + uri_to_bufnr:function(uri:string):integer + uri_to_fname:function(uri:string):string + + pretty_print:function(obj:any):string + + region:function(bufnr:integer, pos1:{integer}, pos2:{integer}, regtype:string, inclusive:boolean):{integer:{integer}} + + record filetype + -- TODO - replace table with options record + add: function(filetypes:table) + + match: function(name:string, bufnr:integer) + end + + record mpack + encode: function(obj:any):string + decode: function(str:string):any + end + + record spell + check: function(str:string):{{string | integer}} + end + -- TODO: these are a pitiful approximation of luv's types -- once Teal has some form of type inheritance/composition and luv.d.tl is written -- just steal from that @@ -216,7 +265,6 @@ global record vim fs_mkdir: function(string, integer, function(string, boolean)): boolean | Dir, string, string end - call: function(string, ...: any): any in_fast_event: function(): boolean type NIL = record userdata end -- special nil for filling tables @@ -413,6 +461,7 @@ global record vim end g: {string:any} + go: {string:any} t: {string:any} v: {string:any} env: {string:any} @@ -564,10 +613,8 @@ global record vim textwidth: number tfu: string thesaurus: string - thesaurusfunc: string ts: number tsr: string - tsrfu: string tw: number udf: boolean ul: number @@ -599,11 +646,9 @@ global record vim crb: boolean cuc: boolean cul: boolean - culopt: string cursorbind: boolean cursorcolumn: boolean cursorline: boolean - cursorlineopt: string diff: boolean fcs: string fdc: string @@ -644,14 +689,12 @@ global record vim rl: boolean rlc: string rnu: boolean - sbr: string scb: boolean scl: string scr: number scroll: number scrollbind: boolean scrolloff: number - showbreak: string sidescrolloff: number signcolumn: string siso: number @@ -675,10 +718,10 @@ global record vim record api --[[ API version Information - neovim version: 0.6.1 + neovim version: 0.5.0 compatible: 0 - level: 8 + level: 7 prerelease: false --]] @@ -702,7 +745,6 @@ global record vim nvim_buf_clear_namespace: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]])--[[void]] nvim_buf_del_extmark: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]]): boolean--[[Boolean]] nvim_buf_del_keymap: function(integer--[[Buffer]], string--[[String]], string--[[String]])--[[void]] - nvim_buf_del_mark: function(integer--[[Buffer]], string--[[String]]): boolean--[[Boolean]] nvim_buf_del_var: function(integer--[[Buffer]], string--[[String]])--[[void]] nvim_buf_delete: function(integer--[[Buffer]], {string:any}--[[Dictionary]])--[[void]] nvim_buf_detach: function(integer--[[Buffer]]): boolean--[[Boolean]] @@ -723,11 +765,11 @@ global record vim nvim_buf_set_extmark: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]], {string:any}--[[Dictionary]]): integer--[[Integer]] nvim_buf_set_keymap: function(integer--[[Buffer]], string--[[String]], string--[[String]], string--[[String]], {string:any}--[[Dictionary]])--[[void]] nvim_buf_set_lines: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]], boolean--[[Boolean]], {string}--[[ArrayOf(String)]])--[[void]] - nvim_buf_set_mark: function(integer--[[Buffer]], string--[[String]], integer--[[Integer]], integer--[[Integer]], {string:any}--[[Dictionary]]): boolean--[[Boolean]] nvim_buf_set_name: function(integer--[[Buffer]], string--[[String]])--[[void]] nvim_buf_set_option: function(integer--[[Buffer]], string--[[String]], any--[[Object]])--[[void]] nvim_buf_set_text: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]], {string}--[[ArrayOf(String)]])--[[void]] nvim_buf_set_var: function(integer--[[Buffer]], string--[[String]], any--[[Object]])--[[void]] + nvim_buf_set_virtual_text: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]], any--[[Array]], {string:any}--[[Dictionary]]): integer--[[Integer]] nvim_call_atomic: function(any--[[Array]]): any--[[Array]] nvim_call_dict_function: function(any--[[Object]], string--[[String]], any--[[Array]]): any--[[Object]] nvim_call_function: function(string--[[String]], any--[[Array]]): any--[[Object]] @@ -737,13 +779,11 @@ global record vim nvim_create_namespace: function(string--[[String]]): integer--[[Integer]] nvim_del_current_line: function()--[[void]] nvim_del_keymap: function(string--[[String]], string--[[String]])--[[void]] - nvim_del_mark: function(string--[[String]]): boolean--[[Boolean]] nvim_del_var: function(string--[[String]])--[[void]] nvim_echo: function(any--[[Array]], boolean--[[Boolean]], {string:any}--[[Dictionary]])--[[void]] nvim_err_write: function(string--[[String]])--[[void]] nvim_err_writeln: function(string--[[String]])--[[void]] nvim_eval: function(string--[[String]]): any--[[Object]] - nvim_eval_statusline: function(string--[[String]], {string:any}--[[Dictionary]]): {string:any}--[[Dictionary]] nvim_exec: function(string--[[String]], boolean--[[Boolean]]): string--[[String]] nvim_exec_lua: function(string--[[String]], any--[[Array]]): any--[[Object]] nvim_feedkeys: function(string--[[String]], string--[[String]], boolean--[[Boolean]])--[[void]] @@ -762,7 +802,6 @@ global record vim nvim_get_hl_by_name: function(string--[[String]], boolean--[[Boolean]]): {string:any}--[[Dictionary]] nvim_get_hl_id_by_name: function(string--[[String]]): integer--[[Integer]] nvim_get_keymap: function(string--[[String]]): {{string:any}}--[[ArrayOf(Dictionary)]] - nvim_get_mark: function(string--[[String]], {string:any}--[[Dictionary]]): any--[[Array]] nvim_get_mode: function(): {string:any}--[[Dictionary]] nvim_get_namespaces: function(): {string:any}--[[Dictionary]] nvim_get_option: function(string--[[String]]): any--[[Object]] From e85ce5b470c1cb5974cc2eec833537167f48de23 Mon Sep 17 00:00:00 2001 From: Steve Vermeulen Date: Fri, 1 Apr 2022 16:57:41 -0700 Subject: [PATCH 2/9] Added basic type hints for busted --- types/busted/busted.d.tl | 76 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 types/busted/busted.d.tl diff --git a/types/busted/busted.d.tl b/types/busted/busted.d.tl new file mode 100644 index 0000000..54f8178 --- /dev/null +++ b/types/busted/busted.d.tl @@ -0,0 +1,76 @@ + +global describe: function(string, function()) +global it: function(string, function()) +global before_each: function(function()) +global after_each: function(function()) +global setup: function(function()) +global teardown: function(function()) +global async: function() +global done: function() + +global record spy + on:function(any, any) +end + +global record assert + is_not_true:function(boolean, string) + is_true:function(boolean, string) + True:function(boolean, string) + + is_not_false:function(boolean, string) + is_false:function(boolean, string) + False:function(boolean, string) + + is_nil:function(any, string) + is_not_nil:function(any, string) + + is_truthy:function(any, string) + truthy:function(any, string) + + is_falsy:function(any, string) + falsy:function(any, string) + + has_property:function(any, string, string) + + same:function(any, any, string) + + are_not_same:function(any, any, string) + are_not_equal:function(any, any, string) + are_not_equals:function(any, any, string) + + are_same:function(any, any, string) + are_equal:function(any, any, string) + are_equals:function(any, any, string) + + are_unique:function(any, any, string) + are_not_unique:function(any, any, string) + + error:function(function(), string) + + has_no_errors:function(function(), string) + has_error:function(function(), string) + has_errors:function(function(), string) + + has_holes:function({any}, string) + has_no_holes:function({any}, string) + + record Spy + was_called:function(string) + was_not_called:function(string) + + was_called_with:function(any, string) + was_not_called_with:function(any, string) + end + + spy:function(any):Spy + + record Stub + was_called:function(string) + was_not_called:function(string) + + was_called_with:function(any, string) + was_not_called_with:function(any, string) + end + + stub:function(any):Stub +end From 40e6ec2c2bd82429ecf0966c91fdd1a84dad2ec3 Mon Sep 17 00:00:00 2001 From: Steve Vermeulen Date: Fri, 1 Apr 2022 20:09:04 -0700 Subject: [PATCH 3/9] Added some more missing type hints for busted. Also added a tests directory to ensure the busted type hints are correct --- tests/.busted | 6 + tests/.gitignore | 1 + tests/run_tests | 5 + tests/src/teal_type_tests/busted_spec.tl | 314 +++++++++++++++++++++++ tests/src/teal_type_tests/test_module.tl | 8 + tests/tlconfig.lua | 5 + types/busted/busted.d.tl | 68 +++-- types/luaassert/luassert/match.d.tl | 21 ++ 8 files changed, 404 insertions(+), 24 deletions(-) create mode 100644 tests/.busted create mode 100644 tests/.gitignore create mode 100755 tests/run_tests create mode 100644 tests/src/teal_type_tests/busted_spec.tl create mode 100644 tests/src/teal_type_tests/test_module.tl create mode 100644 tests/tlconfig.lua create mode 100644 types/luaassert/luassert/match.d.tl diff --git a/tests/.busted b/tests/.busted new file mode 100644 index 0000000..50dee31 --- /dev/null +++ b/tests/.busted @@ -0,0 +1,6 @@ +local cd = require"lfs".currentdir() +return { + default = { + lpath = cd .. "/build/?.lua;" .. cd .. "/build/?/init.lua;./?.lua;./?/init.lua;" + } +} diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +/build diff --git a/tests/run_tests b/tests/run_tests new file mode 100755 index 0000000..eca1d87 --- /dev/null +++ b/tests/run_tests @@ -0,0 +1,5 @@ +#!/bin/sh +set -ex +cd `dirname $BASH_SOURCE` +cyan build --prune +busted build diff --git a/tests/src/teal_type_tests/busted_spec.tl b/tests/src/teal_type_tests/busted_spec.tl new file mode 100644 index 0000000..b8bbab5 --- /dev/null +++ b/tests/src/teal_type_tests/busted_spec.tl @@ -0,0 +1,314 @@ + +-- The following code was just copied from the busted docs, and converted +-- from lua to teal +-- We include this here just to ensure our busted type hints work + +describe("Busted unit testing framework", function() + describe("should be awesome", function() + it("should be easy to use", function() + assert.truthy("Yup.") + end) + + it("should have lots of features", function() + -- deep check comparisons! + assert.are_same({ table = "great"}, { table = "great" }) + + -- or check by reference! + assert.are_not_equal({ table = "great"}, { table = "great"}) + + assert.truthy("this is a string") -- truthy: not false or nil + + assert.True(1 == 1) + assert.is_true(1 == 1) + + assert.falsy(nil) + assert.has_error(function() error("Wat") end, "Wat") + end) + + it("should provide some shortcuts to common functions", function() + assert.are_unique({{ thing = 1 }, { thing = 2 }, { thing = 3 }}) + end) + + it("should have mocks and spies for functional tests", function() + -- local test_module = require("test_module") + -- spy.on(test_module, "greet") + -- test_module.greet("Hi!") + + -- assert.spy(test_module.greet).was_called() + -- assert.spy(test_module.greet).was_called_with("Hi!") + end) + end) +end) + +describe("busted", function() + local obj1:any + local obj2:any + local test_module:any + + setup(function() + -- test_module = require("test_module") + end) + + teardown(function() + test_module = nil + end) + + before_each(function() + obj1 = { test = "yes" } + obj2 = { test = "yes" } + end) + + it("sets up vars with the before_each", function() + obj2 = { test = "no" } + assert.are_not_same(obj1, obj2) + end) + + it("sets up vars with the before_each", function() + -- obj2 is reset thanks to the before_each + assert.same(obj1, obj2) + end) + + describe("nested", function() + it("also runs the before_each here", function() + -- if this describe also had a before_each, it would run + -- both, starting with the parents'. You can go n-deep. + end) + end) +end) + +describe("finally test", function() + it('checks file contents',function() + local f = io.popen('echo 5') + + -- ensure that once test has finished f:close() is called + -- independent of test outcome + finally(function() f:close() end) + + -- do things with f + end) +end) + +describe("busted pending tests", function() + it("example", function() + pending("I should finish this test later") + end) +end) + +describe("some assertions", function() + it("tests positive assertions", function() + assert.is_true(true) -- Lua keyword chained with _ + assert.True(true) -- Lua keyword using a capital + assert.are_equal(1, 1) + assert.has_errors(function() error("this should fail") end) + end) + + it("tests negative assertions", function() + assert.is_not_true(false) + assert.are_not_equals(1, "1") + assert.has_no_errors(function() end) + end) + + it("checks if they're equals", function() + local expected = 1 + local obj = expected + + assert.are_equals(expected, obj) + end) + + it("checks if they're the same", function() + local expected = { name = "Jack" } + local obj = { name = "Jack" } + + assert.are_same(expected, obj) + end) + + it("checks true", function() + assert.is_true(true) + assert.is_not_true("Yes") + assert.is_truthy("Yes") + end) + + it("checks false", function() + assert.is_false(false) + assert.is_not_false(nil) + assert.is_falsy(nil) + end) + + it("should throw an error", function() + assert.has_error(function() error("Yup, it errored") end) + assert.has_no_errors(function() end) + end) + + it("should throw the error we expect", function() + local errfn = function() + error("DB CONN ERROR") + end + + assert.has_error(errfn, "DB CONN ERROR") + end) +end) + +describe("spies", function() + it("registers a new spy as a callback", function() + local s = spy.new(function() end) + + s(1, 2, 3) + s(4, 5, 6) + + assert.spy(s).was_called() + assert.spy(s).was_called(2) -- twice! + assert.spy(s).was_called_with(1, 2, 3) -- checks the history + end) + + it("replaces an original function", function() + local t = { + greet = function(msg:string) print(msg) end + } + + local s = spy.on(t, "greet") + + t.greet("Hey!") -- prints 'Hey!' + assert.spy(t.greet).was_called_with("Hey!") + + s:clear() -- clears the call history + assert.spy(s).was_not_called_with("Hey!") + + s:revert() -- reverts the stub + t.greet("Hello!") -- prints 'Hello!', will not pass through the spy + assert.spy(s).was_not_called_with("Hello!") + end) +end) + +describe("stubs", function() + it("replaces an original function", function() + local t = { + greet = function(msg:string) print(msg) end + } + + local greet_stub = stub(t, "greet") + + t.greet("Hey!") -- DOES NOT print 'Hey!' + assert.stub(t.greet).was_called_with("Hey!") + + greet_stub:revert() -- reverts the stub + t.greet("Hey!") -- DOES print 'Hey!' + end) +end) + +describe("mocks", function() + it("replaces a table with spies", function() + local t = { + thing = function(msg:string) print(msg) end + } + + local m = mock.new(t) -- mocks the table with spies, so it will print + + m.thing("Coffee") + assert.spy(m.thing).was_called_with("Coffee") + end) + + it("replaces a table with stubs", function() + local t = { + thing = function(msg:string) print(msg) end + } + + local m = mock.new(t, true) -- mocks the table with stubs, so it will not print + + m.thing("Coffee") + assert.stub(m.thing).was_called_with("Coffee") + + mock.revert(m) -- reverts all stubs/spies in m + m.thing("Tea") -- DOES print 'Tea' + end) +end) + +describe("match arguments", function() + local match = require("luassert.match") + + it("tests wildcard matcher", function() + local s = spy.new(function() end) + local _ = match._ + + s("foo") + + assert.spy(s).was_called_with(_) -- matches any argument + assert.spy(s).was_not_called_with(_, _) -- does not match two arguments + end) + + it("tests type matchers", function() + local s = spy.new(function() end) + + s("foo") + + assert.spy(s).was_called_with(match.is_string()) + assert.spy(s).was_called_with(match.is_truthy()) + assert.spy(s).was_called_with(match.is_not_nil()) + assert.spy(s).was_called_with(match.is_not_false()) + assert.spy(s).was_called_with(match.is_not_number()) + assert.spy(s).was_called_with(match.is_not_table()) + end) + + it("tests more matchers", function() + local s = spy.new(function() end) + + s(1) + + assert.spy(s).was_called_with(match.is_equal(1)) + assert.spy(s).was_called_with(match.is_same(1)) + end) +end) + +describe("combine matchers", function() + local match = require("luassert.match") + + it("tests ref matchers for passed in table", function() + local record Foo + cnt:integer + incrby:function(t:Foo, i:integer) + end + + local t:Foo = { + cnt = 0, + incrby = function(t:Foo, i:integer) t.cnt = t.cnt + i end + } + + local s = spy.on(t, "incrby") + + s(t, 2) + + assert.spy(s).was_called_with(match.is_ref(t), 2) + end) + + it("tests ref matchers for self", function() + local record Foo + cnt:integer + incrby:function(t:Foo, i:integer) + end + + local t:Foo = { + cnt = 0, + incrby = function(t:Foo, i:integer) t.cnt = t.cnt + i end + } + + local s = spy.on(t, "incrby") + + t:incrby(2) + + assert.spy(s).was_called_with(match.is_ref(t), 2) + end) +end) + +describe("combine matchers", function() + local match = require("luassert.match") + + it("tests composite matchers", function() + local s = spy.new(function() end) + + s("foo") + + assert.spy(s).was_called_with(match.is_all_of(match.is_not_nil(), match.is_not_number())) + assert.spy(s).was_called_with(match.is_any_of(match.is_number(), match.is_string(), match.is_boolean())) + assert.spy(s).was_called_with(match.is_none_of(match.is_number(), match.is_table(), match.is_boolean())) + end) +end) + diff --git a/tests/src/teal_type_tests/test_module.tl b/tests/src/teal_type_tests/test_module.tl new file mode 100644 index 0000000..42cb928 --- /dev/null +++ b/tests/src/teal_type_tests/test_module.tl @@ -0,0 +1,8 @@ + +local test_module = {} + +function test_module.greet(message:string) + print(message) +end + +return test_module diff --git a/tests/tlconfig.lua b/tests/tlconfig.lua new file mode 100644 index 0000000..ee06c49 --- /dev/null +++ b/tests/tlconfig.lua @@ -0,0 +1,5 @@ +return { + build_dir = "build", + source_dir = "src", + global_env_def = "busted" +} diff --git a/types/busted/busted.d.tl b/types/busted/busted.d.tl index 54f8178..eedf20c 100644 --- a/types/busted/busted.d.tl +++ b/types/busted/busted.d.tl @@ -7,19 +7,56 @@ global setup: function(function()) global teardown: function(function()) global async: function() global done: function() +global insulate: function(string, function()) +global expose: function(string, function()) +global randomize: function() +global finally: function(function()) +global pending: function(string) + +global record mock + revert:function(any) + + new:function(T, boolean):T +end + +local record Stub + was_called:function(string) + was_not_called:function(string) + + was_called_with:function(any, string) + was_not_called_with:function(any, string) + + revert:function(self:Stub) +end + +global stub: function(any, string):Stub + +local record Spy + was_called:function(integer) + was_not_called:function() + + was_called_with:function(...:any) + was_not_called_with:function(...:any) + + clear:function(self:Spy) + revert:function(self:Spy) + + metamethod __call: function(self: Spy, ...:any) +end global record spy - on:function(any, any) + on:function(any, any):Spy + new:function(function()):Spy end global record assert - is_not_true:function(boolean, string) - is_true:function(boolean, string) - True:function(boolean, string) + is_not_true:function(any, string) + is_true:function(any, string) + True:function(any, string) - is_not_false:function(boolean, string) - is_false:function(boolean, string) - False:function(boolean, string) + is_not_false:function(any, string) + is_false:function(any, string) + False:function(any, string) is_nil:function(any, string) is_not_nil:function(any, string) @@ -54,23 +91,6 @@ global record assert has_holes:function({any}, string) has_no_holes:function({any}, string) - record Spy - was_called:function(string) - was_not_called:function(string) - - was_called_with:function(any, string) - was_not_called_with:function(any, string) - end - spy:function(any):Spy - - record Stub - was_called:function(string) - was_not_called:function(string) - - was_called_with:function(any, string) - was_not_called_with:function(any, string) - end - stub:function(any):Stub end diff --git a/types/luaassert/luassert/match.d.tl b/types/luaassert/luassert/match.d.tl new file mode 100644 index 0000000..46fb526 --- /dev/null +++ b/types/luaassert/luassert/match.d.tl @@ -0,0 +1,21 @@ + +local record match + _:any + is_string:function() + is_truthy:function() + is_not_nil:function() + is_not_false:function() + is_not_number:function() + is_not_table:function() + is_equal:function(any) + is_same:function(any) + is_ref:function(any) + is_boolean:function(any) + is_table:function(any) + is_number:function() + is_all_of:function(...:any) + is_any_of:function(...:any) + is_none_of:function(...:any) +end + +return match From 166a4f19a0d1f6afd6c07c988b5f473e1447fae2 Mon Sep 17 00:00:00 2001 From: Steve Vermeulen Date: Sat, 2 Apr 2022 13:29:47 -0700 Subject: [PATCH 4/9] Filled out busted/luassert type stubs more --- tests/{ => busted}/.busted | 0 tests/{ => busted}/.gitignore | 0 tests/busted/readme.txt | 3 + tests/{ => busted}/run_tests | 0 tests/busted/src/assertions_spec.tl | 360 ++++++++++++++++++ tests/busted/src/busted_examples_spec.tl | 314 +++++++++++++++ tests/busted/src/matchers_spec.tl | 337 ++++++++++++++++ tests/busted/src/mocks_spec.tl | 54 +++ tests/busted/src/spies_spec.tl | 238 ++++++++++++ tests/busted/src/stub_spec.tl | 206 ++++++++++ .../src}/test_module.tl | 0 tests/{ => busted}/tlconfig.lua | 1 + tests/src/teal_type_tests/busted_spec.tl | 314 --------------- types/busted/busted.d.tl | 82 +--- types/luaassert/luassert.d.tl | 236 ++++++++++++ types/luaassert/luassert/match.d.tl | 113 +++++- types/penlight/{pl/init.d.tl => pl.d.tl} | 0 types/penlight/pl/tablex.d.tl | 2 +- types/say/say.d.tl | 9 + 19 files changed, 1857 insertions(+), 412 deletions(-) rename tests/{ => busted}/.busted (100%) rename tests/{ => busted}/.gitignore (100%) create mode 100644 tests/busted/readme.txt rename tests/{ => busted}/run_tests (100%) create mode 100644 tests/busted/src/assertions_spec.tl create mode 100644 tests/busted/src/busted_examples_spec.tl create mode 100644 tests/busted/src/matchers_spec.tl create mode 100644 tests/busted/src/mocks_spec.tl create mode 100644 tests/busted/src/spies_spec.tl create mode 100644 tests/busted/src/stub_spec.tl rename tests/{src/teal_type_tests => busted/src}/test_module.tl (100%) rename tests/{ => busted}/tlconfig.lua (75%) delete mode 100644 tests/src/teal_type_tests/busted_spec.tl create mode 100644 types/luaassert/luassert.d.tl rename types/penlight/{pl/init.d.tl => pl.d.tl} (100%) create mode 100644 types/say/say.d.tl diff --git a/tests/.busted b/tests/busted/.busted similarity index 100% rename from tests/.busted rename to tests/busted/.busted diff --git a/tests/.gitignore b/tests/busted/.gitignore similarity index 100% rename from tests/.gitignore rename to tests/busted/.gitignore diff --git a/tests/busted/readme.txt b/tests/busted/readme.txt new file mode 100644 index 0000000..8765f8d --- /dev/null +++ b/tests/busted/readme.txt @@ -0,0 +1,3 @@ + +These tests were created by copying the busted tests from the luaassert repo, and then converting them to teal + diff --git a/tests/run_tests b/tests/busted/run_tests similarity index 100% rename from tests/run_tests rename to tests/busted/run_tests diff --git a/tests/busted/src/assertions_spec.tl b/tests/busted/src/assertions_spec.tl new file mode 100644 index 0000000..e378ca1 --- /dev/null +++ b/tests/busted/src/assertions_spec.tl @@ -0,0 +1,360 @@ + +describe("Test Assertions", function() + it("Checks level and get_level values", function() + assert.equal(3, assert:get_level(assert:level(3))) + assert.is_nil(assert:get_level({})) + assert.is_nil(assert:get_level("hello world")) + assert.is_nil(assert:get_level(nil)) + end) + + it("Checks to see if tables 1 and 2 are not the same", function() + local table1 = { derp = false} + local table2 = { derp = true} + assert.is_not_same(table1, table2) + end) + + it("Checks same() assertion to handle nils properly", function() + assert.is_error(function() assert.same(nil) end) -- minimum 2 arguments + assert.same(nil, nil) + assert.is_not_same("a string", nil) + assert.is_not_same(nil, "a string") + end) + + it("Checks to see if tables 1 and 2 are equal", function() + local table1 = { derp = false} + local table2 = table1 + assert.equals(table1, table2) + end) + + it("Checks equals() assertion to handle nils properly", function() + assert.is_error(function() assert.equals(nil) end) -- minimum 2 arguments + assert.equals(nil, nil) + assert.is_not_equals("a string", nil) + assert.is_not_equals(nil, "a string") + end) + + it("Checks to see if table1 only contains unique elements", function() + local table2 = { derp = false} + local table3 = { derp = true } + local table1 = {table2,table3} + local tablenotunique = {table2,table2} + assert.is_unique(table1) + assert.is_not_unique(tablenotunique) + end) + + it("Checks near() assertion handles tolerances", function() + assert.is_near(1.5, 2.0, 0.5) + assert.is_not_near(1.5, 2.0, 0.499) + end) + + it("Checks matches() assertion does string matching", function() + assert.is_error(function() assert.matches('.*') end) -- minimum 2 arguments + assert.is_error(function() assert.matches(nil, 's') end) -- arg1 must be a string + assert.matches("%w+", "test") + assert.has_match("%w+", "test") + assert.has_no_match("%d+", "derp") + assert.has_match("^test", "123 test", "5") + assert.has_no_match("%d+", "123 test", "4") + end) + + it("Ensures the is operator doesn't change the behavior of equals", function() + assert.is_equals(true, true) + end) + + it("Ensures the is_not operator does change the behavior of equals", function() + assert.is_not_equals(true, false) + end) + + it("Ensures that error only throws an error when the first argument function does not throw an error", function() + local test_function = function() error("test") end + assert.has_error(test_function) + assert.has_error(test_function, "test") + assert.has_no_errors(test_function, "derp") + end) + + it("Checks to see if var is truthy", function() + assert.is_not_truthy(nil) + assert.is_truthy(true) + assert.is_truthy({}) + assert.is_truthy(function() end) + assert.is_truthy("") + assert.is_not_truthy(false) + assert.error(function() assert.truthy(false) end) + end) + + it("Checks to see if var is falsy", function() + assert.is_falsy(nil) + assert.is_not_falsy(true) + assert.is_not_falsy({}) + assert.is_not_falsy(function() end) + assert.is_not_falsy("") + assert.is_falsy(false) + end) + + it("Ensures the Not operator does change the behavior of equals", function() + assert.is_not_equal(true, false) + end) + + it("Checks true() assertion", function() + assert.is_true(true) + assert.is_not_true(123) + assert.is_not_true(nil) + assert.is_not_true("abc") + assert.is_not_true(false) + assert.is_not_true(function() end) + end) + + it("Checks false() assertion", function() + assert.is_false(false) + assert.is_not_false(123) + assert.is_not_false(nil) + assert.is_not_false("abc") + assert.is_not_false(true) + assert.is_not_false(function() end) + end) + + it("Checks boolean() assertion", function() + assert.is_boolean(false) + assert.is_boolean(true) + assert.is_not_boolean(123) + assert.is_not_boolean(nil) + assert.is_not_boolean("abc") + assert.is_not_boolean(function() end) + end) + + it("Checks number() assertion", function() + assert.is_number(123) + assert.is_number(-0.345) + assert.is_not_number(nil) + assert.is_not_number("abc") + assert.is_not_number(true) + assert.is_not_number(function() end) + end) + + it("Checks string() assertion", function() + assert.is_string("abc") + assert.is_not_string(123) + assert.is_not_string(nil) + assert.is_not_string(true) + assert.is_not_string(function() end) + end) + + it("Checks table() assertion", function() + assert.is_table({}) + assert.is_not_table("abc") + assert.is_not_table(123) + assert.is_not_table(nil) + assert.is_not_table(true) + assert.is_not_table(function() end) + end) + + it("Checks nil() assertion", function() + assert.is_nil(nil) + assert.is_not_nil(123) + assert.is_not_nil("abc") + assert.is_not_nil(true) + assert.is_not_nil(function() end) + end) + + it("Checks function() assertion", function() + assert.is_function(function() end) + assert.is_not_function(nil) + assert.is_not_function(123) + assert.is_not_function("abc") + assert.is_not_function(true) + end) + + it("Checks userdata() assertion", function() + local myfile = io.tmpfile() + assert.is_userdata(myfile) + myfile:close() + assert.is_not_userdata(nil) + assert.is_not_userdata(123) + assert.is_not_userdata("abc") + assert.is_not_userdata(true) + assert.is_not_userdata(function() end) + end) + + it("Checks thread() assertion", function() + local mythread = coroutine.create(function() end) + assert.is_thread(mythread) + assert.is_not_thread(nil) + assert.is_not_thread(123) + assert.is_not_thread("abc") + assert.is_not_thread(true) + assert.is_not_thread(function() end) + end) + + it("Checks '_' chaining of modifiers and assertions", function() + assert.is_string("abc") + assert.is_true(true) + assert.is_not_string(123) + assert.is_nil(nil) + assert.is_not_nil({}) + assert.is_not_true(false) + assert.is_not_false(true) + + -- verify that failing assertions actually fail + assert.has_error(function() assert.is_string(1) end) + assert.has_error(function() assert.is_true(false) end) + assert.has_error(function() assert.is_not_string('string!') end) + assert.has_error(function() assert.is_nil({}) end) + assert.has_error(function() assert.is_not_nil(nil) end) + assert.has_error(function() assert.is_not_true(true) end) + assert.has_error(function() assert.is_not_false(false) end) + end) + + it("Checks '.' chaining of modifiers and assertions", function() + assert.is_string("abc") + assert.is_true(true) + assert.is_not_string(123) + assert.is_nil(nil) + assert.is_not_nil({}) + assert.is_not_true(false) + assert.is_not_false(true) + assert.not_equals(true, false) + + -- verify that failing assertions actually fail + assert.has_error(function() assert.is_string(1) end) + assert.has_error(function() assert.is_true(false) end) + assert.has_error(function() assert.is_not_string('string!') end) + assert.has_error(function() assert.is_nil({}) end) + assert.has_error(function() assert.is_not_nil(nil) end) + assert.has_error(function() assert.is_not_true(true) end) + assert.has_error(function() assert.is_not_false(false) end) + assert.has_error(function() assert.equals_not(true, true) end) + end) + + it("Checks number of returned arguments", function() + local fn = function() + end + + local fn1 = function():string, integer, integer + return "something",2,3 + end + + local fn2 = function():any + return nil + end + + local fn3 = function():any, any + return nil, nil + end + + local fn4 = function(): any, number, any + return nil, 1, nil + end + + assert.returned_arguments(0, fn()) + assert.not_returned_arguments(2, fn1()) + assert.returned_arguments(3, fn1()) + + assert.returned_arguments(1, fn2()) + assert.returned_arguments(2, fn3()) + assert.returned_arguments(3, fn4()) + end) + + it("Checks has_error to accept only callable arguments", function() + local t_ok = setmetatable( {}, { __call = function() end } ) + local t_nok = setmetatable( {}, { __call = function() error("some error") end } ) + local f_ok = function() end + local f_nok = function() error("some error") end + + assert.has_error(f_nok) + assert.has_no_error(f_ok) + assert.has_error(t_nok) + assert.has_no_error(t_ok) + end) + + it("Checks has_error compares error strings", function() + assert.has_error(function() error() end) + assert.has_error(function() error("string") end, "string") + end) + + it("Checks has_error compares error objects", function() + local func = function() end + assert.has_error(function() error({ "table" }) end, { "table" }) + assert.has_error(function() error(func) end, func) + assert.has_error(function() error(false) end, false) + assert.has_error(function() error(true) end, true) + assert.has_error(function() error(0) end, 0) + assert.has_error(function() error(1.5) end, 1.5) + assert.has_error(function() error(10.0^50) end, 10.0^50) + assert.has_error(function() error(10.0^-50) end, 10.0^-50) + assert.has_no_error(function() error(true) end, 0) + assert.has_no_error(function() error(125) end, 1.5) + end) + + it("Checks has_error compares error objects with strings", function() + local mt = { __tostring = function(t:table):any return t[1] end } + assert.has_error(function() error(setmetatable({ "table" }, mt)) end, "table") + end) + + it("Checks error_matches to accepts at least 2 arguments", function() + assert.has_error(function() assert.error_matches(error) end) + assert.has_no_error(function() assert.error_matches(function() error("foo") end, ".*") end) + end) + + it("Checks error_matches to accept only callable arguments", function() + local t_ok = setmetatable( {}, { __call = function() end } ) + local t_nok = setmetatable( {}, { __call = function() error("some error") end } ) + local f_ok = function() end + local f_nok = function() error("some error") end + + assert.error_matches(f_nok, ".*") + assert.no_error_matches(f_ok, ".*") + assert.error_matches(t_nok, ".*") + assert.no_error_matches(t_ok, ".*") + end) + + it("Checks error_matches does not compare error objects", function() + assert.no_error_matches(function() error({ "table" }) end, "table") + end) + + it("Checks error_matches compares error objects that are convertible to strings", function() + local mt = { __tostring = function(t:table):any return t[1] end } + assert.error_matches(function() error(setmetatable({ "table" }, mt)) end, "^table$") + end) + + it("Checks asserts return all their arguments on success", function() + assert.is_same({true, "bar"}, {assert.is_true(true, "bar")}) + assert.is_same({false, "foobar"}, {assert.is_false(false, "foobar")}) + assert.is_same({"", "truthy"}, {assert.is_truthy("", "truthy")}) + assert.is_same({nil, "falsy"}, {assert.is_falsy(nil, "falsy")}) + assert.is_same({true, "boolean"}, {assert.is_boolean(true, "boolean")}) + assert.is_same({false, "still boolean"}, {assert.is_boolean(false, "still boolean")}) + assert.is_same({0, "is number"}, {assert.is_number(0, "is number")}) + assert.is_same({"string", "is string"}, {assert.is_string("string", "is string")}) + assert.is_same({{}, "empty table"}, {assert.is_table({}, "empty table")}) + assert.is_same({nil, "string"}, {assert.is_nil(nil, "string")}) + assert.is_same({{1, 2, 3}, "unique message"}, {assert.is_unique({1, 2, 3}, "unique message")}) + assert.is_same({"foo", "foo", "bar"}, {assert.is_equal("foo", "foo", "bar")}) + assert.is_same({"foo", "foo", "string"}, {assert.is_same("foo", "foo", "string")}) + assert.is_same({0, 1, 2, "message"}, {assert.is_near(0, 1, 2, "message")}) + end) + + it("Checks assert.has_match returns captures from match on success", function() + assert.is_same({"string"}, {assert.has_match("(.*)", "string", "message")}) + assert.is_same({"s", "n"}, {assert.has_match("(s).*(n)", "string", "message")}) + assert.is_same({"tri"}, {assert.has_match("tri", "string", "message")}) + assert.is_same({}, {assert.has_no_match("%d+", "string", "message")}) + end) + + it("Checks assert.has_error returns thrown error on success", function() + assert.is_same({"err message", "err message"}, {assert.has_error(function() error("err message") end, "err message")}) + assert.is_same({{}, {}}, {assert.has_error(function() error({}) end, {})}) + assert.is_same({nil, nil}, {assert.has_error(function() error(nil) end, nil)}) + assert.is_same({nil, "string"}, {assert.has_no_error(function() end, "string")}) + end) + + it("Checks assert.error_matches returns captures of thrown error on success", function() + assert.is_same({"err", "message"}, {assert.error_matches(function() error("err message") end, "(err) (%w+)$")}) + assert.is_same({}, {assert.error_matches(function() error(nil) end, nil)}) + end) + + it("Checks assert.no_error_matches returns thrown error on success", function() + assert.is_same({nil, "string"}, {assert.no_error_matches(function() end, "string")}) + assert.is_same({"error", "string"}, {assert.no_error_matches(function() error("error") end, "string")}) + end) + +end) diff --git a/tests/busted/src/busted_examples_spec.tl b/tests/busted/src/busted_examples_spec.tl new file mode 100644 index 0000000..336e2da --- /dev/null +++ b/tests/busted/src/busted_examples_spec.tl @@ -0,0 +1,314 @@ + +-- These tests were just copied from the busted docs, and converted +-- from lua to teal +-- We include this here just to ensure our busted type hints work + +describe("Busted unit testing framework", function() + describe("should be awesome", function() + it("should be easy to use", function() + assert.truthy("Yup.") + end) + + it("should have lots of features", function() + -- deep check comparisons! + assert.are_same({ table = "great"}, { table = "great" }) + + -- or check by reference! + assert.are_not_equal({ table = "great"}, { table = "great"}) + + assert.truthy("this is a string") -- truthy: not false or nil + + assert.is_true(1 == 1) + + assert.falsy(nil) + assert.has_error(function() error("Wat") end, "Wat") + end) + + it("should provide some shortcuts to common functions", function() + assert.are_unique({{ thing = 1 }, { thing = 2 }, { thing = 3 }}) + end) + + it("should have mocks and spies for functional tests", function() + local thing = require("old_test_module") + spy.on(thing, "greet") + + assert.spy(thing.greet).was_not_called() + + thing.greet("Hi!") + + assert.spy(thing.greet).was_called() + assert.spy(thing.greet).was_called_with("Hi!") + end) + end) + + describe("test methods", function() + local obj1:any + local obj2:any + local test_module:any + + setup(function() + test_module = require("old_test_module") + end) + + teardown(function() + test_module = nil + end) + + before_each(function() + obj1 = { test = "yes" } + obj2 = { test = "yes" } + end) + + it("sets up vars with the before_each", function() + obj2 = { test = "no" } + assert.are_not_same(obj1, obj2) + end) + + it("sets up vars with the before_each", function() + -- obj2 is reset thanks to the before_each + assert.same(obj1, obj2) + end) + + describe("nested", function() + it("also runs the before_each here", function() + -- if this describe also had a before_each, it would run + -- both, starting with the parents'. You can go n-deep. + end) + end) + end) + + describe("finally test", function() + it('checks file contents',function() + local f = io.popen('echo 5') + + -- ensure that once test has finished f:close() is called + -- independent of test outcome + finally(function() f:close() end) + + -- do things with f + end) + end) + + describe("busted pending tests", function() + it("example", function() + pending("I should finish this test later") + end) + end) + + describe("some assertions", function() + it("tests positive assertions", function() + assert.is_true(true) -- Lua keyword chained with _ + assert.are_equal(1, 1) + assert.has_errors(function() error("this should fail") end) + end) + + it("tests negative assertions", function() + assert.is_not_true(false) + assert.are_not_equals(1, "1") + assert.has_no_errors(function() end) + end) + + it("checks if they're equals", function() + local expected = 1 + local obj = expected + + assert.are_equals(expected, obj) + end) + + it("checks if they're the same", function() + local expected = { name = "Jack" } + local obj = { name = "Jack" } + + assert.are_same(expected, obj) + end) + + it("checks true", function() + assert.is_true(true) + assert.is_not_true("Yes") + assert.is_truthy("Yes") + end) + + it("checks false", function() + assert.is_false(false) + assert.is_not_false(nil) + assert.is_falsy(nil) + end) + + it("should throw an error", function() + assert.has_error(function() error("Yup, it errored") end) + assert.has_no_errors(function() end) + end) + + it("should throw the error we expect", function() + local errfn = function() + error("DB CONN ERROR") + end + + assert.has_error(errfn, "DB CONN ERROR") + end) + end) + + describe("spies", function() + it("registers a new spy as a callback", function() + local s = spy.new(function(_:integer) end) + + s(1) + s(4) + + assert.spy(s).was_called() + assert.spy(s).was_called(2) -- twice! + assert.spy(s).was_called_with(4) -- checks the history + end) + + it("replaces an original function", function() + local t = { + greet = function(msg:string) print(msg) end + } + + local s = spy.on(t, "greet") + + t.greet("Hey!") -- prints 'Hey!' + assert.spy(t.greet).was_called_with("Hey!") + + s:clear() -- clears the call history + assert.spy(s).was_not_called_with("Hey!") + + s:revert() -- reverts the stub + t.greet("Hello!") -- prints 'Hello!', will not pass through the spy + assert.spy(s).was_not_called_with("Hello!") + end) + end) + + describe("stubs", function() + it("replaces an original function", function() + local t = { + greet = function(msg:string) print(msg) end + } + + local greet_stub = stub.new(t, "greet") + + t.greet("Hey!") -- DOES NOT print 'Hey!' + assert.stub(t.greet).was_called_with("Hey!") + + greet_stub:revert() -- reverts the stub + t.greet("Hey!") -- DOES print 'Hey!' + end) + end) + + describe("mocks", function() + it("replaces a table with spies", function() + local t = { + thing = function(msg:string) print(msg) end + } + + local m = mock.new(t) -- mocks the table with spies, so it will print + + m.thing("Coffee") + assert.spy(m.thing).was_called_with("Coffee") + end) + + it("replaces a table with stubs", function() + local t = { + thing = function(msg:string) print(msg) end + } + + local m = mock.new(t, true) -- mocks the table with stubs, so it will not print + + m.thing("Coffee") + assert.stub(m.thing).was_called_with("Coffee") + + mock.revert(m) -- reverts all stubs/spies in m + m.thing("Tea") -- DOES print 'Tea' + end) + end) + + describe("match arguments", function() + local match = require("luassert.match") + + it("tests wildcard matcher", function() + local s = spy.new(function(_:string) end) + local _ = match._ + + s("foo") + + assert.spy(s).was_called_with(_) -- matches any argument + assert.spy(s).was_not_called_with(_, _) -- does not match two arguments + end) + + it("tests type matchers", function() + local s = spy.new(function(_:string) end) + + s("foo") + + assert.spy(s).was_called_with(match.is_string()) + assert.spy(s).was_called_with(match.is_truthy()) + assert.spy(s).was_called_with(match.is_not_nil()) + assert.spy(s).was_called_with(match.is_not_false()) + assert.spy(s).was_called_with(match.is_not_number()) + assert.spy(s).was_called_with(match.is_not_table()) + end) + + it("tests more matchers", function() + local s = spy.new(function(_:integer) end) + + s(1) + + assert.spy(s).was_called_with(match.is_equal(1)) + assert.spy(s).was_called_with(match.is_same(1)) + end) + end) + + describe("combine matchers", function() + local match = require("luassert.match") + + it("tests ref matchers for passed in table", function() + local record Foo + cnt:integer + incrby:function(t:Foo, i:integer) + end + + local t:Foo = { + cnt = 0, + incrby = function(t:Foo, i:integer) t.cnt = t.cnt + i end + } + + local s = spy.on(t, "incrby") + + s(t, 2) + + assert.spy(s).was_called_with(match.is_ref(t), 2) + end) + + it("tests ref matchers for self", function() + local record Foo + cnt:integer + incrby:function(t:Foo, i:integer) + end + + local t:Foo = { + cnt = 0, + incrby = function(t:Foo, i:integer) t.cnt = t.cnt + i end + } + + local s = spy.on(t, "incrby") + + t:incrby(2) + + assert.spy(s).was_called_with(match.is_ref(t), 2) + end) + end) + + describe("combine matchers", function() + local match = require("luassert.match") + + it("tests composite matchers", function() + local s = spy.new(function(_:string) end) + + s("foo") + + assert.spy(s).was_called_with(match.is_all_of(match.is_not_nil(), match.is_not_number())) + assert.spy(s).was_called_with(match.is_any_of(match.is_number(), match.is_string(), match.is_boolean())) + assert.spy(s).was_called_with(match.is_none_of(match.is_number(), match.is_table(), match.is_boolean())) + end) + end) +end) diff --git a/tests/busted/src/matchers_spec.tl b/tests/busted/src/matchers_spec.tl new file mode 100644 index 0000000..1afde14 --- /dev/null +++ b/tests/busted/src/matchers_spec.tl @@ -0,0 +1,337 @@ +local match = require('luassert.match') + +assert.is_true(type(match) == "table") + +describe("Test Matchers", function() + it("Checks wildcard() matcher", function() + assert.is_true(match._(nil)) + assert.is_true(match._(true)) + assert.is_true(match._(false)) + assert.is_true(match._(123)) + assert.is_true(match._("")) + assert.is_true(match._({})) + assert.is_true(match._(function() end)) + end) + + it("Checks truthy() matcher", function() + assert.is_false(match.truthy()(nil)) + assert.is_true(match.truthy()(true)) + assert.is_false(match.truthy()(false)) + assert.is_true(match.truthy()(123)) + assert.is_true(match.truthy()("")) + assert.is_true(match.truthy()({})) + assert.is_true(match.truthy()(function() end)) + end) + + it("Checks falsy() matcher", function() + assert.is_true(match.falsy()(nil)) + assert.is_false(match.falsy()(true)) + assert.is_true(match.falsy()(false)) + assert.is_false(match.falsy()(123)) + assert.is_false(match.falsy()("")) + assert.is_false(match.falsy()({})) + assert.is_false(match.falsy()(function() end)) + end) + + it("Checks true() matcher", function() + assert.is_false(match.is_true()(nil)) + assert.is_true(match.is_true()(true)) + assert.is_false(match.is_true()(false)) + assert.is_false(match.is_true()(123)) + assert.is_false(match.is_true()("")) + assert.is_false(match.is_true()({})) + assert.is_false(match.is_true()(function() end)) + end) + + it("Checks false() matcher", function() + assert.is_false(match.is_false()(nil)) + assert.is_false(match.is_false()(true)) + assert.is_true(match.is_false()(false)) + assert.is_false(match.is_false()(123)) + assert.is_false(match.is_false()("")) + assert.is_false(match.is_false()({})) + assert.is_false(match.is_false()(function() end)) + end) + + it("Checks nil() matcher", function() + assert.is_true(match.is_nil()(nil)) + assert.is_false(match.is_nil()(true)) + assert.is_false(match.is_nil()(false)) + assert.is_false(match.is_nil()(123)) + assert.is_false(match.is_nil()("")) + assert.is_false(match.is_nil()({})) + assert.is_false(match.is_nil()(function() end)) + end) + + it("Checks boolean() matcher", function() + assert.is_false(match.is_boolean()(nil)) + assert.is_true(match.is_boolean()(true)) + assert.is_true(match.is_boolean()(false)) + assert.is_false(match.is_boolean()(123)) + assert.is_false(match.is_boolean()("")) + assert.is_false(match.is_boolean()({})) + assert.is_false(match.is_boolean()(function() end)) + end) + + it("Checks number() matcher", function() + assert.is_false(match.is_number()(nil)) + assert.is_false(match.is_number()(true)) + assert.is_false(match.is_number()(false)) + assert.is_true(match.is_number()(123)) + assert.is_false(match.is_number()("")) + assert.is_false(match.is_number()({})) + assert.is_false(match.is_number()(function() end)) + end) + + it("Checks string() matcher", function() + assert.is_false(match.is_string()(nil)) + assert.is_false(match.is_string()(true)) + assert.is_false(match.is_string()(false)) + assert.is_false(match.is_string()(123)) + assert.is_true(match.is_string()("")) + assert.is_false(match.is_string()({})) + assert.is_false(match.is_string()(function() end)) + end) + + it("Checks table() matcher", function() + assert.is_false(match.is_boolean()(nil)) + assert.is_false(match.is_table()(nil)) + assert.is_false(match.is_table()(true)) + assert.is_false(match.is_table()(false)) + assert.is_false(match.is_table()(123)) + assert.is_false(match.is_table()("")) + assert.is_true(match.is_table()({})) + assert.is_false(match.is_table()(function() end)) + end) + + it("Checks function() matcher", function() + assert.is_false(match.is_function()(nil)) + assert.is_false(match.is_function()(true)) + assert.is_false(match.is_function()(false)) + assert.is_false(match.is_function()(123)) + assert.is_false(match.is_function()("")) + assert.is_false(match.is_function()({})) + assert.is_true(match.is_function()(function() end)) + end) + + it("Checks userdata() matcher", function() + assert.is_true(match.is_userdata()(io.stdout)) + assert.is_false(match.is_userdata()(nil)) + assert.is_false(match.is_userdata()(true)) + assert.is_false(match.is_userdata()(false)) + assert.is_false(match.is_userdata()(123)) + assert.is_false(match.is_userdata()("")) + assert.is_false(match.is_userdata()({})) + assert.is_false(match.is_userdata()(function() end)) + end) + + it("Checks thread() matcher", function() + local mythread = coroutine.create(function() end) + assert.is_true(match.is_thread()(mythread)) + assert.is_false(match.is_thread()(nil)) + assert.is_false(match.is_thread()(true)) + assert.is_false(match.is_thread()(false)) + assert.is_false(match.is_thread()(123)) + assert.is_false(match.is_thread()("")) + assert.is_false(match.is_thread()({})) + assert.is_false(match.is_thread()(function() end)) + end) + + it("Checks to see if tables 1 and 2 are equal", function() + local table1 = { derp = false} + local table2 = table1 + assert.is_true(match.is_equal(table1)(table2)) + assert.is_true(match.is_equal(table2)(table1)) + end) + + it("Checks equals() matcher to handle nils properly", function() + assert.is_error(function() match.is_equals() end) -- minimum 1 argument + assert.is_true(match.is_equal(nil)(nil)) + assert.is_false(match.is_equal("a string")(nil)) + assert.is_false(match.is_equal(nil)("a string")) + end) + + it("Checks same() matcher to handle nils properly", function() + assert.is_error(function() match.same()() end) -- minimum 1 arguments + assert.is_true(match.is_same(nil)(nil)) + assert.is_false(match.is_same("a string")(nil)) + assert.is_false(match.is_same(nil)("a string")) + end) + + it("Checks ref() matcher", function() + local t = {} + local func = function() end + local mythread = coroutine.create(func) + assert.is_error(function() match.is_ref() end) -- minimum 1 arguments + assert.is_true(match.is_ref(t)(t)) + assert.is_true(match.is_ref(func)(func)) + assert.is_true(match.is_ref(mythread)(mythread)) + assert.is_false(match.is_ref(t)(func)) + assert.is_false(match.is_ref(t)(mythread)) + assert.is_false(match.is_ref(t)(nil)) + assert.is_false(match.is_ref(t)(true)) + assert.is_false(match.is_ref(t)(false)) + assert.is_false(match.is_ref(t)(123)) + assert.is_false(match.is_ref(t)("")) + assert.is_false(match.is_ref(t)({})) + assert.is_false(match.is_ref(t)(function() end)) + end) + + it("Checks matches() matcher does string matching", function() + assert.is_error(function() match.matches() end) -- minimum 1 arguments + assert.is_true(match.matches("%w+")("test")) + assert.is_true(match.has_match("%w+")("test")) + assert.is_false(match.matches("%d+")("derp")) + assert.is_true(match.has_match("^test", 5)("123 test")) + assert.is_false(match.has_match("%d+", 4)("123 test")) + end) + + it("Checks near() matcher handles tolerances", function() + assert.is_error(function() match.near(0) end) -- minimum 2 arguments + + assert.is_true(match.is_near(1.5, 0.5)(2.0)) + assert.is_true(match.is_not_near(1.5, 0.499)(2.0)) + end) + + it("Checks to see if table1 only contains unique elements", function() + local table2 = { derp = false} + local table3 = { derp = true } + local table1 = {table2,table3} + local tablenotunique = {table2,table2} + assert.is_true(match.is_unique()(table1)) + assert.is_true(match.is_not_unique()(tablenotunique)) + end) + + it("Checks '_' chaining of modifiers and match", function() + assert.is_true(match.is_string()("abc")) + assert.is_true(match.is_true()(true)) + assert.is_true(match.is_not_string()(123)) + assert.is_true(match.is_nil()(nil)) + assert.is_true(match.is_not_nil()({})) + assert.is_true(match.is_not_true()(false)) + assert.is_true(match.is_not_false()(true)) + + -- verify that failing match return false + assert.is_false(match.is_string()(1)) + assert.is_false(match.is_true()(false)) + assert.is_false(match.is_not_string()('string!')) + assert.is_false(match.is_nil()({})) + assert.is_false(match.is_not_nil()(nil)) + assert.is_false(match.is_not_true()(true)) + assert.is_false(match.is_not_false()(false)) + end) + + it("Checks '.' chaining of modifiers and match", function() + assert.is_true(match.is_string()("abc")) + assert.is_true(match.is_true()(true)) + assert.is_true(match.is_not_string()(123)) + assert.is_true(match.is_nil()(nil)) + assert.is_true(match.is_not_nil()({})) + assert.is_true(match.is_not_true()(false)) + assert.is_true(match.is_not_false()(true)) + + -- verify that failing match return false + assert.is_false(match.is_string()(1)) + assert.is_false(match.is_true()(false)) + assert.is_false(match.is_not_string()('string!')) + assert.is_false(match.is_nil()({})) + assert.is_false(match.is_not_nil()(nil)) + assert.is_false(match.is_not_true()(true)) + assert.is_false(match.is_not_false()(false)) + end) + + it("Checks called_with() argument matching for spies", function() + local s = spy.new(function():string return "foo" end) + s(1) + s(nil, "") + s({}, "") + s(function() end, "") + s(1, 2, 3) + s("a", "b", "c", "d") + assert.spy(s).was_called_with(match._) + assert.spy(s).was_called_with(match.is_number()) + assert.spy(s).was_called_with(match.is_number(), match.is_number(), match.is_number()) + assert.spy(s).was_not_called_with(match.is_string()) + assert.spy(s).was_called_with(match.is_string(), match.is_string(), match.is_string(), match.is_string()) + assert.spy(s).was_called_with(match.is_nil(), match._) + assert.spy(s).was_called_with(match.is_table(), match._) + assert.spy(s).was_called_with(match.is_function(), match._) + assert.spy(s).was_not_called_with(match.is_nil()) + assert.spy(s).was_not_called_with(match.is_table()) + assert.spy(s).was_not_called_with(match.is_function()) + end) + + it("Checks returned_with() argument matching for spies", function() + local s = spy.new(function():string return "foo" end) + s() + assert.spy(s).was_returned_with(match._) + assert.spy(s).was_returned_with(match.is_string()) + assert.spy(s).was_returned_with(match.is_not_number()) + assert.spy(s).was_returned_with(match.is_not_table()) + assert.spy(s).was_not_returned_with(match.is_number()) + assert.spy(s).was_not_returned_with(match.is_table()) + end) + + it("Checks on_call_with() argument matching for stubs", function() + local test = {} + local s = stub.new(test, "key").returns("foo") + s.on_call_with(match.is_string()).returns("bar") + s.on_call_with(match.is_number()).returns(555) + s.on_call_with(match.is_table()).returns({"foo"}) + s(0) + s("") + s({}) + assert.spy(s).was_returned_with(555) + assert.spy(s).was_returned_with("bar") + assert.spy(s).was_returned_with({"foo"}) + end) + + it("Checks returned_with() argument matching for spies", function() + local s = spy.new(function():string return "foo" end) + s() + assert.spy(s).was_returned_with(match._) + assert.spy(s).was_returned_with(match.is_string()) + assert.spy(s).was_returned_with(match.is_not_nil()) + assert.spy(s).was_returned_with(match.is_not_number()) + assert.spy(s).was_returned_with(match.is_not_table()) + assert.spy(s).was_returned_with(match.is_not_function()) + end) + + it("Checks none() composite matcher", function() + assert.has_error(function() match.none_of() end) -- minimum 1 arguments + assert.has_error(function() match.none_of('') end) -- arg must be a matcher + assert.has_error(function() match.none_of('', 0) end) -- all args must be a match + + assert.is_false(match.none_of(match.is_string())('')) + assert.is_true(match.none_of(match.is_number())('')) + assert.is_true(match.none_of(match.is_number(), match.is_function())('')) + assert.is_false(match.none_of(match.is_number(), match.is_not_function())('')) + assert.is_false(match.not_none_of(match.is_number(), match.is_function())('')) + end) + + it("Checks any() composite matcher", function() + assert.has_error(function() match.any_of() end) -- minimum 1 arguments + assert.has_error(function() match.any_of('') end) -- arg must be a matcher + assert.has_error(function() match.any_of('', 0) end) -- all args must be a match + + assert.is_true(match.any_of(match.is_string())('')) + assert.is_false(match.any_of(match.is_number())('')) + assert.is_false(match.any_of(match.is_number(), match.is_function())('')) + assert.is_true(match.any_of(match.is_number(), match.is_not_function())('')) + assert.is_true(match.not_any_of(match.is_number(), match.is_function())('')) + end) + + it("Checks all() composite matcher", function() + assert.has_error(function() match.all_of() end) -- minimum 1 arguments + assert.has_error(function() match.all_of('') end) -- arg must be a matcher + assert.has_error(function() match.all_of('', 0) end) -- all args must be a match + + assert.is_true(match.all_of(match.is_string())('')) + assert.is_false(match.all_of(match.is_number())('')) + assert.is_false(match.all_of(match.is_number(), match.is_function())('')) + assert.is_false(match.all_of(match.is_number(), match.is_not_function())('')) + assert.is_true(match.not_all_of(match.is_number(), match.is_function())('')) + assert.is_true(match.all_of(match.is_not_number(), match.is_not_function())('')) + end) + +end) diff --git a/tests/busted/src/mocks_spec.tl b/tests/busted/src/mocks_spec.tl new file mode 100644 index 0000000..b607fd8 --- /dev/null +++ b/tests/busted/src/mocks_spec.tl @@ -0,0 +1,54 @@ +describe("Tests dealing with mocks", function() + local test = {} + + before_each(function() + test = { + key = function(_:any):string + return "derp" + end, + foo = { bar = function(_:any):string return "foobar" end } + } + end) + + it("makes sure we're returning the same table", function() + local val = tostring(test) + assert.is_true(type(mock.new(test)) == "table") + assert.is_true(tostring(mock.new(test)) == val) + end) + + it("makes sure function calls are spies", function() + assert.is_true(type(test.key) == "function") + mock.new(test) + assert.is_true(type(test.key) == "table") + assert.is_true(test.key() == "derp") + end) + + it("makes sure function calls are stubs when specified", function() + assert.is_true(type(test.key) == "function") + mock.new(test, true) + assert.is_true(type(test.key) == "table") + assert.is_true(test.key() == nil) + end) + + it("makes sure call history can be cleared", function() + mock.new(test) + test.key() + test.key("test") + test.foo.bar() + test.foo.bar("hello world") + assert.spy(test.key).was_called() + assert.spy(test.foo.bar).was_called() + mock.clear(test) + assert.spy(test.key).was_not_called() + assert.spy(test.foo.bar).was_not_called() + end) + + it("makes sure table can be reverted to pre-mock state", function() + local val = tostring(test) + mock.new(test) + mock.revert(test) + assert.is_true(type(test.key) == "function") + assert.is_true(test.key() == "derp") + assert.is_true(tostring(test) == val) + end) +end) diff --git a/tests/busted/src/spies_spec.tl b/tests/busted/src/spies_spec.tl new file mode 100644 index 0000000..e8486cd --- /dev/null +++ b/tests/busted/src/spies_spec.tl @@ -0,0 +1,238 @@ +local match = require('luassert.match') + +describe("Tests dealing with spies", function() + local record Test + record Foo + bar:{string}|string + end + key:function(any):string + foo:Foo + end + local test:Test = {} + + before_each(function() + assert:set_parameter("TableFormatLevel", 3) + test = { + key = function(_:any):string + return "derp" + end, + foo = { bar = "" } + } + end) + + it("checks if a spy actually executes the internal function", function() + spy.on(test, "key") + assert.is_true(test.key() == "derp") + end) + + it("checks to see if spy keeps track of arguments", function() + spy.on(test, "key") + + test.key("derp") + assert.spy(test.key).was_called_with("derp") + assert.errors(function() assert.spy(test.key).was_called_with("herp") end) + end) + + it("checks to see if spy keeps track of returned arguments", function() + spy.on(test, "key") + + test.key() + assert.spy(test.key).was_returned_with("derp") + assert.errors(function() assert.spy(test.key).was_returned_with("herp") end) + end) + + it("checks to see if spy keeps track of number of calls", function() + spy.on(test, "key") + test.key() + test.key("test") + assert.spy(test.key).was_called(2) + end) + + it("checks returned_with() assertions", function() + local s = spy.new(function(...):any return ... end) + local t:Test = { foo = { bar = { "test" } } } + local _ = match._ + + s(1, 2, 3) + s("a", "b", "c") + s(t) + t.foo.bar = "value" + + assert.spy(s).was_returned_with(1, 2, 3) + assert.spy(s).was_not_returned_with({1, 2, 3}) -- mind the accolades + assert.spy(s).was_returned_with(_, 2, 3) -- matches don't care + assert.spy(s).was_returned_with(_, _, _) -- matches multiple don't cares + assert.spy(s).was_not_returned_with(_, _, _, _) -- does not match if too many args + assert.spy(s).was_returned_with({ foo = { bar = { "test" } } }) -- matches original table + assert.spy(s).was_not_returned_with(t) -- does not match modified table + assert.error_matches( + function() assert.spy(s).returned_with(5, 6) end, + "Function never returned matching arguments.\n" + .. "Returned %(last call if any%):\n" + .. "%(values list%) %(%(table: 0x%x+%) {\n" + .. " %[foo%] = {\n" + .. " %[bar%] = {\n" + .. " %[1%] = 'test' } } }.\n" + .. "Expected:\n" + .. "%(values list%) %(%(number%) 5, %(number%) 6%)") + end) + + it("checks called() and called_with() assertions", function() + local s = spy.new(function() end) + local t:Test = { foo = { bar = { "test" } } } + local _ = match._ + + s(1, 2, 3) + s("a", "b", "c") + s(t) + t.foo.bar = "value" + + assert.spy(s).was_called() + assert.spy(s).was_called(3) -- 3 times! + assert.spy(s).was_not_called(4) + assert.spy(s).was_not_called_with({1, 2, 3}) -- mind the accolades + assert.spy(s).was_called_with(1, 2, 3) + assert.spy(s).was_called_with(_, 2, 3) -- matches don't care + assert.spy(s).was_called_with(_, _, _) -- matches multiple don't cares + assert.spy(s).was_not_called_with(_, _, _, _) -- does not match if too many args + assert.spy(s).was_called_with({ foo = { bar = { "test" } } }) -- matches original table + assert.spy(s).was_not_called_with(t) -- does not match modified table + assert.error_matches( + function() assert.spy(s).was_called_with(5, 6) end, + "Function was never called with matching arguments.\n" + .. "Called with %(last call if any%):\n" + .. "%(values list%) %(%(table: 0x%x+%) {\n" + .. " %[foo%] = {\n" + .. " %[bar%] = {\n" + .. " %[1%] = 'test' } } }%)\n" + .. "Expected:\n" + .. "%(values list%) %(%(number%) 5, %(number%) 6%)") + end) + + it("checks called() and called_with() assertions using refs", function() + local s = spy.new(function() end) + local t1:Test = { foo = { bar = { "test" } } } + local t2:Test = { foo = { bar = { "test" } } } + + s(t1) + t1.foo.bar = "value" + + assert.spy(s).was_called_with(t2) + assert.spy(s).was_not_called_with(match.is_ref(t2)) + assert.spy(s).was_called_with(match.is_ref(t1)) + end) + + it("checks called_with(aspy) assertions", function() + local s = spy.new(function() end) + + s(s) + + assert.spy(s).was_called_with(s) + end) + + it("checks called_at_least() assertions", function() + local s = spy.new(function() end) + + s(1, 2, 3) + s("a", "b", "c") + assert.spy(s).was_called_at_least(1) + assert.spy(s).was_called_at_least(2) + assert.spy(s).was_not_called_at_least(3) + assert.error_matches( + function() assert.spy(s).was_called_at_least() end, + "attempt to compare nil with number") + end) + + it("checks called_at_most() assertions", function() + local s = spy.new(function() end) + + s(1, 2, 3) + s("a", "b", "c") + assert.spy(s).was_called_at_most(3) + assert.spy(s).was_called_at_most(2) + assert.spy(s).was_not_called_at_most(1) + assert.error_matches( + function() assert.spy(s).was_called_at_most() end, + "attempt to compare number with nil") + end) + + it("checks called_more_than() assertions", function() + local s = spy.new(function() end) + + s(1, 2, 3) + s("a", "b", "c") + assert.spy(s).was_called_more_than(0) + assert.spy(s).was_called_more_than(1) + assert.spy(s).was_not_called_more_than(2) + assert.error_matches( + function() assert.spy(s).was_called_more_than() end, + "attempt to compare nil with number") + end) + + it("checks called_less_than() assertions", function() + local s = spy.new(function() end) + + s(1, 2, 3) + s("a", "b", "c") + assert.spy(s).was_called_less_than(4) + assert.spy(s).was_called_less_than(3) + assert.spy(s).was_not_called_less_than(2) + assert.error_matches( + function() assert.spy(s).was_called_less_than() end, + "attempt to compare number with nil") + end) + + it("checks reverting a spy.on call", function() + local old = test.key + local s = spy.on(test, "key") + test.key() + test.key("test") + assert.spy(test.key).was_called(2) + -- revert and call again + s:revert() + assert.are_equal(old, test.key) + test.key() + test.key("test") + assert.spy(s).was_called(2) -- still two, spy was removed + end) + + it("checks reverting a spy.new call", function() + local calls = 0 + local old = function() calls = calls + 1 end + local s = spy.new(old) + assert.is_table(s) + s() + s() + assert.spy(s).was_called(2) + assert.are_equal(calls, 2) + local old_s = s + s = s:revert() + assert.are_equal(s, old) + s() + assert.spy(old_s).was_called(2) -- still two, spy was removed + assert.are_equal(calls, 3) + end) + + it("checks clearing a spy.on call history", function() + local s = spy.on(test, "key") + test.key() + test.key("test") + s:clear() + assert.spy(s).was_called(0) + end) + + it("checks clearing a spy.new call history", function() + local s = spy.new(function():string return "foobar" end) + s() + s("test") + s:clear() + assert.spy(s).was_called(0) + assert.spy(s).was_not_returned_with("foobar") + end) + + it("checks spy.new can be constructed without arguments", function() + local s = spy.new() + s() + assert.spy(s).was_called(1) + end) +end) diff --git a/tests/busted/src/stub_spec.tl b/tests/busted/src/stub_spec.tl new file mode 100644 index 0000000..2d485ad --- /dev/null +++ b/tests/busted/src/stub_spec.tl @@ -0,0 +1,206 @@ +local match = require 'luassert.match' + +describe("Tests dealing with stubs", function() + local record Test + record Foo + bar:{string}|string + end + key:function(any):any + foo:Foo + end + local test:Test = {} + + before_each(function() + test = { + key = function(_:any):string + return "derp" + end + } + end) + + it("checks to see if stub keeps track of arguments", function() + stub(test, "key") + test.key("derp") + assert.stub(test.key).was_called_with("derp") + end) + + it("checks to see if stub keeps track of number of calls", function() + stub(test, "key") + test.key() + test.key("test") + assert.stub(test.key).was_called(2) + end) + + it("checks called() and called_with() assertions", function() + local s = stub.new(test, "key") + + s(1, 2, 3) + s("a", "b", "c") + assert.stub(s).was_called() + assert.stub(s).was_called(2) -- twice! + assert.stub(s).was_not_called(3) + assert.stub(s).was_not_called_with({1, 2, 3}) -- mind the accolades + assert.stub(s).was_called_with(1, 2, 3) + end) + + it("checks reverting a stub call", function() + local calls = 0 + local old = function(_:any):string calls = calls + 1 end + test.key = old + local s = stub.new(test, "key") + assert.is_table(s) + s() + s() + assert.stub(s).was_called(2) + assert.are_equal(calls, 0) -- its a stub, so no calls + local old_s = s + s = s:revert() + s() + assert.stub(old_s).was_called(2) -- still two, stub was removed + assert.are_equal(s, old) + assert.are_equal(calls, 1) -- restored, so now 1 call + end) + + it("checks reverting a stub call on a nil value", function() + test = {} + local s = stub.new(test, "key") + assert.is_table(s) + s() + s() + assert.stub(s).was_called(2) + s = s:revert() + assert.is_nil(s) + end) + + it("checks creating and reverting a 'blank' stub", function() + local s = stub.new() -- use no parameters to create a blank + assert.is_table(s) + s() + s() + assert.stub(s).was_called(2) + s = s:revert() + assert.is_nil(s) + end) + + it("checks clearing a stub only clears call history", function() + local s = stub.new(test, "key") + s.returns("value") + s.on_call_with("foo").returns("bar") + s() + s("foo") + s:clear() + assert.stub(s).was_not_called() + assert.stub(s).was_not_returned_with("value") + assert.stub(s).was_not_returned_with("bar") + s("foo") + assert.stub(s).was_returned_with("bar") + end) + + it("returns nil by default", function() + stub(test, "key") + + assert.is_nil(test.key()) + end) + + it("returns a given return value", function() + stub(test, "key", "foo") + + assert.is_equal("foo", test.key()) + end) + + it("returns default stub arguments", function() + stub.new(test, "key").returns("foo") + + local arg1 = test.key("bar") + + assert.is_equal("foo", arg1) + end) + + it("invokes default stub function", function() + stub.new(test, "key").invokes(function(a:string):string + return a .. "_x" + end) + + local arg1 = test.key("bar") + + assert.is_equal("bar_x", arg1) + end) + + it("returns stub arguments by default", function() + stub.new(test, "key").by_default.returns("foo") + + local arg1 = test.key() + + assert.is_equal("foo", arg1) + end) + + it("invokes stub function by default", function() + stub.new(test, "key").by_default.invokes(function(a:string):string + return a .. "_x" + end) + + local arg1 = test.key("bar") + + assert.is_equal("bar_x", arg1) + end) + + it("on_call_with invokes stub function", function() + local s = stub.new(test, "key").returns("foo foo") + + s.on_call_with("foo").invokes(function(_:string):string + return "bar" + end) + + local arg1 = test.key("foo") + local foo = test.key() + + assert.is_equal("bar", arg1) + assert.is_equal("foo foo", foo) + end) + + it("on_call_with matches arguments for returns", function() + local t:Test = { foo = { bar = { "test" } } } + local s = stub.new(test, "key").returns("foo foo") + s.on_call_with(t).returns("bar") + t.foo.bar = "value" + + local bar = test.key({ foo = { bar = { "test" } } }) + local foofoo = test.key(t) + + assert.is_equal("bar", bar) + assert.is_equal("foo foo", foofoo) + end) + + it("on_call_with matches arguments for invokes", function() + local t:Test = { foo = { bar = { "test" } } } + local s = stub.new(test, "key").returns("foo foo") + s.on_call_with(t).invokes(function():string return "bar bar" end) + t.foo.bar = "value" + + local bar = test.key({ foo = { bar = { "test" } } }) + local foofoo = test.key(t) + + assert.is_equal("bar bar", bar) + assert.is_equal("foo foo", foofoo) + end) + + it("on_call_with matches arguments using refs", function() + local t1:Test = { foo = { bar = { "test" } } } + local t2:Test = { foo = { bar = { "test" } } } + local s = stub.new(test, "key").returns("foo foo") + + s.on_call_with(match.is_ref(t1)).returns("bar") + + t1.foo.bar = "value" + t2.foo.bar = "value" + + local bar = test.key(t1) + local foo = test.key(t2) + local foofoo = test.key({ foo = { bar = { "test" } } }) + + assert.is_equal("bar", bar) + assert.is_equal("foo foo", foo) + assert.is_equal("foo foo", foofoo) + end) + +end) diff --git a/tests/src/teal_type_tests/test_module.tl b/tests/busted/src/test_module.tl similarity index 100% rename from tests/src/teal_type_tests/test_module.tl rename to tests/busted/src/test_module.tl diff --git a/tests/tlconfig.lua b/tests/busted/tlconfig.lua similarity index 75% rename from tests/tlconfig.lua rename to tests/busted/tlconfig.lua index ee06c49..9b813d7 100644 --- a/tests/tlconfig.lua +++ b/tests/busted/tlconfig.lua @@ -1,5 +1,6 @@ return { build_dir = "build", source_dir = "src", + include_dir = { "src" }, global_env_def = "busted" } diff --git a/tests/src/teal_type_tests/busted_spec.tl b/tests/src/teal_type_tests/busted_spec.tl deleted file mode 100644 index b8bbab5..0000000 --- a/tests/src/teal_type_tests/busted_spec.tl +++ /dev/null @@ -1,314 +0,0 @@ - --- The following code was just copied from the busted docs, and converted --- from lua to teal --- We include this here just to ensure our busted type hints work - -describe("Busted unit testing framework", function() - describe("should be awesome", function() - it("should be easy to use", function() - assert.truthy("Yup.") - end) - - it("should have lots of features", function() - -- deep check comparisons! - assert.are_same({ table = "great"}, { table = "great" }) - - -- or check by reference! - assert.are_not_equal({ table = "great"}, { table = "great"}) - - assert.truthy("this is a string") -- truthy: not false or nil - - assert.True(1 == 1) - assert.is_true(1 == 1) - - assert.falsy(nil) - assert.has_error(function() error("Wat") end, "Wat") - end) - - it("should provide some shortcuts to common functions", function() - assert.are_unique({{ thing = 1 }, { thing = 2 }, { thing = 3 }}) - end) - - it("should have mocks and spies for functional tests", function() - -- local test_module = require("test_module") - -- spy.on(test_module, "greet") - -- test_module.greet("Hi!") - - -- assert.spy(test_module.greet).was_called() - -- assert.spy(test_module.greet).was_called_with("Hi!") - end) - end) -end) - -describe("busted", function() - local obj1:any - local obj2:any - local test_module:any - - setup(function() - -- test_module = require("test_module") - end) - - teardown(function() - test_module = nil - end) - - before_each(function() - obj1 = { test = "yes" } - obj2 = { test = "yes" } - end) - - it("sets up vars with the before_each", function() - obj2 = { test = "no" } - assert.are_not_same(obj1, obj2) - end) - - it("sets up vars with the before_each", function() - -- obj2 is reset thanks to the before_each - assert.same(obj1, obj2) - end) - - describe("nested", function() - it("also runs the before_each here", function() - -- if this describe also had a before_each, it would run - -- both, starting with the parents'. You can go n-deep. - end) - end) -end) - -describe("finally test", function() - it('checks file contents',function() - local f = io.popen('echo 5') - - -- ensure that once test has finished f:close() is called - -- independent of test outcome - finally(function() f:close() end) - - -- do things with f - end) -end) - -describe("busted pending tests", function() - it("example", function() - pending("I should finish this test later") - end) -end) - -describe("some assertions", function() - it("tests positive assertions", function() - assert.is_true(true) -- Lua keyword chained with _ - assert.True(true) -- Lua keyword using a capital - assert.are_equal(1, 1) - assert.has_errors(function() error("this should fail") end) - end) - - it("tests negative assertions", function() - assert.is_not_true(false) - assert.are_not_equals(1, "1") - assert.has_no_errors(function() end) - end) - - it("checks if they're equals", function() - local expected = 1 - local obj = expected - - assert.are_equals(expected, obj) - end) - - it("checks if they're the same", function() - local expected = { name = "Jack" } - local obj = { name = "Jack" } - - assert.are_same(expected, obj) - end) - - it("checks true", function() - assert.is_true(true) - assert.is_not_true("Yes") - assert.is_truthy("Yes") - end) - - it("checks false", function() - assert.is_false(false) - assert.is_not_false(nil) - assert.is_falsy(nil) - end) - - it("should throw an error", function() - assert.has_error(function() error("Yup, it errored") end) - assert.has_no_errors(function() end) - end) - - it("should throw the error we expect", function() - local errfn = function() - error("DB CONN ERROR") - end - - assert.has_error(errfn, "DB CONN ERROR") - end) -end) - -describe("spies", function() - it("registers a new spy as a callback", function() - local s = spy.new(function() end) - - s(1, 2, 3) - s(4, 5, 6) - - assert.spy(s).was_called() - assert.spy(s).was_called(2) -- twice! - assert.spy(s).was_called_with(1, 2, 3) -- checks the history - end) - - it("replaces an original function", function() - local t = { - greet = function(msg:string) print(msg) end - } - - local s = spy.on(t, "greet") - - t.greet("Hey!") -- prints 'Hey!' - assert.spy(t.greet).was_called_with("Hey!") - - s:clear() -- clears the call history - assert.spy(s).was_not_called_with("Hey!") - - s:revert() -- reverts the stub - t.greet("Hello!") -- prints 'Hello!', will not pass through the spy - assert.spy(s).was_not_called_with("Hello!") - end) -end) - -describe("stubs", function() - it("replaces an original function", function() - local t = { - greet = function(msg:string) print(msg) end - } - - local greet_stub = stub(t, "greet") - - t.greet("Hey!") -- DOES NOT print 'Hey!' - assert.stub(t.greet).was_called_with("Hey!") - - greet_stub:revert() -- reverts the stub - t.greet("Hey!") -- DOES print 'Hey!' - end) -end) - -describe("mocks", function() - it("replaces a table with spies", function() - local t = { - thing = function(msg:string) print(msg) end - } - - local m = mock.new(t) -- mocks the table with spies, so it will print - - m.thing("Coffee") - assert.spy(m.thing).was_called_with("Coffee") - end) - - it("replaces a table with stubs", function() - local t = { - thing = function(msg:string) print(msg) end - } - - local m = mock.new(t, true) -- mocks the table with stubs, so it will not print - - m.thing("Coffee") - assert.stub(m.thing).was_called_with("Coffee") - - mock.revert(m) -- reverts all stubs/spies in m - m.thing("Tea") -- DOES print 'Tea' - end) -end) - -describe("match arguments", function() - local match = require("luassert.match") - - it("tests wildcard matcher", function() - local s = spy.new(function() end) - local _ = match._ - - s("foo") - - assert.spy(s).was_called_with(_) -- matches any argument - assert.spy(s).was_not_called_with(_, _) -- does not match two arguments - end) - - it("tests type matchers", function() - local s = spy.new(function() end) - - s("foo") - - assert.spy(s).was_called_with(match.is_string()) - assert.spy(s).was_called_with(match.is_truthy()) - assert.spy(s).was_called_with(match.is_not_nil()) - assert.spy(s).was_called_with(match.is_not_false()) - assert.spy(s).was_called_with(match.is_not_number()) - assert.spy(s).was_called_with(match.is_not_table()) - end) - - it("tests more matchers", function() - local s = spy.new(function() end) - - s(1) - - assert.spy(s).was_called_with(match.is_equal(1)) - assert.spy(s).was_called_with(match.is_same(1)) - end) -end) - -describe("combine matchers", function() - local match = require("luassert.match") - - it("tests ref matchers for passed in table", function() - local record Foo - cnt:integer - incrby:function(t:Foo, i:integer) - end - - local t:Foo = { - cnt = 0, - incrby = function(t:Foo, i:integer) t.cnt = t.cnt + i end - } - - local s = spy.on(t, "incrby") - - s(t, 2) - - assert.spy(s).was_called_with(match.is_ref(t), 2) - end) - - it("tests ref matchers for self", function() - local record Foo - cnt:integer - incrby:function(t:Foo, i:integer) - end - - local t:Foo = { - cnt = 0, - incrby = function(t:Foo, i:integer) t.cnt = t.cnt + i end - } - - local s = spy.on(t, "incrby") - - t:incrby(2) - - assert.spy(s).was_called_with(match.is_ref(t), 2) - end) -end) - -describe("combine matchers", function() - local match = require("luassert.match") - - it("tests composite matchers", function() - local s = spy.new(function() end) - - s("foo") - - assert.spy(s).was_called_with(match.is_all_of(match.is_not_nil(), match.is_not_number())) - assert.spy(s).was_called_with(match.is_any_of(match.is_number(), match.is_string(), match.is_boolean())) - assert.spy(s).was_called_with(match.is_none_of(match.is_number(), match.is_table(), match.is_boolean())) - end) -end) - diff --git a/types/busted/busted.d.tl b/types/busted/busted.d.tl index eedf20c..e48d114 100644 --- a/types/busted/busted.d.tl +++ b/types/busted/busted.d.tl @@ -13,84 +13,4 @@ global randomize: function() global finally: function(function()) global pending: function(string) -global record mock - revert:function(any) - - new:function(T, boolean):T -end - -local record Stub - was_called:function(string) - was_not_called:function(string) - - was_called_with:function(any, string) - was_not_called_with:function(any, string) - - revert:function(self:Stub) -end - -global stub: function(any, string):Stub - -local record Spy - was_called:function(integer) - was_not_called:function() - - was_called_with:function(...:any) - was_not_called_with:function(...:any) - - clear:function(self:Spy) - revert:function(self:Spy) - - metamethod __call: function(self: Spy, ...:any) -end - -global record spy - on:function(any, any):Spy - new:function(function()):Spy -end - -global record assert - is_not_true:function(any, string) - is_true:function(any, string) - True:function(any, string) - - is_not_false:function(any, string) - is_false:function(any, string) - False:function(any, string) - - is_nil:function(any, string) - is_not_nil:function(any, string) - - is_truthy:function(any, string) - truthy:function(any, string) - - is_falsy:function(any, string) - falsy:function(any, string) - - has_property:function(any, string, string) - - same:function(any, any, string) - - are_not_same:function(any, any, string) - are_not_equal:function(any, any, string) - are_not_equals:function(any, any, string) - - are_same:function(any, any, string) - are_equal:function(any, any, string) - are_equals:function(any, any, string) - - are_unique:function(any, any, string) - are_not_unique:function(any, any, string) - - error:function(function(), string) - - has_no_errors:function(function(), string) - has_error:function(function(), string) - has_errors:function(function(), string) - - has_holes:function({any}, string) - has_no_holes:function({any}, string) - - spy:function(any):Spy - stub:function(any):Stub -end +require("luassert") diff --git a/types/luaassert/luassert.d.tl b/types/luaassert/luassert.d.tl new file mode 100644 index 0000000..5a2257b --- /dev/null +++ b/types/luaassert/luassert.d.tl @@ -0,0 +1,236 @@ + +global record mock + clear:function(any) + revert:function(any) + + new:function(T, boolean):T +end + +global record stub + record Defaults + returns:function(...:any) + invokes:function(function(...:any)) + end + + record OnCallWith + returns:function(...:any) + invokes:function(function(...:any)) + end + + clear:function(self:stub):stub + revert:function(self:stub):stub + + on_call_with:function(...:any):OnCallWith + + returns:function(...:any):stub + invokes:function(function(...:any)):stub + + -- table, key, return values + new:function(any, string, ...:any):stub + + by_default:Defaults + + metamethod __call: function(self: stub, ...:any) +end + +global record spy + clear:function(self:spy):spy + revert:function(self:spy):spy + + on:function(any, string):spy + new:function(function(...:any)):spy + + metamethod __call: function(self: spy, ...:any) +end + +local record Callable + metamethod __call: function(self: Callable) +end + +local record ArrayAssert + has_holes:function(integer) + has_no_holes:function() +end + +local record SpyAssert + was_called:function(integer) + was_not_called:function(integer) + + was_called_with:function(...:any) + was_not_called_with:function(...:any) + + was_returned_with:function(...:any) + was_not_returned_with:function(...:any) + + was_called_at_least:function(integer) + was_called_at_most:function(integer) + was_called_more_than:function(integer) + was_called_less_than:function(integer) + + was_not_called_at_least:function(integer) + was_not_called_at_most:function(integer) + was_not_called_more_than:function(integer) + was_not_called_less_than:function(integer) + + called:function(integer) + not_called:function() + + called_with:function(...:any) + not_called_with:function(...:any) + + returned_with:function(...:any) + not_returned_with:function(...:any) + + called_at_least:function(integer) + called_at_most:function(integer) + called_more_than:function(integer) + called_less_than:function(integer) +end + +global record assert + -- True / false + is_not_true:function(any, string):any, string + is_true:function(any, string):any, string + + is_not_false:function(any, string):any, string + is_false:function(any, string):any, string + + is_not_truthy:function(any, string):any, string + is_truthy:function(any, string):any, string + + truthy:function(any, string):any, string + not_truthy:function(any, string):any, string + + is_not_falsy:function(any, string):any, string + is_falsy:function(any, string):any, string + + falsy:function(any, string):any, string + not_falsy:function(any, string):any, string + + -- Same-ness + same:function(any, any, string):any, any, string + + is_same:function(any, any, string):any, any, string + is_not_same:function(any, any, string):any, any, string + + are_same:function(any, any, string):any, any, string + are_not_same:function(any, any, string):any, any, string + + -- Equality + are_not_equal:function(any, any, string):any, any, string + are_not_equals:function(any, any, string):any, any, string + + is_not_equal:function(any, any, string):any, any, string + is_not_equals:function(any, any, string):any, any, string + + equal:function(any, any, string):any, any, string + equals:function(any, any, string):any, any, string + + not_equals:function(any, any, string):any, any, string + not_equal:function(any, any, string):any, any, string + + equals_not:function(any, any, string):any, any, string + equal_not:function(any, any, string):any, any, string + + is_equal:function(any, any, string):any, any, string + is_equals:function(any, any, string):any, any, string + + are_equal:function(any, any, string):any, any, string + are_equals:function(any, any, string):any, any, string + + -- Nearness + is_near:function(number, number, number, string):number, number, number, string + is_not_near:function(number, number, number, string):number, number, number, string + + -- Uniqueness + is_unique:function({any}, string):{any}, string + is_not_unique:function({any}, string):{any}, string + + are_unique:function({any}, string):{any}, string + are_not_unique:function({any}, string):{any}, string + + -- Errors function + is_error:function(function(), any, string):{any} + error:function(function(), any, string):{any} + errors:function(function(), any, string):{any} + + no_errors:function(function(), any, string):{any} + + has_no_errors:function(function(), any, string):{any} + has_no_error:function(function(), any, string):{any} + + has_error:function(function(), any, string):{any} + has_errors:function(function(), any, string):{any} + + -- Errors Callable + is_error:function(Callable, any, string):{any} + error:function(Callable, any, string):{any} + errors:function(Callable, any, string):{any} + + no_errors:function(Callable, any, string):{any} + + has_no_errors:function(Callable, any, string):{any} + has_no_error:function(Callable, any, string):{any} + + has_error:function(Callable, any, string):{any} + has_errors:function(Callable, any, string):{any} + + -- matches + matches:function(string, string, string) + + has_match:function(string, string, string):{string} + has_no_match:function(string, string, string):{string} + + does_error_match:function(any, string, string) + matches_error:function(any, string, string) + has_no_error_match:function(any, string, string) + does_not_match_error:function(any, string, string) + + error_matches:function(any, string, string):{any} + no_error_matches:function(any, string, string):{any} + + -- type checking + is_boolean:function(any, string):any, string + is_not_boolean:function(any, string):any, string + + is_number:function(any, string):any, string + is_not_number:function(any, string):any, string + + is_string:function(any, string):any, string + is_not_string:function(any, string):any, string + + is_table:function(any, string):any, string + is_not_table:function(any, string):any, string + + is_function:function(any, string):any, string + is_not_function:function(any, string):any, string + + is_userdata:function(any, string):any, string + is_not_userdata:function(any, string):any, string + + is_thread:function(any, string):any, string + is_not_thread:function(any, string):any, string + + is_nil:function(any, string):any, string + is_not_nil:function(any, string):any, string + + -- misc + set_parameter:function(self:assert, string, integer) + + returned_arguments:function(...:any) + not_returned_arguments:function(...:any) + + has_holes:function({any}) + has_no_holes:function({any}) + + array:function({any}):ArrayAssert + + spy:function(any):SpyAssert + stub:function(any):SpyAssert + + get_level:function(self:assert, any) + level:function(self:assert, integer) + + has_property:function(any, string) +end + diff --git a/types/luaassert/luassert/match.d.tl b/types/luaassert/luassert/match.d.tl index 46fb526..88b141b 100644 --- a/types/luaassert/luassert/match.d.tl +++ b/types/luaassert/luassert/match.d.tl @@ -1,21 +1,102 @@ +local record Matcher + metamethod __call: function(self: Matcher, any) +end + local record match - _:any - is_string:function() - is_truthy:function() - is_not_nil:function() - is_not_false:function() - is_not_number:function() - is_not_table:function() - is_equal:function(any) - is_same:function(any) - is_ref:function(any) - is_boolean:function(any) - is_table:function(any) - is_number:function() - is_all_of:function(...:any) - is_any_of:function(...:any) - is_none_of:function(...:any) + _:function(any) + + match:function(any):Matcher + + -- truthiness + is_true:function():Matcher + is_false:function():Matcher + + is_not_true:function():Matcher + is_not_false:function():Matcher + + is_truthy:function():Matcher + is_falsy:function():Matcher + + is_not_truthy:function():Matcher + is_not_falsy:function():Matcher + + not_false:function():Matcher + + truthy:function():Matcher + falsy:function():Matcher + + -- type matching + is_boolean:function(any):Matcher + is_function:function():Matcher + is_nil:function():Matcher + is_number:function():Matcher + is_string:function():Matcher + is_table:function(any):Matcher + is_thread:function():Matcher + is_ref:function(any):Matcher + is_userdata:function():Matcher + + boolean:function(any):Matcher + number:function():Matcher + string:function():Matcher + table:function(any):Matcher + thread:function():Matcher + userdata:function():Matcher + ref:function():Matcher + + not_boolean:function(any):Matcher + not_function:function():Matcher + not_nil:function():Matcher + not_number:function():Matcher + not_string:function():Matcher + not_table:function(any):Matcher + not_thread:function():Matcher + not_userdata:function():Matcher + not_ref:function():Matcher + + is_not_boolean:function(any):Matcher + is_not_function:function():Matcher + is_not_nil:function():Matcher + is_not_number:function():Matcher + is_not_string:function():Matcher + is_not_table:function(any):Matcher + is_not_thread:function():Matcher + is_not_userdata:function():Matcher + is_not_ref:function():Matcher + + -- equality + is_equals:function():Matcher + is_equal:function(any):Matcher + is_same:function(any):Matcher + + equals:function(any):Matcher + equal:function(any):Matcher + same:function(any):Matcher + + is_unique:function():Matcher + is_not_unique:function():Matcher + + -- group matching + is_all_of:function(...:any):Matcher + is_any_of:function(...:any):Matcher + is_none_of:function(...:any):Matcher + + all_of:function(...:any):Matcher + any_of:function(...:any):Matcher + none_of:function(...:any):Matcher + + not_all_of:function(...:any):Matcher + not_any_of:function(...:any):Matcher + not_none_of:function(...:any):Matcher + + -- misc + matches:function(string, number):Matcher + has_match:function(string, number):Matcher + + near:function(number, number):Matcher + is_near:function(number, number):Matcher + is_not_near:function(number, number):Matcher end return match diff --git a/types/penlight/pl/init.d.tl b/types/penlight/pl.d.tl similarity index 100% rename from types/penlight/pl/init.d.tl rename to types/penlight/pl.d.tl diff --git a/types/penlight/pl/tablex.d.tl b/types/penlight/pl/tablex.d.tl index 86b80a6..4569a8d 100644 --- a/types/penlight/pl/tablex.d.tl +++ b/types/penlight/pl/tablex.d.tl @@ -1 +1 @@ -return require "pl".tablex +return require("pl").tablex diff --git a/types/say/say.d.tl b/types/say/say.d.tl new file mode 100644 index 0000000..917e16c --- /dev/null +++ b/types/say/say.d.tl @@ -0,0 +1,9 @@ + +local record say + set_namespace:function(self:say, string) + set:function(self:say, string, string) + + metamethod __call: function(self: say, string, {any}) +end + +return say From b3dbdd14a952dd46d6339888a89f03e6545b9c70 Mon Sep 17 00:00:00 2001 From: Steve Vermeulen Date: Sun, 3 Apr 2022 17:14:09 -0700 Subject: [PATCH 5/9] Added some more missing type info --- types/luaassert/luassert.d.tl | 236 +-------------------------- types/luaassert/luassert/assert.d.tl | 194 ++++++++++++++++++++++ types/luaassert/luassert/mock.d.tl | 9 + types/luaassert/luassert/spy.d.tl | 14 ++ types/luaassert/luassert/stub.d.tl | 29 ++++ types/neovim/template | 23 +++ types/neovim/vim.d.tl | 23 +++ 7 files changed, 293 insertions(+), 235 deletions(-) create mode 100644 types/luaassert/luassert/assert.d.tl create mode 100644 types/luaassert/luassert/mock.d.tl create mode 100644 types/luaassert/luassert/spy.d.tl create mode 100644 types/luaassert/luassert/stub.d.tl diff --git a/types/luaassert/luassert.d.tl b/types/luaassert/luassert.d.tl index 5a2257b..759b8c4 100644 --- a/types/luaassert/luassert.d.tl +++ b/types/luaassert/luassert.d.tl @@ -1,236 +1,2 @@ -global record mock - clear:function(any) - revert:function(any) - - new:function(T, boolean):T -end - -global record stub - record Defaults - returns:function(...:any) - invokes:function(function(...:any)) - end - - record OnCallWith - returns:function(...:any) - invokes:function(function(...:any)) - end - - clear:function(self:stub):stub - revert:function(self:stub):stub - - on_call_with:function(...:any):OnCallWith - - returns:function(...:any):stub - invokes:function(function(...:any)):stub - - -- table, key, return values - new:function(any, string, ...:any):stub - - by_default:Defaults - - metamethod __call: function(self: stub, ...:any) -end - -global record spy - clear:function(self:spy):spy - revert:function(self:spy):spy - - on:function(any, string):spy - new:function(function(...:any)):spy - - metamethod __call: function(self: spy, ...:any) -end - -local record Callable - metamethod __call: function(self: Callable) -end - -local record ArrayAssert - has_holes:function(integer) - has_no_holes:function() -end - -local record SpyAssert - was_called:function(integer) - was_not_called:function(integer) - - was_called_with:function(...:any) - was_not_called_with:function(...:any) - - was_returned_with:function(...:any) - was_not_returned_with:function(...:any) - - was_called_at_least:function(integer) - was_called_at_most:function(integer) - was_called_more_than:function(integer) - was_called_less_than:function(integer) - - was_not_called_at_least:function(integer) - was_not_called_at_most:function(integer) - was_not_called_more_than:function(integer) - was_not_called_less_than:function(integer) - - called:function(integer) - not_called:function() - - called_with:function(...:any) - not_called_with:function(...:any) - - returned_with:function(...:any) - not_returned_with:function(...:any) - - called_at_least:function(integer) - called_at_most:function(integer) - called_more_than:function(integer) - called_less_than:function(integer) -end - -global record assert - -- True / false - is_not_true:function(any, string):any, string - is_true:function(any, string):any, string - - is_not_false:function(any, string):any, string - is_false:function(any, string):any, string - - is_not_truthy:function(any, string):any, string - is_truthy:function(any, string):any, string - - truthy:function(any, string):any, string - not_truthy:function(any, string):any, string - - is_not_falsy:function(any, string):any, string - is_falsy:function(any, string):any, string - - falsy:function(any, string):any, string - not_falsy:function(any, string):any, string - - -- Same-ness - same:function(any, any, string):any, any, string - - is_same:function(any, any, string):any, any, string - is_not_same:function(any, any, string):any, any, string - - are_same:function(any, any, string):any, any, string - are_not_same:function(any, any, string):any, any, string - - -- Equality - are_not_equal:function(any, any, string):any, any, string - are_not_equals:function(any, any, string):any, any, string - - is_not_equal:function(any, any, string):any, any, string - is_not_equals:function(any, any, string):any, any, string - - equal:function(any, any, string):any, any, string - equals:function(any, any, string):any, any, string - - not_equals:function(any, any, string):any, any, string - not_equal:function(any, any, string):any, any, string - - equals_not:function(any, any, string):any, any, string - equal_not:function(any, any, string):any, any, string - - is_equal:function(any, any, string):any, any, string - is_equals:function(any, any, string):any, any, string - - are_equal:function(any, any, string):any, any, string - are_equals:function(any, any, string):any, any, string - - -- Nearness - is_near:function(number, number, number, string):number, number, number, string - is_not_near:function(number, number, number, string):number, number, number, string - - -- Uniqueness - is_unique:function({any}, string):{any}, string - is_not_unique:function({any}, string):{any}, string - - are_unique:function({any}, string):{any}, string - are_not_unique:function({any}, string):{any}, string - - -- Errors function - is_error:function(function(), any, string):{any} - error:function(function(), any, string):{any} - errors:function(function(), any, string):{any} - - no_errors:function(function(), any, string):{any} - - has_no_errors:function(function(), any, string):{any} - has_no_error:function(function(), any, string):{any} - - has_error:function(function(), any, string):{any} - has_errors:function(function(), any, string):{any} - - -- Errors Callable - is_error:function(Callable, any, string):{any} - error:function(Callable, any, string):{any} - errors:function(Callable, any, string):{any} - - no_errors:function(Callable, any, string):{any} - - has_no_errors:function(Callable, any, string):{any} - has_no_error:function(Callable, any, string):{any} - - has_error:function(Callable, any, string):{any} - has_errors:function(Callable, any, string):{any} - - -- matches - matches:function(string, string, string) - - has_match:function(string, string, string):{string} - has_no_match:function(string, string, string):{string} - - does_error_match:function(any, string, string) - matches_error:function(any, string, string) - has_no_error_match:function(any, string, string) - does_not_match_error:function(any, string, string) - - error_matches:function(any, string, string):{any} - no_error_matches:function(any, string, string):{any} - - -- type checking - is_boolean:function(any, string):any, string - is_not_boolean:function(any, string):any, string - - is_number:function(any, string):any, string - is_not_number:function(any, string):any, string - - is_string:function(any, string):any, string - is_not_string:function(any, string):any, string - - is_table:function(any, string):any, string - is_not_table:function(any, string):any, string - - is_function:function(any, string):any, string - is_not_function:function(any, string):any, string - - is_userdata:function(any, string):any, string - is_not_userdata:function(any, string):any, string - - is_thread:function(any, string):any, string - is_not_thread:function(any, string):any, string - - is_nil:function(any, string):any, string - is_not_nil:function(any, string):any, string - - -- misc - set_parameter:function(self:assert, string, integer) - - returned_arguments:function(...:any) - not_returned_arguments:function(...:any) - - has_holes:function({any}) - has_no_holes:function({any}) - - array:function({any}):ArrayAssert - - spy:function(any):SpyAssert - stub:function(any):SpyAssert - - get_level:function(self:assert, any) - level:function(self:assert, integer) - - has_property:function(any, string) -end - +return require("luassert.assert") diff --git a/types/luaassert/luassert/assert.d.tl b/types/luaassert/luassert/assert.d.tl new file mode 100644 index 0000000..6f1884c --- /dev/null +++ b/types/luaassert/luassert/assert.d.tl @@ -0,0 +1,194 @@ + +local record ArrayAssert + has_holes:function(integer) + has_no_holes:function() +end + +local record SpyAssert + was_called:function(integer) + was_not_called:function(integer) + + was_called_with:function(...:any) + was_not_called_with:function(...:any) + + was_returned_with:function(...:any) + was_not_returned_with:function(...:any) + + was_called_at_least:function(integer) + was_called_at_most:function(integer) + was_called_more_than:function(integer) + was_called_less_than:function(integer) + + was_not_called_at_least:function(integer) + was_not_called_at_most:function(integer) + was_not_called_more_than:function(integer) + was_not_called_less_than:function(integer) + + called:function(integer) + not_called:function() + + called_with:function(...:any) + not_called_with:function(...:any) + + returned_with:function(...:any) + not_returned_with:function(...:any) + + called_at_least:function(integer) + called_at_most:function(integer) + called_more_than:function(integer) + called_less_than:function(integer) +end + +-- We use asserts instead of assert here to avoid tl warning +local record asserts + -- True / false + is_not_true:function(any, string):any, string + is_true:function(any, string):any, string + + is_not_false:function(any, string):any, string + is_false:function(any, string):any, string + + is_not_truthy:function(any, string):any, string + is_truthy:function(any, string):any, string + + truthy:function(any, string):any, string + not_truthy:function(any, string):any, string + + is_not_falsy:function(any, string):any, string + is_falsy:function(any, string):any, string + + falsy:function(any, string):any, string + not_falsy:function(any, string):any, string + + -- Same-ness + same:function(any, any, string):any, any, string + + is_same:function(any, any, string):any, any, string + is_not_same:function(any, any, string):any, any, string + + are_same:function(any, any, string):any, any, string + are_not_same:function(any, any, string):any, any, string + + -- Equality + are_not_equal:function(any, any, string):any, any, string + are_not_equals:function(any, any, string):any, any, string + + is_not_equal:function(any, any, string):any, any, string + is_not_equals:function(any, any, string):any, any, string + + equal:function(any, any, string):any, any, string + equals:function(any, any, string):any, any, string + + not_equals:function(any, any, string):any, any, string + not_equal:function(any, any, string):any, any, string + + equals_not:function(any, any, string):any, any, string + equal_not:function(any, any, string):any, any, string + + is_equal:function(any, any, string):any, any, string + is_equals:function(any, any, string):any, any, string + + are_equal:function(any, any, string):any, any, string + are_equals:function(any, any, string):any, any, string + + -- Nearness + is_near:function(number, number, number, string):number, number, number, string + is_not_near:function(number, number, number, string):number, number, number, string + + -- Uniqueness + is_unique:function({any}, string):{any}, string + is_not_unique:function({any}, string):{any}, string + + are_unique:function({any}, string):{any}, string + are_not_unique:function({any}, string):{any}, string + + -- Errors function + is_error:function(function(), any, string):{any} + error:function(function(), any, string):{any} + errors:function(function(), any, string):{any} + + no_errors:function(function(), any, string):{any} + + has_no_errors:function(function(), any, string):{any} + has_no_error:function(function(), any, string):{any} + + has_error:function(function(), any, string):{any} + has_errors:function(function(), any, string):{any} + + record Callable + metamethod __call: function(self: Callable) + end + + -- Errors Callable + is_error:function(Callable, any, string):{any} + error:function(Callable, any, string):{any} + errors:function(Callable, any, string):{any} + + no_errors:function(Callable, any, string):{any} + + has_no_errors:function(Callable, any, string):{any} + has_no_error:function(Callable, any, string):{any} + + has_error:function(Callable, any, string):{any} + has_errors:function(Callable, any, string):{any} + + -- matches + matches:function(string, string, string) + + has_match:function(string, string, string):{string} + has_no_match:function(string, string, string):{string} + + does_error_match:function(any, string, string) + matches_error:function(any, string, string) + has_no_error_match:function(any, string, string) + does_not_match_error:function(any, string, string) + + error_matches:function(any, string, string):{any} + no_error_matches:function(any, string, string):{any} + + -- type checking + is_boolean:function(any, string):any, string + is_not_boolean:function(any, string):any, string + + is_number:function(any, string):any, string + is_not_number:function(any, string):any, string + + is_string:function(any, string):any, string + is_not_string:function(any, string):any, string + + is_table:function(any, string):any, string + is_not_table:function(any, string):any, string + + is_function:function(any, string):any, string + is_not_function:function(any, string):any, string + + is_userdata:function(any, string):any, string + is_not_userdata:function(any, string):any, string + + is_thread:function(any, string):any, string + is_not_thread:function(any, string):any, string + + is_nil:function(any, string):any, string + is_not_nil:function(any, string):any, string + + -- misc + set_parameter:function(self:asserts, string, integer) + + returned_arguments:function(...:any) + not_returned_arguments:function(...:any) + + has_holes:function({any}) + has_no_holes:function({any}) + + array:function({any}):ArrayAssert + + spy:function(any):SpyAssert + stub:function(any):SpyAssert + + get_level:function(self:asserts, any) + level:function(self:asserts, integer) + + has_property:function(any, string) +end + +return asserts diff --git a/types/luaassert/luassert/mock.d.tl b/types/luaassert/luassert/mock.d.tl new file mode 100644 index 0000000..a7eb94c --- /dev/null +++ b/types/luaassert/luassert/mock.d.tl @@ -0,0 +1,9 @@ + +local record mock + clear:function(any) + revert:function(any) + + new:function(T, boolean):T +end + +return mock diff --git a/types/luaassert/luassert/spy.d.tl b/types/luaassert/luassert/spy.d.tl new file mode 100644 index 0000000..17d5843 --- /dev/null +++ b/types/luaassert/luassert/spy.d.tl @@ -0,0 +1,14 @@ + +local record spy + clear:function(self:spy):spy + revert:function(self:spy):spy + + on:function(any, string):spy + + -- To call spy methods, cast it back to spy with 'as' + new:function(T):T + + metamethod __call: function(self: spy, ...:any) +end + +return spy diff --git a/types/luaassert/luassert/stub.d.tl b/types/luaassert/luassert/stub.d.tl new file mode 100644 index 0000000..0039e75 --- /dev/null +++ b/types/luaassert/luassert/stub.d.tl @@ -0,0 +1,29 @@ + +local record stub + record Defaults + returns:function(...:any) + invokes:function(function(...:any)) + end + + record OnCallWith + returns:function(...:any) + invokes:function(function(...:any)) + end + + clear:function(self:stub):stub + revert:function(self:stub):stub + + on_call_with:function(...:any):OnCallWith + + returns:function(...:any):stub + invokes:function(function(...:any)):stub + + -- table, key, return values + new:function(any, string, ...:any):stub + + by_default:Defaults + + metamethod __call: function(self: stub, ...:any) +end + +return stub diff --git a/types/neovim/template b/types/neovim/template index f2dd7ac..5bbf981 100644 --- a/types/neovim/template +++ b/types/neovim/template @@ -289,6 +289,28 @@ global record vim types: {string|integer:string|integer} + record KeyMap + record DelOptions + buffer:boolean + end + + record SetOptions + unique:boolean + expr:boolean + script:boolean + nowait:boolean + remap:boolean + replace_keycodes:boolean + silent:boolean + buffer:boolean + end + + set:function(mode:string|{string}, lhs:string, rhs:string|function(), opts:SetOptions) + del:function(modes:string|{string}, lhs:string, opts:DelOptions) + end + + keymap: KeyMap + record EventData --TODO: this is a vim thing, so types aren't really documented abort: any chan: integer @@ -508,3 +530,4 @@ global record vim select: function(any, SelectOpts, function(any, integer)) end end + diff --git a/types/neovim/vim.d.tl b/types/neovim/vim.d.tl index 0bbc202..ffddae6 100644 --- a/types/neovim/vim.d.tl +++ b/types/neovim/vim.d.tl @@ -289,6 +289,28 @@ global record vim types: {string|integer:string|integer} + record KeyMap + record DelOptions + buffer:boolean + end + + record SetOptions + unique:boolean + expr:boolean + script:boolean + nowait:boolean + remap:boolean + replace_keycodes:boolean + silent:boolean + buffer:boolean + end + + set:function(mode:string|{string}, lhs:string, rhs:string|function(), opts:SetOptions) + del:function(modes:string|{string}, lhs:string, opts:DelOptions) + end + + keymap: KeyMap + record EventData --TODO: this is a vim thing, so types aren't really documented abort: any chan: integer @@ -913,3 +935,4 @@ global record vim select: function(any, SelectOpts, function(any, integer)) end end + From da9aa6a65db1c4f11f9937d2a3b54690e50a3ee1 Mon Sep 17 00:00:00 2001 From: Steve Vermeulen Date: Mon, 4 Apr 2022 14:50:35 -0700 Subject: [PATCH 6/9] More fixes/extensions to vim types --- types/luaassert/luassert/assert.d.tl | 26 +- types/neovim/autogen_tl | 32 +- types/neovim/template | 19 +- types/neovim/vim.d.tl | 1164 +++++++++++++++++++++++++- 4 files changed, 1212 insertions(+), 29 deletions(-) diff --git a/types/luaassert/luassert/assert.d.tl b/types/luaassert/luassert/assert.d.tl index 6f1884c..3854960 100644 --- a/types/luaassert/luassert/assert.d.tl +++ b/types/luaassert/luassert/assert.d.tl @@ -132,20 +132,30 @@ local record asserts has_error:function(Callable, any, string):{any} has_errors:function(Callable, any, string):{any} + -- Errors matches + does_error_match:function(function(), string, string) + matches_error:function(function(), string, string) + has_no_error_match:function(function(), string, string) + does_not_match_error:function(function(), string, string) + + error_matches:function(function(), string, string):{any} + no_error_matches:function(function(), string, string):{any} + + -- Errors matches callable + does_error_match:function(Callable, string, string) + matches_error:function(Callable, string, string) + has_no_error_match:function(Callable, string, string) + does_not_match_error:function(Callable, string, string) + + error_matches:function(Callable, string, string):{any} + no_error_matches:function(Callable, string, string):{any} + -- matches matches:function(string, string, string) has_match:function(string, string, string):{string} has_no_match:function(string, string, string):{string} - does_error_match:function(any, string, string) - matches_error:function(any, string, string) - has_no_error_match:function(any, string, string) - does_not_match_error:function(any, string, string) - - error_matches:function(any, string, string):{any} - no_error_matches:function(any, string, string):{any} - -- type checking is_boolean:function(any, string):any, string is_not_boolean:function(any, string):any, string diff --git a/types/neovim/autogen_tl b/types/neovim/autogen_tl index d870b86..b305074 100644 --- a/types/neovim/autogen_tl +++ b/types/neovim/autogen_tl @@ -164,24 +164,42 @@ do local opts = vim.api.nvim_get_all_options_info() opts[""] = nil + local go : {string} = {} + local o : {string} = {} local wo : {string} = {} local bo : {string} = {} for _, opt in pairs(opts) do - local tab: {string} + local tables: {{string}} = {} + + table.insert(tables, o) + if opt.scope == "win" then - tab = wo + table.insert(tables, wo) elseif opt.scope == "buf" then - tab = bo + table.insert(tables, bo) + elseif opt.scope == "global" then + table.insert(tables, go) end - if tab then + + for _, tab in ipairs(tables) do if opt.shortname ~= "" then - table.insert(tab, string.format(" %s: %s", opt.shortname, opt.type)) - end + table.insert(tab, string.format(" %s: %s", opt.shortname, opt.type)) + end table.insert(tab, string.format(" %s: %s", opt.name, opt.type)) - end + end end + table.sort(o) + table.insert(o, 1, "record AllOptions") + table.insert(o, " end") + substitutions.ALL_OPTS = table.concat(o, "\n") + + table.sort(go) + table.insert(go, 1, "record GlobalOptions") + table.insert(go, " end") + substitutions.GLOBAL_OPTS = table.concat(go, "\n") + table.sort(wo) table.insert(wo, 1, "record WindowOptions") table.insert(wo, " end") diff --git a/types/neovim/template b/types/neovim/template index 5bbf981..e2ecfd4 100644 --- a/types/neovim/template +++ b/types/neovim/template @@ -13,9 +13,6 @@ global record vim -- end -- TODO: - -- vim.opt - -- vim.opt_global - -- vim.opt_local -- vim.treesitter fn: {string:function(...: any): (any)} @@ -482,20 +479,28 @@ global record vim client: function(): Client end + -- TODO: + -- vim.opt + -- vim.opt_global + -- vim.opt_local + g: {string:any} - go: {string:any} t: {string:any} v: {string:any} + b: {string:any} + w: {string:any} env: {string:any} - o: {string:any} + --[[$ALL_OPTS$]] + o: AllOptions + + --[[$GLOBAL_OPTS$]] + go: GlobalOptions --[[$BUFFER_OPTS$]] - b: BufferOptions bo: BufferOptions --[[$WINDOW_OPTS$]] - w: WindowOptions wo: WindowOptions --[[$API$]] diff --git a/types/neovim/vim.d.tl b/types/neovim/vim.d.tl index ffddae6..55935d1 100644 --- a/types/neovim/vim.d.tl +++ b/types/neovim/vim.d.tl @@ -13,9 +13,6 @@ global record vim -- end -- TODO: - -- vim.opt - -- vim.opt_global - -- vim.opt_local -- vim.treesitter fn: {string:function(...: any): (any)} @@ -482,13 +479,1168 @@ global record vim client: function(): Client end + -- TODO: + -- vim.opt + -- vim.opt_global + -- vim.opt_local + g: {string:any} - go: {string:any} t: {string:any} v: {string:any} + b: {string:any} + w: {string:any} env: {string:any} - o: {string:any} + record AllOptions + acd: boolean + ai: boolean + al: number + aleph: number + allowrevins: boolean + ambiwidth: string + ambw: string + ar: boolean + arab: boolean + arabic: boolean + arabicshape: boolean + ari: boolean + arshape: boolean + autochdir: boolean + autoindent: boolean + autoread: boolean + autowrite: boolean + autowriteall: boolean + aw: boolean + awa: boolean + background: string + backspace: string + backup: boolean + backupcopy: string + backupdir: string + backupext: string + backupskip: string + bdir: string + belloff: string + bex: string + bg: string + bh: string + bin: boolean + binary: boolean + bk: boolean + bkc: string + bl: boolean + bo: string + bomb: boolean + breakat: string + breakindent: boolean + breakindentopt: string + bri: boolean + briopt: string + brk: string + browsedir: string + bs: string + bsdir: string + bsk: string + bt: string + bufhidden: string + buflisted: boolean + buftype: string + casemap: string + cb: string + cc: string + ccv: string + cd: string + cdpath: string + cedit: string + cf: boolean + cfu: string + ch: number + channel: number + charconvert: string + ci: boolean + cin: boolean + cindent: boolean + cink: string + cinkeys: string + cino: string + cinoptions: string + cinw: string + cinwords: string + clipboard: string + cmdheight: number + cmdwinheight: number + cmp: string + cms: string + co: number + cocu: string + cole: number + colorcolumn: string + columns: number + com: string + comments: string + commentstring: string + compatible: boolean + complete: string + completefunc: string + completeopt: string + completeslash: string + concealcursor: string + conceallevel: number + confirm: boolean + copyindent: boolean + cot: string + cp: boolean + cpo: string + cpoptions: string + cpt: string + crb: boolean + cscopepathcomp: number + cscopeprg: string + cscopequickfix: string + cscoperelative: boolean + cscopetag: boolean + cscopetagorder: number + cscopeverbose: boolean + csl: string + cspc: number + csprg: string + csqf: string + csre: boolean + cst: boolean + csto: number + csverb: boolean + cuc: boolean + cul: boolean + cursorbind: boolean + cursorcolumn: boolean + cursorline: boolean + cwh: number + debug: string + deco: boolean + def: string + define: string + delcombine: boolean + dex: string + dg: boolean + dict: string + dictionary: string + diff: boolean + diffexpr: string + diffopt: string + digraph: boolean + dip: string + dir: string + directory: string + display: string + dy: string + ea: boolean + ead: string + eadirection: string + eb: boolean + ed: boolean + edcompatible: boolean + ef: string + efm: string + ei: string + emo: boolean + emoji: boolean + enc: string + encoding: string + endofline: boolean + eol: boolean + ep: string + equalalways: boolean + equalprg: string + errorbells: boolean + errorfile: string + errorformat: string + et: boolean + eventignore: string + ex: boolean + expandtab: boolean + exrc: boolean + fcl: string + fcs: string + fdc: string + fde: string + fdi: string + fdl: number + fdls: number + fdm: string + fdn: number + fdo: string + fdt: string + fen: boolean + fenc: string + fencs: string + fex: string + ff: string + ffs: string + fic: boolean + fileencoding: string + fileencodings: string + fileformat: string + fileformats: string + fileignorecase: boolean + filetype: string + fillchars: string + fixendofline: boolean + fixeol: boolean + flp: string + fml: number + fmr: string + fo: string + foldclose: string + foldcolumn: string + foldenable: boolean + foldexpr: string + foldignore: string + foldlevel: number + foldlevelstart: number + foldmarker: string + foldmethod: string + foldminlines: number + foldnestmax: number + foldopen: string + foldtext: string + formatexpr: string + formatlistpat: string + formatoptions: string + formatprg: string + fp: string + fs: boolean + fsync: boolean + ft: string + gcr: string + gd: boolean + gdefault: boolean + gfm: string + gfn: string + gfw: string + go: string + gp: string + grepformat: string + grepprg: string + gtl: string + gtt: string + guicursor: string + guifont: string + guifontwide: string + guioptions: string + guitablabel: string + guitabtooltip: string + helpfile: string + helpheight: number + helplang: string + hf: string + hh: number + hi: number + hid: boolean + hidden: boolean + highlight: string + history: number + hk: boolean + hkmap: boolean + hkmapp: boolean + hkp: boolean + hl: string + hlg: string + hls: boolean + hlsearch: boolean + ic: boolean + icm: string + icon: boolean + iconstring: string + ignorecase: boolean + im: boolean + imc: boolean + imcmdline: boolean + imd: boolean + imdisable: boolean + imi: number + iminsert: number + ims: number + imsearch: number + inc: string + inccommand: string + include: string + includeexpr: string + incsearch: boolean + inde: string + indentexpr: string + indentkeys: string + indk: string + inex: string + inf: boolean + infercase: boolean + insertmode: boolean + is: boolean + isf: string + isfname: string + isi: string + isident: string + isk: string + iskeyword: string + isp: string + isprint: string + joinspaces: boolean + jop: string + js: boolean + jumpoptions: string + keymap: string + keymodel: string + keywordprg: string + km: string + kmp: string + kp: string + langmap: string + langmenu: string + langnoremap: boolean + langremap: boolean + laststatus: number + lazyredraw: boolean + lbr: boolean + lcs: string + linebreak: boolean + lines: number + linespace: number + lisp: boolean + lispwords: string + list: boolean + listchars: string + lm: string + lmap: string + lnr: boolean + loadplugins: boolean + lpl: boolean + lrm: boolean + ls: number + lsp: number + lw: string + lz: boolean + ma: boolean + magic: boolean + makeef: string + makeencoding: string + makeprg: string + mat: number + matchpairs: string + matchtime: number + maxcombine: number + maxfuncdepth: number + maxmapdepth: number + maxmempattern: number + mco: number + mef: string + menc: string + menuitems: number + mfd: number + mh: boolean + mis: number + mkspellmem: string + ml: boolean + mle: boolean + mls: number + mmd: number + mmp: number + mod: boolean + modeline: boolean + modelineexpr: boolean + modelines: number + modifiable: boolean + modified: boolean + more: boolean + mouse: string + mousef: boolean + mousefocus: boolean + mousehide: boolean + mousem: string + mousemodel: string + mouses: string + mouseshape: string + mouset: number + mousetime: number + mp: string + mps: string + msm: string + nf: string + nrformats: string + nu: boolean + number: boolean + numberwidth: number + nuw: number + odev: boolean + ofu: string + omnifunc: string + opendevice: boolean + operatorfunc: string + opfunc: string + pa: string + packpath: string + para: string + paragraphs: string + paste: boolean + pastetoggle: string + patchexpr: string + patchmode: string + path: string + pb: number + pdev: string + penc: string + pex: string + pexpr: string + pfn: string + ph: number + pheader: string + pi: boolean + pm: string + pmbcs: string + pmbfn: string + popt: string + pp: string + preserveindent: boolean + previewheight: number + previewwindow: boolean + printdevice: string + printencoding: string + printexpr: string + printfont: string + printheader: string + printmbcharset: string + printmbfont: string + printoptions: string + prompt: boolean + pt: string + pumblend: number + pumheight: number + pumwidth: number + pvh: number + pvw: boolean + pw: number + pyx: number + pyxversion: number + qe: string + qftf: string + quickfixtextfunc: string + quoteescape: string + rdb: string + rdt: number + re: number + readonly: boolean + redrawdebug: string + redrawtime: number + regexpengine: number + relativenumber: boolean + remap: boolean + report: number + revins: boolean + ri: boolean + rightleft: boolean + rightleftcmd: string + rl: boolean + rlc: string + rnu: boolean + ro: boolean + rtp: string + ru: boolean + ruf: string + ruler: boolean + rulerformat: string + runtimepath: string + sb: boolean + sbo: string + sbr: string + sc: boolean + scb: boolean + scbk: number + scl: string + scr: number + scroll: number + scrollback: number + scrollbind: boolean + scrolljump: number + scrolloff: number + scrollopt: string + scs: boolean + sd: string + sdf: string + sect: string + sections: string + secure: boolean + sel: string + selection: string + selectmode: string + sessionoptions: string + sft: boolean + sh: string + shada: string + shadafile: string + shcf: string + shell: string + shellcmdflag: string + shellpipe: string + shellquote: string + shellredir: string + shellslash: boolean + shelltemp: boolean + shellxescape: string + shellxquote: string + shiftround: boolean + shiftwidth: number + shm: string + shortmess: string + showbreak: string + showcmd: boolean + showfulltag: boolean + showmatch: boolean + showmode: boolean + showtabline: number + shq: string + si: boolean + sidescroll: number + sidescrolloff: number + signcolumn: string + siso: number + sj: number + slm: string + sm: boolean + smartcase: boolean + smartindent: boolean + smarttab: boolean + smc: number + smd: boolean + so: number + softtabstop: number + sol: boolean + sp: string + spc: string + spell: boolean + spellcapcheck: string + spellfile: string + spelllang: string + spelloptions: string + spellsuggest: string + spf: string + spl: string + splitbelow: boolean + splitright: boolean + spo: string + spr: boolean + sps: string + sr: boolean + srr: string + ss: number + ssl: boolean + ssop: string + sta: boolean + stal: number + startofline: boolean + statusline: string + stl: string + stmp: boolean + sts: number + su: string + sua: string + suffixes: string + suffixesadd: string + sw: number + swapfile: boolean + swb: string + swf: boolean + switchbuf: string + sxe: string + sxq: string + syn: string + synmaxcol: number + syntax: string + tabline: string + tabpagemax: number + tabstop: number + tag: string + tagbsearch: boolean + tagcase: string + tagfunc: string + taglength: number + tagrelative: boolean + tags: string + tagstack: boolean + tal: string + tbidi: boolean + tbs: boolean + tc: string + tenc: string + termbidi: boolean + termencoding: string + termguicolors: boolean + termpastefilter: string + terse: boolean + textwidth: number + tf: boolean + tfu: string + tgc: boolean + tgst: boolean + thesaurus: string + tildeop: boolean + timeout: boolean + timeoutlen: number + title: boolean + titlelen: number + titleold: string + titlestring: string + tl: number + tm: number + to: boolean + top: boolean + tpf: string + tpm: number + tr: boolean + ts: number + tsr: string + ttimeout: boolean + ttimeoutlen: number + ttm: number + ttyfast: boolean + tw: number + uc: number + udf: boolean + udir: string + ul: number + undodir: string + undofile: boolean + undolevels: number + undoreload: number + updatecount: number + updatetime: number + ur: number + ut: number + varsofttabstop: string + vartabstop: string + vb: boolean + vbs: number + vdir: string + ve: string + verbose: number + verbosefile: string + vfile: string + vi: string + viewdir: string + viewoptions: string + vif: string + viminfo: string + viminfofile: string + virtualedit: string + visualbell: boolean + vop: string + vsts: string + vts: string + wa: boolean + wak: string + warn: boolean + wb: boolean + wc: number + wcm: number + wd: number + wfh: boolean + wfw: boolean + wh: number + whichwrap: string + wi: number + wic: boolean + wig: string + wildchar: number + wildcharm: number + wildignore: string + wildignorecase: boolean + wildmenu: boolean + wildmode: string + wildoptions: string + wim: string + winaltkeys: string + winbl: number + winblend: number + window: number + winfixheight: boolean + winfixwidth: boolean + winheight: number + winhighlight: string + winhl: string + winminheight: number + winminwidth: number + winwidth: number + wiw: number + wm: number + wmh: number + wmnu: boolean + wmw: number + wop: string + wrap: boolean + wrapmargin: number + wrapscan: boolean + write: boolean + writeany: boolean + writebackup: boolean + writedelay: number + ws: boolean + ww: string + end + o: AllOptions + + record GlobalOptions + acd: boolean + al: number + aleph: number + allowrevins: boolean + ambiwidth: string + ambw: string + arabicshape: boolean + ari: boolean + arshape: boolean + autochdir: boolean + autowrite: boolean + autowriteall: boolean + aw: boolean + awa: boolean + background: string + backspace: string + backup: boolean + backupdir: string + backupext: string + backupskip: string + bdir: string + belloff: string + bex: string + bg: string + bk: boolean + bo: string + breakat: string + brk: string + browsedir: string + bs: string + bsdir: string + bsk: string + casemap: string + cb: string + ccv: string + cd: string + cdpath: string + cedit: string + cf: boolean + ch: number + charconvert: string + clipboard: string + cmdheight: number + cmdwinheight: number + cmp: string + co: number + columns: number + compatible: boolean + completeopt: string + completeslash: string + confirm: boolean + cot: string + cp: boolean + cpo: string + cpoptions: string + cscopepathcomp: number + cscopeprg: string + cscopequickfix: string + cscoperelative: boolean + cscopetag: boolean + cscopetagorder: number + cscopeverbose: boolean + csl: string + cspc: number + csprg: string + csqf: string + csre: boolean + cst: boolean + csto: number + csverb: boolean + cwh: number + debug: string + deco: boolean + delcombine: boolean + dex: string + dg: boolean + diffexpr: string + diffopt: string + digraph: boolean + dip: string + dir: string + directory: string + display: string + dy: string + ea: boolean + ead: string + eadirection: string + eb: boolean + ed: boolean + edcompatible: boolean + ef: string + ei: string + emo: boolean + emoji: boolean + enc: string + encoding: string + equalalways: boolean + errorbells: boolean + errorfile: string + eventignore: string + ex: boolean + exrc: boolean + fcl: string + fdls: number + fdo: string + fencs: string + ffs: string + fic: boolean + fileencodings: string + fileformats: string + fileignorecase: boolean + foldclose: string + foldlevelstart: number + foldopen: string + fs: boolean + fsync: boolean + gcr: string + gd: boolean + gdefault: boolean + gfm: string + gfn: string + gfw: string + go: string + grepformat: string + gtl: string + gtt: string + guicursor: string + guifont: string + guifontwide: string + guioptions: string + guitablabel: string + guitabtooltip: string + helpfile: string + helpheight: number + helplang: string + hf: string + hh: number + hi: number + hid: boolean + hidden: boolean + highlight: string + history: number + hk: boolean + hkmap: boolean + hkmapp: boolean + hkp: boolean + hl: string + hlg: string + hls: boolean + hlsearch: boolean + ic: boolean + icm: string + icon: boolean + iconstring: string + ignorecase: boolean + im: boolean + imc: boolean + imcmdline: boolean + imd: boolean + imdisable: boolean + inccommand: string + incsearch: boolean + insertmode: boolean + is: boolean + isf: string + isfname: string + isi: string + isident: string + isp: string + isprint: string + joinspaces: boolean + jop: string + js: boolean + jumpoptions: string + keymodel: string + km: string + langmap: string + langmenu: string + langnoremap: boolean + langremap: boolean + laststatus: number + lazyredraw: boolean + lines: number + linespace: number + lm: string + lmap: string + lnr: boolean + loadplugins: boolean + lpl: boolean + lrm: boolean + ls: number + lsp: number + lz: boolean + magic: boolean + makeef: string + mat: number + matchtime: number + maxcombine: number + maxfuncdepth: number + maxmapdepth: number + maxmempattern: number + mco: number + mef: string + menuitems: number + mfd: number + mh: boolean + mis: number + mkspellmem: string + mle: boolean + mls: number + mmd: number + mmp: number + modelineexpr: boolean + modelines: number + more: boolean + mouse: string + mousef: boolean + mousefocus: boolean + mousehide: boolean + mousem: string + mousemodel: string + mouses: string + mouseshape: string + mouset: number + mousetime: number + msm: string + odev: boolean + opendevice: boolean + operatorfunc: string + opfunc: string + packpath: string + para: string + paragraphs: string + paste: boolean + pastetoggle: string + patchexpr: string + patchmode: string + pb: number + pdev: string + penc: string + pex: string + pexpr: string + pfn: string + ph: number + pheader: string + pm: string + pmbcs: string + pmbfn: string + popt: string + pp: string + previewheight: number + printdevice: string + printencoding: string + printexpr: string + printfont: string + printheader: string + printmbcharset: string + printmbfont: string + printoptions: string + prompt: boolean + pt: string + pumblend: number + pumheight: number + pumwidth: number + pvh: number + pw: number + pyx: number + pyxversion: number + qftf: string + quickfixtextfunc: string + rdb: string + rdt: number + re: number + redrawdebug: string + redrawtime: number + regexpengine: number + remap: boolean + report: number + revins: boolean + ri: boolean + rtp: string + ru: boolean + ruf: string + ruler: boolean + rulerformat: string + runtimepath: string + sb: boolean + sbo: string + sbr: string + sc: boolean + scrolljump: number + scrollopt: string + scs: boolean + sd: string + sdf: string + sect: string + sections: string + secure: boolean + sel: string + selection: string + selectmode: string + sessionoptions: string + sft: boolean + sh: string + shada: string + shadafile: string + shcf: string + shell: string + shellcmdflag: string + shellpipe: string + shellquote: string + shellredir: string + shellslash: boolean + shelltemp: boolean + shellxescape: string + shellxquote: string + shiftround: boolean + shm: string + shortmess: string + showbreak: string + showcmd: boolean + showfulltag: boolean + showmatch: boolean + showmode: boolean + showtabline: number + shq: string + sidescroll: number + sj: number + slm: string + sm: boolean + smartcase: boolean + smarttab: boolean + smd: boolean + sol: boolean + sp: string + spellsuggest: string + splitbelow: boolean + splitright: boolean + spr: boolean + sps: string + sr: boolean + srr: string + ss: number + ssl: boolean + ssop: string + sta: boolean + stal: number + startofline: boolean + stmp: boolean + su: string + suffixes: string + swb: string + switchbuf: string + sxe: string + sxq: string + tabline: string + tabpagemax: number + tagbsearch: boolean + taglength: number + tagrelative: boolean + tagstack: boolean + tal: string + tbidi: boolean + tbs: boolean + tenc: string + termbidi: boolean + termencoding: string + termguicolors: boolean + termpastefilter: string + terse: boolean + tf: boolean + tgc: boolean + tgst: boolean + tildeop: boolean + timeout: boolean + timeoutlen: number + title: boolean + titlelen: number + titleold: string + titlestring: string + tl: number + tm: number + to: boolean + top: boolean + tpf: string + tpm: number + tr: boolean + ttimeout: boolean + ttimeoutlen: number + ttm: number + ttyfast: boolean + uc: number + udir: string + undodir: string + undoreload: number + updatecount: number + updatetime: number + ur: number + ut: number + vb: boolean + vbs: number + vdir: string + ve: string + verbose: number + verbosefile: string + vfile: string + vi: string + viewdir: string + viewoptions: string + vif: string + viminfo: string + viminfofile: string + virtualedit: string + visualbell: boolean + vop: string + wa: boolean + wak: string + warn: boolean + wb: boolean + wc: number + wcm: number + wd: number + wh: number + whichwrap: string + wi: number + wic: boolean + wig: string + wildchar: number + wildcharm: number + wildignore: string + wildignorecase: boolean + wildmenu: boolean + wildmode: string + wildoptions: string + wim: string + winaltkeys: string + window: number + winheight: number + winminheight: number + winminwidth: number + winwidth: number + wiw: number + wmh: number + wmnu: boolean + wmw: number + wop: string + wrapscan: boolean + write: boolean + writeany: boolean + writebackup: boolean + writedelay: number + ws: boolean + ww: string + end + go: GlobalOptions record BufferOptions ai: boolean @@ -649,7 +1801,6 @@ global record vim wm: number wrapmargin: number end - b: BufferOptions bo: BufferOptions record WindowOptions @@ -734,7 +1885,6 @@ global record vim winhl: string wrap: boolean end - w: WindowOptions wo: WindowOptions record api From 7cc82377970413818aa447255a7a99be74602c12 Mon Sep 17 00:00:00 2001 From: Steve Vermeulen Date: Tue, 5 Apr 2022 14:01:49 -0700 Subject: [PATCH 7/9] Auto generated vim types again --- types/neovim/vim.d.tl | 47 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/types/neovim/vim.d.tl b/types/neovim/vim.d.tl index 55935d1..a2a6712 100644 --- a/types/neovim/vim.d.tl +++ b/types/neovim/vim.d.tl @@ -550,6 +550,8 @@ global record vim cc: string ccv: string cd: string + cdh: boolean + cdhome: boolean cdpath: string cedit: string cf: boolean @@ -611,9 +613,11 @@ global record vim csverb: boolean cuc: boolean cul: boolean + culopt: string cursorbind: boolean cursorcolumn: boolean cursorline: boolean + cursorlineopt: string cwh: number debug: string deco: boolean @@ -1080,6 +1084,7 @@ global record vim tgc: boolean tgst: boolean thesaurus: string + thesaurusfunc: string tildeop: boolean timeout: boolean timeoutlen: number @@ -1096,6 +1101,7 @@ global record vim tr: boolean ts: number tsr: string + tsrfu: string ttimeout: boolean ttimeoutlen: number ttm: number @@ -1222,6 +1228,8 @@ global record vim cb: string ccv: string cd: string + cdh: boolean + cdhome: boolean cdpath: string cedit: string cf: boolean @@ -1474,7 +1482,6 @@ global record vim runtimepath: string sb: boolean sbo: string - sbr: string sc: boolean scrolljump: number scrollopt: string @@ -1505,7 +1512,6 @@ global record vim shiftround: boolean shm: string shortmess: string - showbreak: string showcmd: boolean showfulltag: boolean showmatch: boolean @@ -1588,7 +1594,6 @@ global record vim vb: boolean vbs: number vdir: string - ve: string verbose: number verbosefile: string vfile: string @@ -1598,7 +1603,6 @@ global record vim vif: string viminfo: string viminfofile: string - virtualedit: string visualbell: boolean vop: string wa: boolean @@ -1787,8 +1791,10 @@ global record vim textwidth: number tfu: string thesaurus: string + thesaurusfunc: string ts: number tsr: string + tsrfu: string tw: number udf: boolean ul: number @@ -1819,9 +1825,11 @@ global record vim crb: boolean cuc: boolean cul: boolean + culopt: string cursorbind: boolean cursorcolumn: boolean cursorline: boolean + cursorlineopt: string diff: boolean fcs: string fdc: string @@ -1862,12 +1870,14 @@ global record vim rl: boolean rlc: string rnu: boolean + sbr: string scb: boolean scl: string scr: number scroll: number scrollbind: boolean scrolloff: number + showbreak: string sidescrolloff: number signcolumn: string siso: number @@ -1875,6 +1885,8 @@ global record vim spell: boolean statusline: string stl: string + ve: string + virtualedit: string wfh: boolean wfw: boolean winbl: number @@ -1890,11 +1902,11 @@ global record vim record api --[[ API version Information - neovim version: 0.5.0 + neovim version: 0.7.0 compatible: 0 - level: 7 - prerelease: false + level: 9 + prerelease: true --]] --[[ @@ -1911,12 +1923,16 @@ global record vim none of the above -> any --]] + nvim_add_user_command: function(string--[[String]], any--[[Object]], {string:any}--[[Dictionary]])--[[void]] nvim_buf_add_highlight: function(integer--[[Buffer]], integer--[[Integer]], string--[[String]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]]): integer--[[Integer]] + nvim_buf_add_user_command: function(integer--[[Buffer]], string--[[String]], any--[[Object]], {string:any}--[[Dictionary]])--[[void]] nvim_buf_attach: function(integer--[[Buffer]], boolean--[[Boolean]], {string:any}--[[Dictionary]]): boolean--[[Boolean]] nvim_buf_call: function(integer--[[Buffer]], any--[[LuaRef]]): any--[[Object]] nvim_buf_clear_namespace: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]])--[[void]] nvim_buf_del_extmark: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]]): boolean--[[Boolean]] nvim_buf_del_keymap: function(integer--[[Buffer]], string--[[String]], string--[[String]])--[[void]] + nvim_buf_del_mark: function(integer--[[Buffer]], string--[[String]]): boolean--[[Boolean]] + nvim_buf_del_user_command: function(integer--[[Buffer]], string--[[String]])--[[void]] nvim_buf_del_var: function(integer--[[Buffer]], string--[[String]])--[[void]] nvim_buf_delete: function(integer--[[Buffer]], {string:any}--[[Dictionary]])--[[void]] nvim_buf_detach: function(integer--[[Buffer]]): boolean--[[Boolean]] @@ -1930,6 +1946,7 @@ global record vim nvim_buf_get_name: function(integer--[[Buffer]]): string--[[String]] nvim_buf_get_offset: function(integer--[[Buffer]], integer--[[Integer]]): integer--[[Integer]] nvim_buf_get_option: function(integer--[[Buffer]], string--[[String]]): any--[[Object]] + nvim_buf_get_text: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]], {string:any}--[[Dictionary]]): {string}--[[ArrayOf(String)]] nvim_buf_get_var: function(integer--[[Buffer]], string--[[String]]): any--[[Object]] nvim_buf_is_loaded: function(integer--[[Buffer]]): boolean--[[Boolean]] nvim_buf_is_valid: function(integer--[[Buffer]]): boolean--[[Boolean]] @@ -1937,30 +1954,41 @@ global record vim nvim_buf_set_extmark: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]], {string:any}--[[Dictionary]]): integer--[[Integer]] nvim_buf_set_keymap: function(integer--[[Buffer]], string--[[String]], string--[[String]], string--[[String]], {string:any}--[[Dictionary]])--[[void]] nvim_buf_set_lines: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]], boolean--[[Boolean]], {string}--[[ArrayOf(String)]])--[[void]] + nvim_buf_set_mark: function(integer--[[Buffer]], string--[[String]], integer--[[Integer]], integer--[[Integer]], {string:any}--[[Dictionary]]): boolean--[[Boolean]] nvim_buf_set_name: function(integer--[[Buffer]], string--[[String]])--[[void]] nvim_buf_set_option: function(integer--[[Buffer]], string--[[String]], any--[[Object]])--[[void]] nvim_buf_set_text: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]], {string}--[[ArrayOf(String)]])--[[void]] nvim_buf_set_var: function(integer--[[Buffer]], string--[[String]], any--[[Object]])--[[void]] - nvim_buf_set_virtual_text: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]], any--[[Array]], {string:any}--[[Dictionary]]): integer--[[Integer]] nvim_call_atomic: function(any--[[Array]]): any--[[Array]] nvim_call_dict_function: function(any--[[Object]], string--[[String]], any--[[Array]]): any--[[Object]] nvim_call_function: function(string--[[String]], any--[[Array]]): any--[[Object]] nvim_chan_send: function(integer--[[Integer]], string--[[String]])--[[void]] + nvim_clear_autocmds: function({string:any}--[[Dictionary]])--[[void]] nvim_command: function(string--[[String]])--[[void]] + nvim_create_augroup: function(string--[[String]], {string:any}--[[Dictionary]]): integer--[[Integer]] + nvim_create_autocmd: function(any--[[Object]], {string:any}--[[Dictionary]]): integer--[[Integer]] nvim_create_buf: function(boolean--[[Boolean]], boolean--[[Boolean]]): integer--[[Buffer]] nvim_create_namespace: function(string--[[String]]): integer--[[Integer]] + nvim_del_augroup_by_id: function(integer--[[Integer]])--[[void]] + nvim_del_augroup_by_name: function(string--[[String]])--[[void]] + nvim_del_autocmd: function(integer--[[Integer]])--[[void]] nvim_del_current_line: function()--[[void]] nvim_del_keymap: function(string--[[String]], string--[[String]])--[[void]] + nvim_del_mark: function(string--[[String]]): boolean--[[Boolean]] + nvim_del_user_command: function(string--[[String]])--[[void]] nvim_del_var: function(string--[[String]])--[[void]] nvim_echo: function(any--[[Array]], boolean--[[Boolean]], {string:any}--[[Dictionary]])--[[void]] nvim_err_write: function(string--[[String]])--[[void]] nvim_err_writeln: function(string--[[String]])--[[void]] nvim_eval: function(string--[[String]]): any--[[Object]] + nvim_eval_statusline: function(string--[[String]], {string:any}--[[Dictionary]]): {string:any}--[[Dictionary]] nvim_exec: function(string--[[String]], boolean--[[Boolean]]): string--[[String]] + nvim_exec_autocmds: function(any--[[Object]], {string:any}--[[Dictionary]])--[[void]] nvim_exec_lua: function(string--[[String]], any--[[Array]]): any--[[Object]] nvim_feedkeys: function(string--[[String]], string--[[String]], boolean--[[Boolean]])--[[void]] nvim_get_all_options_info: function(): {string:any}--[[Dictionary]] nvim_get_api_info: function(): any--[[Array]] + nvim_get_autocmds: function({string:any}--[[Dictionary]]): any--[[Array]] nvim_get_chan_info: function(integer--[[Integer]]): {string:any}--[[Dictionary]] nvim_get_color_by_name: function(string--[[String]]): integer--[[Integer]] nvim_get_color_map: function(): {string:any}--[[Dictionary]] @@ -1974,10 +2002,12 @@ global record vim nvim_get_hl_by_name: function(string--[[String]], boolean--[[Boolean]]): {string:any}--[[Dictionary]] nvim_get_hl_id_by_name: function(string--[[String]]): integer--[[Integer]] nvim_get_keymap: function(string--[[String]]): {{string:any}}--[[ArrayOf(Dictionary)]] + nvim_get_mark: function(string--[[String]], {string:any}--[[Dictionary]]): any--[[Array]] nvim_get_mode: function(): {string:any}--[[Dictionary]] nvim_get_namespaces: function(): {string:any}--[[Dictionary]] nvim_get_option: function(string--[[String]]): any--[[Object]] nvim_get_option_info: function(string--[[String]]): {string:any}--[[Dictionary]] + nvim_get_option_value: function(string--[[String]], {string:any}--[[Dictionary]]): any--[[Object]] nvim_get_proc: function(integer--[[Integer]]): any--[[Object]] nvim_get_proc_children: function(integer--[[Integer]]): any--[[Array]] nvim_get_runtime_file: function(string--[[String]], boolean--[[Boolean]]): {string}--[[ArrayOf(String)]] @@ -2011,6 +2041,7 @@ global record vim nvim_set_hl: function(integer--[[Integer]], string--[[String]], {string:any}--[[Dictionary]])--[[void]] nvim_set_keymap: function(string--[[String]], string--[[String]], string--[[String]], {string:any}--[[Dictionary]])--[[void]] nvim_set_option: function(string--[[String]], any--[[Object]])--[[void]] + nvim_set_option_value: function(string--[[String]], any--[[Object]], {string:any}--[[Dictionary]])--[[void]] nvim_set_var: function(string--[[String]], any--[[Object]])--[[void]] nvim_set_vvar: function(string--[[String]], any--[[Object]])--[[void]] nvim_strwidth: function(string--[[String]]): integer--[[Integer]] From 3e92b3d621edfcf6cc6baa5d874904d5fe48806e Mon Sep 17 00:00:00 2001 From: Steve Vermeulen Date: Thu, 7 Apr 2022 13:20:24 -0700 Subject: [PATCH 8/9] Fix attempt for pipeline failure --- types/{luaassert => luassert}/luassert.d.tl | 0 types/{luaassert => luassert}/luassert/assert.d.tl | 0 types/{luaassert => luassert}/luassert/match.d.tl | 0 types/{luaassert => luassert}/luassert/mock.d.tl | 0 types/{luaassert => luassert}/luassert/spy.d.tl | 0 types/{luaassert => luassert}/luassert/stub.d.tl | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename types/{luaassert => luassert}/luassert.d.tl (100%) rename types/{luaassert => luassert}/luassert/assert.d.tl (100%) rename types/{luaassert => luassert}/luassert/match.d.tl (100%) rename types/{luaassert => luassert}/luassert/mock.d.tl (100%) rename types/{luaassert => luassert}/luassert/spy.d.tl (100%) rename types/{luaassert => luassert}/luassert/stub.d.tl (100%) diff --git a/types/luaassert/luassert.d.tl b/types/luassert/luassert.d.tl similarity index 100% rename from types/luaassert/luassert.d.tl rename to types/luassert/luassert.d.tl diff --git a/types/luaassert/luassert/assert.d.tl b/types/luassert/luassert/assert.d.tl similarity index 100% rename from types/luaassert/luassert/assert.d.tl rename to types/luassert/luassert/assert.d.tl diff --git a/types/luaassert/luassert/match.d.tl b/types/luassert/luassert/match.d.tl similarity index 100% rename from types/luaassert/luassert/match.d.tl rename to types/luassert/luassert/match.d.tl diff --git a/types/luaassert/luassert/mock.d.tl b/types/luassert/luassert/mock.d.tl similarity index 100% rename from types/luaassert/luassert/mock.d.tl rename to types/luassert/luassert/mock.d.tl diff --git a/types/luaassert/luassert/spy.d.tl b/types/luassert/luassert/spy.d.tl similarity index 100% rename from types/luaassert/luassert/spy.d.tl rename to types/luassert/luassert/spy.d.tl diff --git a/types/luaassert/luassert/stub.d.tl b/types/luassert/luassert/stub.d.tl similarity index 100% rename from types/luaassert/luassert/stub.d.tl rename to types/luassert/luassert/stub.d.tl From 8814c228c94b700a75d105b0d40358bab567c6a5 Mon Sep 17 00:00:00 2001 From: Steve Vermeulen Date: Thu, 7 Apr 2022 13:26:31 -0700 Subject: [PATCH 9/9] Changed to not include luassert automatically with busted for now --- types/busted/busted.d.tl | 1 - 1 file changed, 1 deletion(-) diff --git a/types/busted/busted.d.tl b/types/busted/busted.d.tl index e48d114..d3156b0 100644 --- a/types/busted/busted.d.tl +++ b/types/busted/busted.d.tl @@ -13,4 +13,3 @@ global randomize: function() global finally: function(function()) global pending: function(string) -require("luassert")