diff src/testdir/test_assert.vim @ 17728:68ea27d26d5b v8.1.1861

patch 8.1.1861: only some assert functions can be used as a method commit https://github.com/vim/vim/commit/24278d2407dfbc8d93eb36593cdd006ff5d86f94 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 16 21:49:22 2019 +0200 patch 8.1.1861: only some assert functions can be used as a method Problem: Only some assert functions can be used as a method. Solution: Allow using most assert functions as a method.
author Bram Moolenaar <Bram@vim.org>
date Fri, 16 Aug 2019 22:00:04 +0200
parents ccd21c8f916b
children ce993ba17adb
line wrap: on
line diff
--- a/src/testdir/test_assert.vim
+++ b/src/testdir/test_assert.vim
@@ -3,20 +3,30 @@
 func Test_assert_false()
   call assert_equal(0, assert_false(0))
   call assert_equal(0, assert_false(v:false))
+  call assert_equal(0, v:false->assert_false())
 
   call assert_equal(1, assert_false(123))
   call assert_match("Expected False but got 123", v:errors[0])
   call remove(v:errors, 0)
+
+  call assert_equal(1, 123->assert_false())
+  call assert_match("Expected False but got 123", v:errors[0])
+  call remove(v:errors, 0)
 endfunc
 
 func Test_assert_true()
   call assert_equal(0, assert_true(1))
   call assert_equal(0, assert_true(123))
   call assert_equal(0, assert_true(v:true))
+  call assert_equal(0, v:true->assert_true())
 
   call assert_equal(1, assert_true(0))
   call assert_match("Expected True but got 0", v:errors[0])
   call remove(v:errors, 0)
+
+  call assert_equal(1, 0->assert_true())
+  call assert_match("Expected True but got 0", v:errors[0])
+  call remove(v:errors, 0)
 endfunc
 
 func Test_assert_equal()
@@ -141,6 +151,10 @@ func Test_match()
   call assert_equal(1, assert_match('bar.*foo', 'foobar', 'wrong'))
   call assert_match('wrong', v:errors[0])
   call remove(v:errors, 0)
+
+  call assert_equal(1, 'foobar'->assert_match('bar.*foo', 'wrong'))
+  call assert_match('wrong', v:errors[0])
+  call remove(v:errors, 0)
 endfunc
 
 func Test_notmatch()
@@ -150,6 +164,10 @@ func Test_notmatch()
   call assert_equal(1, assert_notmatch('foo', 'foobar'))
   call assert_match("Pattern 'foo' does match 'foobar'", v:errors[0])
   call remove(v:errors, 0)
+
+  call assert_equal(1, 'foobar'->assert_notmatch('foo'))
+  call assert_match("Pattern 'foo' does match 'foobar'", v:errors[0])
+  call remove(v:errors, 0)
 endfunc
 
 func Test_assert_fail_fails()
@@ -164,6 +182,10 @@ func Test_assert_fail_fails()
   call assert_equal(1, assert_fails('echo', '', 'echo command'))
   call assert_match("command did not fail: echo command", v:errors[0])
   call remove(v:errors, 0)
+
+  call assert_equal(1, 'echo'->assert_fails('', 'echo command'))
+  call assert_match("command did not fail: echo command", v:errors[0])
+  call remove(v:errors, 0)
 endfunc
 
 func Test_assert_fails_in_try_block()
@@ -179,6 +201,12 @@ func Test_assert_beeps()
   call assert_equal(1, assert_beeps('normal 0'))
   call assert_match("command did not beep: normal 0", v:errors[0])
   call remove(v:errors, 0)
+
+  call assert_equal(0, 'normal h'->assert_beeps())
+  call assert_equal(1, 'normal 0'->assert_beeps())
+  call assert_match("command did not beep: normal 0", v:errors[0])
+  call remove(v:errors, 0)
+
   bwipe
 endfunc
 
@@ -195,6 +223,12 @@ func Test_assert_inrange()
   call assert_match("Expected range 5 - 7, but got 8", v:errors[0])
   call remove(v:errors, 0)
 
+  call assert_equal(0, 5->assert_inrange(5, 7))
+  call assert_equal(0, 7->assert_inrange(5, 7))
+  call assert_equal(1, 8->assert_inrange(5, 7))
+  call assert_match("Expected range 5 - 7, but got 8", v:errors[0])
+  call remove(v:errors, 0)
+
   call assert_fails('call assert_inrange(1, 1)', 'E119:')
 
   if has('float')