summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_assert.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-08-16 21:49:22 +0200
committerBram Moolenaar <Bram@vim.org>2019-08-16 21:49:22 +0200
commit24278d2407dfbc8d93eb36593cdd006ff5d86f94 (patch)
tree206d7e615bc0b42b9976e6ace2fb875718e21b14 /src/testdir/test_assert.vim
parentea94c855163cf58a3389b5f3c54a0767c9e1be49 (diff)
patch 8.1.1861: only some assert functions can be used as a methodv8.1.1861
Problem: Only some assert functions can be used as a method. Solution: Allow using most assert functions as a method.
Diffstat (limited to 'src/testdir/test_assert.vim')
-rw-r--r--src/testdir/test_assert.vim34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim
index 900710b893..65a0ee41a7 100644
--- 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')