mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
vim-patch:7.4.1663
Problem: In tests it's often useful to check if a pattern matches.
Solution: Add assert_match().
ea6553bec3
This commit is contained in:
@@ -155,10 +155,29 @@ describe('assert function:', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
-- assert_match({pat}, {text}[, {msg}])
|
||||
describe('assert_match', function()
|
||||
it('should not change v:errors when pat matches text', function()
|
||||
call('assert_match', '^f.*b.*r$', 'foobar')
|
||||
expected_empty()
|
||||
end)
|
||||
|
||||
it('should change v:errors when pat does not match text', function()
|
||||
call('assert_match', 'bar.*foo', 'foobar')
|
||||
expected_errors({"Pattern 'bar.*foo' does not match 'foobar'"})
|
||||
end)
|
||||
|
||||
it('should set v:errors to msg when given and match fails', function()
|
||||
call('assert_match', 'bar.*foo', 'foobar', 'wrong')
|
||||
expected_errors({"'wrong'"})
|
||||
end)
|
||||
end)
|
||||
|
||||
-- assert_fails({cmd}, [, {error}])
|
||||
describe('assert_fails', function()
|
||||
it('should change v:errors when error does not match v:errmsg', function()
|
||||
execute([[call assert_fails('xxx', {})]])
|
||||
execute([[call assert_match("Expected {} but got 'E731:", v:errors[0])]])
|
||||
expected_errors({"Expected {} but got 'E731: using Dictionary as a String'"})
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user