aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/README.md53
-rw-r--r--test/functional/eval/json_functions_spec.lua7
-rw-r--r--test/functional/fixtures/api_level_3.mpackbin0 -> 19501 bytes
-rw-r--r--test/functional/ui/inccommand_spec.lua36
4 files changed, 78 insertions, 18 deletions
diff --git a/test/README.md b/test/README.md
index 01db5960cd..44558f0981 100644
--- a/test/README.md
+++ b/test/README.md
@@ -1,31 +1,48 @@
-# Tests
+Tests
+=====
Tests are run by `/cmake/RunTests.cmake` file, using busted.
For some failures, `.nvimlog` (or `$NVIM_LOG_FILE`) may provide insight.
-## Directory structure
+Lint
+----
-Directories with tests: `/test/benchmark` for benchmarks, `/test/functional` for
-functional tests, `/test/unit` for unit tests. `/test/config` contains `*.in`
-files (currently a single one) which are transformed into `*.lua` files using
-`configure_file` CMake command: this is for acessing CMake variables in lua
-tests. `/test/includes` contains include files for use by luajit `ffi.cdef`
-C definitions parser: normally used to make macros not accessible via this
-mechanism accessible the other way.
+`make lint` (and `make testlint`) runs [luacheck](https://github.com/mpeterv/luacheck)
+on the test code.
-Files `/test/*/preload.lua` contain modules which will be preloaded by busted,
-via `--helper` option. `/test/**/helpers.lua` contain various “library”
-functions, (intended to be) used by a number of tests and not just a single one.
+If a luacheck warning must be ignored, specify the warning code. Example:
-`/test/*/**/*_spec.lua` are files containing actual tests. Files that do not end
-with a `_spec.lua` are libraries like `/test/**/helpers.lua`, except that they
-have some common topic.
+ -- luacheck: ignore 621
-Tests inside `/test/unit` and `/test/functional` are normally divided into
-groups by the semantic component they are testing.
+http://luacheck.readthedocs.io/en/stable/warnings.html
-## Environment variables
+Ignore the smallest applicable scope (e.g. inside a function, not at the top of
+the file).
+
+Layout
+------
+
+- `/test/benchmark` : benchmarks
+- `/test/functional` : functional tests
+- `/test/unit` : unit tests
+- `/test/config` : contains `*.in` files which are transformed into `*.lua`
+ files using `configure_file` CMake command: this is for acessing CMake
+ variables in lua tests.
+- `/test/includes` : include-files for use by luajit `ffi.cdef` C definitions
+ parser: normally used to make macros not accessible via this mechanism
+ accessible the other way.
+- `/test/*/preload.lua` : modules preloaded by busted `--helper` option
+- `/test/**/helpers.lua` : common utility functions for test code
+- `/test/*/**/*_spec.lua` : actual tests. Files that do not end with
+ `_spec.lua` are libraries like `/test/**/helpers.lua`, except that they have
+ some common topic.
+
+Tests in `/test/unit` and `/test/functional` are normally divided into groups
+by the semantic component they are testing.
+
+Environment variables
+---------------------
Test behaviour is affected by environment variables. Currently supported
(Functional, Unit, Benchmarks) (when Defined; when set to _1_; when defined,
diff --git a/test/functional/eval/json_functions_spec.lua b/test/functional/eval/json_functions_spec.lua
index 4d34cde849..8dcaea806e 100644
--- a/test/functional/eval/json_functions_spec.lua
+++ b/test/functional/eval/json_functions_spec.lua
@@ -776,4 +776,11 @@ describe('json_encode() function', function()
it('can dump NULL dictionary', function()
eq('{}', eval('json_encode(v:_null_dict)'))
end)
+
+ it('fails to parse NULL strings and lists', function()
+ eq('Vim(call):E474: Attempt to decode a blank string',
+ exc_exec('call json_decode($XXX_UNEXISTENT_VAR_XXX)'))
+ eq('Vim(call):E474: Attempt to decode a blank string',
+ exc_exec('call json_decode(v:_null_list)'))
+ end)
end)
diff --git a/test/functional/fixtures/api_level_3.mpack b/test/functional/fixtures/api_level_3.mpack
new file mode 100644
index 0000000000..ef36b99c8c
--- /dev/null
+++ b/test/functional/fixtures/api_level_3.mpack
Binary files differ
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index 6646e65bad..53fd17c309 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -1791,6 +1791,42 @@ describe("'inccommand' with 'gdefault'", function()
expect("A\nA")
eq({mode='n', blocking=false}, nvim("get_mode"))
end)
+
+ it("does not crash on zero-width matches #7485", function()
+ common_setup(nil, "split", default_text)
+ command("set gdefault")
+ feed("gg")
+ feed("Vj")
+ feed(":s/\\%V")
+ eq({mode='c', blocking=false}, nvim("get_mode"))
+ feed("<Esc>")
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ end)
+
+ it("removes highlights after abort for a zero-width match", function()
+ local screen = Screen.new(30,5)
+ common_setup(screen, "nosplit", default_text)
+ command("set gdefault")
+
+ feed(":%s/\\%1c/a/")
+ screen:expect([[
+ {12:a}Inc substitution on |
+ {12:a}two lines |
+ {12:a} |
+ {15:~ }|
+ :%s/\%1c/a/^ |
+ ]])
+
+ feed("<Esc>")
+ screen:expect([[
+ Inc substitution on |
+ two lines |
+ ^ |
+ {15:~ }|
+ |
+ ]])
+ end)
+
end)
describe(":substitute", function()