aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/assert_spec.lua
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2016-07-08 13:32:25 -0400
committerJames McCoy <jamessan@jamessan.com>2016-07-23 20:42:46 -0400
commitaece3ffa7dca546bd5c358478dfb9f423519e211 (patch)
tree28002fc970d2b22a620d97fd91e7b74e6c6c7568 /test/functional/legacy/assert_spec.lua
parent8c1fb99d2d4058d2cc1decbfed89b1f73b38cef6 (diff)
downloadrneovim-aece3ffa7dca546bd5c358478dfb9f423519e211.tar.gz
rneovim-aece3ffa7dca546bd5c358478dfb9f423519e211.tar.bz2
rneovim-aece3ffa7dca546bd5c358478dfb9f423519e211.zip
vim-patch:7.4.1663
Problem: In tests it's often useful to check if a pattern matches. Solution: Add assert_match(). https://github.com/vim/vim/commit/ea6553bec340920d8a09c7210cdc2d218e25ace2
Diffstat (limited to 'test/functional/legacy/assert_spec.lua')
-rw-r--r--test/functional/legacy/assert_spec.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua
index 8da6ee45d7..cf1dcf6686 100644
--- a/test/functional/legacy/assert_spec.lua
+++ b/test/functional/legacy/assert_spec.lua
@@ -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)