diff src/testdir/test_assert.vim @ 8831:6f41d68aa68e v7.4.1703

commit https://github.com/vim/vim/commit/b50e5f56861deb867478997397f7c784a7043233 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 3 20:57:20 2016 +0200 patch 7.4.1703 Problem: Can't assert for not equal and not matching. Solution: Add assert_notmatch() and assert_notequal().
author Christian Brabandt <cb@256bit.org>
date Sun, 03 Apr 2016 21:00:05 +0200
parents 65a5a18d3acf
children ccbb8e393d80
line wrap: on
line diff
--- 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])