mirror of
https://github.com/neovim/neovim.git
synced 2025-11-03 09:14:24 +00:00
test: use matches(...) instead of ok(string.find(...)) (#28111)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear, eq, ok = helpers.clear, helpers.eq, helpers.ok
|
||||
local neq, command, fn = helpers.neq, helpers.command, helpers.fn
|
||||
local matches = helpers.matches
|
||||
local reltime, reltimestr, reltimefloat = fn.reltime, fn.reltimestr, fn.reltimefloat
|
||||
|
||||
describe('reltimestr(), reltimefloat()', function()
|
||||
@@ -15,7 +16,7 @@ describe('reltimestr(), reltimefloat()', function()
|
||||
neq('0.0', reltimestr(elapsed))
|
||||
ok(reltimefloat(elapsed) > 0.0)
|
||||
-- original vim test for < 0.1, but easily fails on travis
|
||||
ok(nil ~= string.match(reltimestr(elapsed), '0%.'))
|
||||
matches('0%.', reltimestr(elapsed))
|
||||
ok(reltimefloat(elapsed) < 1.0)
|
||||
|
||||
local same = reltime(now, now)
|
||||
@@ -29,7 +30,7 @@ describe('reltimestr(), reltimefloat()', function()
|
||||
neq('0.0', reltimestr(differs))
|
||||
ok(reltimefloat(differs) > 0.0)
|
||||
-- original vim test for < 0.1, but easily fails on travis
|
||||
ok(nil ~= string.match(reltimestr(differs), '0%.'))
|
||||
matches('0%.', reltimestr(differs))
|
||||
ok(reltimefloat(differs) < 1.0)
|
||||
end)
|
||||
|
||||
|
||||
@@ -100,14 +100,14 @@ describe('server', function()
|
||||
|
||||
local s = fn.serverstart('127.0.0.1:0') -- assign random port
|
||||
if #s > 0 then
|
||||
assert(string.match(s, '127.0.0.1:%d+'))
|
||||
matches('127.0.0.1:%d+', s)
|
||||
eq(s, fn.serverlist()[1])
|
||||
clear_serverlist()
|
||||
end
|
||||
|
||||
s = fn.serverstart('127.0.0.1:') -- assign random port
|
||||
if #s > 0 then
|
||||
assert(string.match(s, '127.0.0.1:%d+'))
|
||||
matches('127.0.0.1:%d+', s)
|
||||
eq(s, fn.serverlist()[1])
|
||||
clear_serverlist()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user