summaryrefslogtreecommitdiff
path: root/src/testdir/test_assert.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-04-03 20:57:20 +0200
committerBram Moolenaar <Bram@vim.org>2016-04-03 20:57:20 +0200
commitb50e5f56861deb867478997397f7c784a7043233 (patch)
treea6ce47ff80152e78ee12f9020664ad0796e875c8 /src/testdir/test_assert.vim
parent4afc7c5d4a73340831077a02bfe1f74935e7f4a1 (diff)
downloadvim-git-b50e5f56861deb867478997397f7c784a7043233.tar.gz
patch 7.4.1703v7.4.1703
Problem: Can't assert for not equal and not matching. Solution: Add assert_notmatch() and assert_notequal().
Diffstat (limited to 'src/testdir/test_assert.vim')
-rw-r--r--src/testdir/test_assert.vim25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim
index bc025b4c4..d7fb6385f 100644
--- a/src/testdir/test_assert.vim
+++ b/src/testdir/test_assert.vim
@@ -18,6 +18,22 @@ func Test_assert_equal()
call assert_equal(4, n)
let l = [1, 2, 3]
call assert_equal([1, 2, 3], l)
+
+ let s = 'foo'
+ call assert_equal('bar', s)
+ call assert_match("Expected 'bar' but got 'foo'", v:errors[0])
+ call remove(v:errors, 0)
+endfunc
+
+func Test_assert_notequal()
+ let n = 4
+ call assert_notequal('foo', n)
+ let s = 'foo'
+ call assert_notequal([1, 2, 3], s)
+
+ call assert_notequal('foo', s)
+ call assert_match("Expected 'foo' differs from 'foo'", v:errors[0])
+ call remove(v:errors, 0)
endfunc
func Test_assert_exception()
@@ -74,6 +90,15 @@ func Test_match()
call remove(v:errors, 0)
endfunc
+func Test_notmatch()
+ call assert_notmatch('foo', 'bar')
+ call assert_notmatch('^foobar$', 'foobars')
+
+ call assert_notmatch('foo', 'foobar')
+ call assert_match("Pattern 'foo' does match 'foobar'", v:errors[0])
+ call remove(v:errors, 0)
+endfunc
+
func Test_assert_fail_fails()
call assert_fails('xxx', {})
call assert_match("Expected {} but got 'E731:", v:errors[0])