aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwin Pujols <73705427+shade-of-noon@users.noreply.github.com>2020-12-11 19:54:39 -0400
committerGitHub <noreply@github.com>2020-12-11 18:54:39 -0500
commitf2ec0586021dd363566922bd7d6dbd3ab7703e38 (patch)
tree334d125b55c2d886a6cafd5eba0cf63e60e8fe2d
parent4620ad604f58f22e07152b80a4969055643f684f (diff)
downloadrneovim-f2ec0586021dd363566922bd7d6dbd3ab7703e38.tar.gz
rneovim-f2ec0586021dd363566922bd7d6dbd3ab7703e38.tar.bz2
rneovim-f2ec0586021dd363566922bd7d6dbd3ab7703e38.zip
tests: Take into account magic hyphen. (#13518)
In Lua patterns the hyphen works like a non-greedy version of Vim's `*`. - Use `%-` when you need a literal hyphen. - If you don't need a regular expression at all, use something like ``` string.find(text, pattern, 1, true) ``` so that the pattern is regarded as a plain, non-magical string. See [1] and [2] in the Lua manual. [1]: https://www.lua.org/manual/5.1/manual.html#pdf-Patterns [2]: https://www.lua.org/manual/5.1/manual.html#pdf-string.find
-rw-r--r--test/functional/core/startup_spec.lua4
-rw-r--r--test/functional/terminal/tui_spec.lua2
2 files changed, 3 insertions, 3 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index ff0fdbea45..d5f03db03a 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -428,9 +428,9 @@ end)
describe('clean', function()
clear()
- ok(string.match(meths.get_option('runtimepath'), funcs.stdpath('config')) ~= nil)
+ ok(string.find(meths.get_option('runtimepath'), funcs.stdpath('config'), 1, true) ~= nil)
clear('--clean')
- ok(string.match(meths.get_option('runtimepath'), funcs.stdpath('config')) == nil)
+ ok(string.find(meths.get_option('runtimepath'), funcs.stdpath('config'), 1, true) == nil)
end)
describe('user config init', function()
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 3ef41fde1d..8a5dd7ef18 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -1477,7 +1477,7 @@ describe("TUI", function()
retry(nil, 3000, function() -- Wait for log file to be flushed.
local log = read_file('Xtest_tui_verbose_log') or ''
- eq('--- Terminal info --- {{{\n', string.match(log, '--- Terminal.-\n'))
+ eq('--- Terminal info --- {{{\n', string.match(log, '%-%-%- Terminal.-\n'))
ok(#log > 50)
end)
end)