Skip to content

Commit 683fa18

Browse files
committed
patch 7.4.945
Problem: New style testing is incomplete. Solution: Add the runtest script to the list of distributed files. Add the new functions to the function overview. Rename the functions to match Vim function style. Move undolevels testing into a new style test script.
1 parent 4334554 commit 683fa18

9 files changed

Lines changed: 87 additions & 104 deletions

File tree

Filelist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ SRC_ALL = \
8787
src/testdir/README.txt \
8888
src/testdir/*.in \
8989
src/testdir/sautest/autoload/*.vim \
90+
src/testdir/runtest.vim \
9091
src/testdir/test[0-9]*.ok \
9192
src/testdir/test[0-9]*a.ok \
9293
src/testdir/test_[a-z]*.ok \

runtime/doc/eval.txt

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 7.4. Last change: 2015 Nov 29
1+
*eval.txt* For Vim version 7.4. Last change: 2015 Nov 30
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1380,7 +1380,7 @@ v:errmsg Last given error message. It's allowed to set this variable.
13801380
< "errmsg" also works, for backwards compatibility.
13811381

13821382
*v:errors* *errors-variable*
1383-
v:errors Errors found by assert functions, such as |assertTrue()|.
1383+
v:errors Errors found by assert functions, such as |assert_true()|.
13841384
This is a list of strings.
13851385
The assert functions append an item when an assert fails.
13861386
To remove old results make it empty: >
@@ -1742,13 +1742,13 @@ append( {lnum}, {string}) Number append {string} below line {lnum}
17421742
append( {lnum}, {list}) Number append lines {list} below line {lnum}
17431743
argc() Number number of files in the argument list
17441744
argidx() Number current index in the argument list
1745-
arglistid( [{winnr}, [ {tabnr}]])
1745+
arglistid( [{winnr} [, {tabnr}]])
17461746
Number argument list id
17471747
argv( {nr}) String {nr} entry of the argument list
17481748
argv( ) List the argument list
1749-
assertEqual( {exp}, {act}) none assert that {exp} equals {act}
1750-
assertFalse( {actual}) none assert that {actual} is false
1751-
assertTrue( {actual}) none assert that {actual} is true
1749+
assert_equal( {exp}, {act} [, {msg}]) none assert that {exp} equals {act}
1750+
assert_false( {actual} [, {msg}]) none assert that {actual} is false
1751+
assert_true( {actual} [, {msg}]) none assert that {actual} is true
17521752
asin( {expr}) Float arc sine of {expr}
17531753
atan( {expr}) Float arc tangent of {expr}
17541754
atan2( {expr}, {expr}) Float arc tangent of {expr1} / {expr2}
@@ -2166,30 +2166,36 @@ argv([{nr}]) The result is the {nr}th file in the argument list of the
21662166
< Without the {nr} argument a |List| with the whole |arglist| is
21672167
returned.
21682168

2169-
*assertEqual()*
2170-
assertEqual({expected}, {actual})
2169+
*assert_equal()*
2170+
assert_equal({expected}, {actual}, [, {msg}])
21712171
When {expected} and {actual} are not equal an error message is
21722172
added to |v:errors|.
21732173
There is no automatic conversion, the String "4" is different
21742174
from the Number 4. And the number 4 is different from the
21752175
Float 4.0. The value of 'ignorecase' is not used here, case
21762176
always matters.
2177+
When {msg} is omitted an error in the form "Expected
2178+
{expected} but got {actual}" is produced.
21772179
Example: >
2178-
assertEqual('foo', 'bar')
2180+
assert_equal('foo', 'bar')
21792181
< Will result in a string to be added to |v:errors|:
21802182
test.vim line 12: Expected 'foo' but got 'bar' ~
21812183

2182-
assertFalse({actual}) *assertFalse()*
2184+
assert_false({actual}, [, {msg}]) *assert_false()*
21832185
When {actual} is not false an error message is added to
2184-
|v:errors|, like with |assertEqual()|..
2186+
|v:errors|, like with |assert_equal()|..
21852187
A value is false when it is zero. When "{actual}" is not a
21862188
number the assert fails.
2189+
When {msg} is omitted an error in the form "Expected False but
2190+
got {actual}" is produced.
21872191

2188-
assertTrue({actual}) *assertTrue()*
2192+
assert_true({actual}, [, {msg}]) *assert_true()*
21892193
When {actual} is not true an error message is added to
2190-
|v:errors|, like with |assertEqual()|..
2194+
|v:errors|, like with |assert_equal()|..
21912195
A value is true when it is a non-zeron number. When {actual}
21922196
is not a number the assert fails.
2197+
When {msg} is omitted an error in the form "Expected True but
2198+
got {actual}" is produced.
21932199

21942200
asin({expr}) *asin()*
21952201
Return the arc sine of {expr} measured in radians, as a |Float|

runtime/doc/usr_41.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*usr_41.txt* For Vim version 7.4. Last change: 2014 Aug 16
1+
*usr_41.txt* For Vim version 7.4. Last change: 2015 Nov 30
22

33
VIM USER MANUAL - by Bram Moolenaar
44

@@ -888,6 +888,11 @@ Mappings: *mapping-functions*
888888
maparg() get rhs of a mapping
889889
wildmenumode() check if the wildmode is active
890890

891+
Testing: *test-functions*
892+
assert_equal() assert that two expressions values are equal
893+
assert_false() assert that an expression is false
894+
assert_true() assert that an expression is true
895+
891896
Various: *various-functions*
892897
mode() get current editing mode
893898
visualmode() last visual mode used

src/testdir/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
6868
test_utf8.out \
6969
test_writefile.out
7070

71-
NEW_TESTS = test_assert.res
71+
NEW_TESTS = test_assert.res \
72+
test_undolevels.res
7273

7374
SCRIPTS_GUI = test16.out
7475

src/testdir/test100.in

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,8 @@
1-
Tests for 'undolevel' and 'lispwords' settings being global-local
1+
Tests for 'lispwords' settings being global-local
22

33
STARTTEST
44
:so small.vim
5-
:set nocompatible viminfo+=nviminfo ul=5
6-
:fu! FillBuffer()
7-
:for i in range(1,13)
8-
:put=i
9-
:exe "setg ul=" . &g:ul
10-
:endfor
11-
:endfu
12-
:fu! UndoLevel()
13-
:redir @a | setglobal undolevels? | echon ' global' | setlocal undolevels? | echon ' local' |redir end
14-
:$put a
15-
:endfu
16-
:new one
17-
:0put ='ONE: expecting global undolevels: 5, local undolevels: -123456 (default)'
18-
:call FillBuffer()
19-
:earlier 10
20-
:call UndoLevel()
21-
:set ff=unix
22-
:%w! test.out
23-
:new two
24-
:0put ='TWO: expecting global undolevels: 5, local undolevels: 2 (first) then 10 (afterwards)'
25-
:setlocal ul=2
26-
:call FillBuffer()
27-
:earlier 10
28-
:call UndoLevel()
29-
:setlocal ul=10
30-
:call UndoLevel()
31-
:set ff=unix
32-
:%w >> test.out
33-
:wincmd p
34-
:redir >>test.out | echo "global value shouldn't be changed and still be 5!" | echo 'ONE: expecting global undolevels: 5, local undolevels: -123456 (default)'|:setglobal undolevels? | echon ' global' | setlocal undolevels? | echon ' local' |echo "" |redir end
35-
:new three
36-
:setglobal ul=50
37-
:1put ='global value should be changed to 50'
38-
:2put ='THREE: expecting global undolevels: 50, local undolevels: -123456 (default)'
39-
:call UndoLevel()
40-
:set ff=unix
41-
:%w >> test.out
42-
:"sleep 10
5+
:set nocompatible viminfo+=nviminfo
436
:"
447
:" Testing 'lispwords'
458
:"

src/testdir/test100.ok

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,3 @@
1-
ONE: expecting global undolevels: 5, local undolevels: -123456 (default)
2-
1
3-
2
4-
3
5-
4
6-
5
7-
6
8-
7
9-
10-
11-
undolevels=5 global
12-
undolevels=-123456 local
13-
TWO: expecting global undolevels: 5, local undolevels: 2 (first) then 10 (afterwards)
14-
1
15-
2
16-
3
17-
4
18-
5
19-
6
20-
7
21-
8
22-
9
23-
10
24-
25-
26-
undolevels=5 global
27-
undolevels=2 local
28-
29-
undolevels=5 global
30-
undolevels=10 local
31-
32-
global value shouldn't be changed and still be 5!
33-
ONE: expecting global undolevels: 5, local undolevels: -123456 (default)
34-
undolevels=5 global
35-
undolevels=-123456 local
36-
37-
global value should be changed to 50
38-
THREE: expecting global undolevels: 50, local undolevels: -123456 (default)
39-
40-
undolevels=50 global
41-
undolevels=-123456 local
421

432
Testing 'lispwords' local value
443
lispwords=foo,bar,baz

src/testdir/test_assert.vim

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
" Test that the methods used for testing work.
22

3-
func Test_assertFalse()
4-
call assertFalse(0)
3+
func Test_assert_false()
4+
call assert_false(0)
55
endfunc
66

7-
func Test_assertTrue()
8-
call assertTrue(1)
9-
call assertTrue(123)
7+
func Test_assert_true()
8+
call assert_true(1)
9+
call assert_true(123)
1010
endfunc
1111

12-
func Test_assertEqual()
12+
func Test_assert_equal()
1313
let s = 'foo'
14-
call assertEqual('foo', s)
14+
call assert_equal('foo', s)
1515
let n = 4
16-
call assertEqual(4, n)
16+
call assert_equal(4, n)
1717
let l = [1, 2, 3]
18-
call assertEqual([1, 2, 3], l)
18+
call assert_equal([1, 2, 3], l)
1919
endfunc

src/testdir/test_undolevels.vim

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
" Tests for 'undolevels'
2+
3+
set nocompatible viminfo+=nviminfo
4+
5+
func FillBuffer()
6+
for i in range(1,13)
7+
put=i
8+
" Set 'undolevels' to split undo.
9+
exe "setg ul=" . &g:ul
10+
endfor
11+
endfunc
12+
13+
func Test_global_local_undolevels()
14+
new one
15+
set undolevels=5
16+
call FillBuffer()
17+
" will only undo the last 5 changes, end up with 13 - (5 + 1) = 7 lines
18+
earlier 10
19+
call assert_equal(5, &g:undolevels)
20+
call assert_equal(-123456, &l:undolevels)
21+
call assert_equal('7', getline('$'))
22+
23+
new two
24+
setlocal undolevels=2
25+
call FillBuffer()
26+
" will only undo the last 2 changes, end up with 13 - (2 + 1) = 10 lines
27+
earlier 10
28+
call assert_equal(5, &g:undolevels)
29+
call assert_equal(2, &l:undolevels)
30+
call assert_equal('10', getline('$'))
31+
32+
setlocal ul=10
33+
call assert_equal(5, &g:undolevels)
34+
call assert_equal(10, &l:undolevels)
35+
36+
" Setting local value in "two" must not change local value in "one"
37+
wincmd p
38+
call assert_equal(5, &g:undolevels)
39+
call assert_equal(-123456, &l:undolevels)
40+
41+
new three
42+
setglobal ul=50
43+
call assert_equal(50, &g:undolevels)
44+
call assert_equal(-123456, &l:undolevels)
45+
46+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
945,
744746
/**/
745747
944,
746748
/**/

0 commit comments

Comments
 (0)