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
This commit is contained in:
Edwin Pujols 2020-12-11 19:54:39 -04:00 committed by GitHub
parent 4620ad604f
commit f2ec058602
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -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()

View File

@ -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)