Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
8830:d15abeac22c6 | 8831:6f41d68aa68e |
---|---|
16 call assert_equal('foo', s) | 16 call assert_equal('foo', s) |
17 let n = 4 | 17 let n = 4 |
18 call assert_equal(4, n) | 18 call assert_equal(4, n) |
19 let l = [1, 2, 3] | 19 let l = [1, 2, 3] |
20 call assert_equal([1, 2, 3], l) | 20 call assert_equal([1, 2, 3], l) |
21 | |
22 let s = 'foo' | |
23 call assert_equal('bar', s) | |
24 call assert_match("Expected 'bar' but got 'foo'", v:errors[0]) | |
25 call remove(v:errors, 0) | |
26 endfunc | |
27 | |
28 func Test_assert_notequal() | |
29 let n = 4 | |
30 call assert_notequal('foo', n) | |
31 let s = 'foo' | |
32 call assert_notequal([1, 2, 3], s) | |
33 | |
34 call assert_notequal('foo', s) | |
35 call assert_match("Expected 'foo' differs from 'foo'", v:errors[0]) | |
36 call remove(v:errors, 0) | |
21 endfunc | 37 endfunc |
22 | 38 |
23 func Test_assert_exception() | 39 func Test_assert_exception() |
24 try | 40 try |
25 nocommand | 41 nocommand |
72 call assert_match('bar.*foo', 'foobar', 'wrong') | 88 call assert_match('bar.*foo', 'foobar', 'wrong') |
73 call assert_match('wrong', v:errors[0]) | 89 call assert_match('wrong', v:errors[0]) |
74 call remove(v:errors, 0) | 90 call remove(v:errors, 0) |
75 endfunc | 91 endfunc |
76 | 92 |
93 func Test_notmatch() | |
94 call assert_notmatch('foo', 'bar') | |
95 call assert_notmatch('^foobar$', 'foobars') | |
96 | |
97 call assert_notmatch('foo', 'foobar') | |
98 call assert_match("Pattern 'foo' does match 'foobar'", v:errors[0]) | |
99 call remove(v:errors, 0) | |
100 endfunc | |
101 | |
77 func Test_assert_fail_fails() | 102 func Test_assert_fail_fails() |
78 call assert_fails('xxx', {}) | 103 call assert_fails('xxx', {}) |
79 call assert_match("Expected {} but got 'E731:", v:errors[0]) | 104 call assert_match("Expected {} but got 'E731:", v:errors[0]) |
80 call remove(v:errors, 0) | 105 call remove(v:errors, 0) |
81 endfunc | 106 endfunc |