Skip to content

Commit 28b2382

Browse files
committed
patch 8.0.0684: old style tests are not nice
Problem: Old style tests are not nice. Solution: Turn two tests into new style. (pschuh, closes #1797)
1 parent 2e147ca commit 28b2382

File tree

10 files changed

+125
-173
lines changed

10 files changed

+125
-173
lines changed

src/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,8 +2089,8 @@ test1 \
20892089
test50 test51 test52 test53 test54 test55 test56 test57 test59 \
20902090
test60 test64 test66 test67 test68 test69 \
20912091
test70 test72 test73 test74 test75 test77 test78 test79 \
2092-
test80 test82 test83 test84 test85 test86 test87 test88 \
2093-
test90 test91 test94 test95 test97 test98 test99 \
2092+
test80 test83 test84 test85 test86 test87 test88 \
2093+
test91 test94 test95 test97 test98 test99 \
20942094
test100 test101 test103 test104 test107 test108:
20952095
cd testdir; rm -f [email protected]; $(MAKE) -f Makefile [email protected] VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
20962096

@@ -2207,6 +2207,7 @@ test_arglist \
22072207
test_search \
22082208
test_searchpos \
22092209
test_set \
2210+
test_sha256 \
22102211
test_signs \
22112212
test_smartindent \
22122213
test_sort \
@@ -2233,6 +2234,7 @@ test_arglist \
22332234
test_unlet \
22342235
test_usercommands \
22352236
test_utf8 \
2237+
test_utf8_comparisons \
22362238
test_viminfo \
22372239
test_vimscript \
22382240
test_visual \

src/testdir/Make_all.mak

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ SCRIPTS_ALL = \
6060
test77.out \
6161
test79.out \
6262
test80.out \
63-
test82.out \
6463
test84.out \
6564
test88.out \
66-
test90.out \
6765
test91.out \
6866
test94.out \
6967
test95.out \

src/testdir/Make_vms.mms

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ SCRIPT = test1.out test3.out test4.out test5.out \
9191
test66.out test67.out test68.out test69.out \
9292
test72.out test75.out \
9393
test77a.out test78.out test79.out test80.out \
94-
test82.out test84.out test88.out \
95-
test90.out test91.out test94.out \
94+
test84.out test88.out \
95+
test91.out test94.out \
9696
test95.out test98.out test99.out \
9797
test103.out test104.out \
9898
test107.out test108.out\

src/testdir/test82.in

Lines changed: 0 additions & 103 deletions
This file was deleted.

src/testdir/test82.ok

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/testdir/test90.in

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/testdir/test90.ok

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/testdir/test_sha256.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
" Tests for the sha256() function.
2+
3+
if !has('cryptv') || !exists('*sha256')
4+
finish
5+
endif
6+
7+
function Test_sha256()
8+
" test for empty string:
9+
call assert_equal(sha256(""), 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855')
10+
11+
"'test for 1 char:
12+
call assert_equal(sha256("a"), 'ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb')
13+
"
14+
"test for 3 chars:
15+
call assert_equal(sha256("abc"), 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad')
16+
17+
" test for contains meta char:
18+
call assert_equal(sha256("foo\nbar"), '807eff6267f3f926a21d234f7b0cf867a86f47e07a532f15e8cc39ed110ca776')
19+
20+
" test for contains non-ascii char:
21+
call assert_equal(sha256("\xde\xad\xbe\xef"), '5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953')
22+
endfunction
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
" Tests for case-insensitive UTF-8 comparisons (utf_strnicmp() in mbyte.c)
2+
" Also test "g~ap".
3+
4+
if !has("multi_byte")
5+
finish
6+
endif
7+
8+
function! Ch(a, op, b, expected)
9+
call assert_equal(eval(printf('"%s" %s "%s"', a:a, a:op, a:b)), a:expected,
10+
\ printf('"%s" %s "%s" should return %d', a:a, a:op, a:b, a:expected))
11+
endfunction
12+
13+
function! Chk(a, b, result)
14+
if a:result == 0
15+
call Ch(a:a, '==?', a:b, 1)
16+
call Ch(a:a, '!=?', a:b, 0)
17+
call Ch(a:a, '<=?', a:b, 1)
18+
call Ch(a:a, '>=?', a:b, 1)
19+
call Ch(a:a, '<?', a:b, 0)
20+
call Ch(a:a, '>?', a:b, 0)
21+
elseif a:result > 0
22+
call Ch(a:a, '==?', a:b, 0)
23+
call Ch(a:a, '!=?', a:b, 1)
24+
call Ch(a:a, '<=?', a:b, 0)
25+
call Ch(a:a, '>=?', a:b, 1)
26+
call Ch(a:a, '<?', a:b, 0)
27+
call Ch(a:a, '>?', a:b, 1)
28+
else
29+
call Ch(a:a, '==?', a:b, 0)
30+
call Ch(a:a, '!=?', a:b, 1)
31+
call Ch(a:a, '<=?', a:b, 1)
32+
call Ch(a:a, '>=?', a:b, 0)
33+
call Ch(a:a, '<?', a:b, 1)
34+
call Ch(a:a, '>?', a:b, 0)
35+
endif
36+
endfunction
37+
38+
function! Check(a, b, result)
39+
call Chk(a:a, a:b, a:result)
40+
call Chk(a:b, a:a, -a:result)
41+
endfunction
42+
43+
function! LT(a, b)
44+
call Check(a:a, a:b, -1)
45+
endfunction
46+
47+
function! GT(a, b)
48+
call Check(a:a, a:b, 1)
49+
endfunction
50+
51+
function! EQ(a, b)
52+
call Check(a:a, a:b, 0)
53+
endfunction
54+
55+
function Test_comparisons()
56+
call EQ('', '')
57+
call LT('', 'a')
58+
call EQ('abc', 'abc')
59+
call EQ('Abc', 'abC')
60+
call LT('ab', 'abc')
61+
call LT('AB', 'abc')
62+
call LT('ab', 'aBc')
63+
call EQ('\xd0\xb9\xd1\x86\xd1\x83\xd0\xba\xd0\xb5\xd0\xbd', '\xd0\xb9\xd0\xa6\xd0\xa3\xd0\xba\xd0\x95\xd0\xbd')
64+
call LT('\xd0\xb9\xd1\x86\xd1\x83\xd0\xba\xd0\xb5\xd0\xbd', '\xd0\xaf\xd1\x86\xd1\x83\xd0\xba\xd0\xb5\xd0\xbd')
65+
call EQ('\xe2\x84\xaa', 'k')
66+
call LT('\xe2\x84\xaa', 'kkkkkk')
67+
call EQ('\xe2\x84\xaa\xe2\x84\xaa\xe2\x84\xaa', 'kkk')
68+
call LT('kk', '\xe2\x84\xaa\xe2\x84\xaa\xe2\x84\xaa')
69+
call EQ('\xe2\x84\xaa\xe2\x84\xa6k\xe2\x84\xaak\xcf\x89', 'k\xcf\x89\xe2\x84\xaakk\xe2\x84\xa6')
70+
call EQ('Abc\x80', 'AbC\x80')
71+
call LT('Abc\x80', 'AbC\x81')
72+
call LT('Abc', 'AbC\x80')
73+
call LT('abc\x80DEF', 'abc\x80def') " case folding stops at the first bad character
74+
call LT('\xc3XYZ', '\xc3xyz')
75+
call EQ('\xef\xbc\xba', '\xef\xbd\x9a') " FF3A (upper), FF5A (lower)
76+
call GT('\xef\xbc\xba', '\xef\xbc\xff') " first string is ok and equals \xef\xbd\x9a after folding, second string is illegal and was left unchanged, then the strings were bytewise compared
77+
call LT('\xc3', '\xc3\x83')
78+
call EQ('\xc3\xa3xYz', '\xc3\x83XyZ')
79+
for n in range(0x60, 0xFF)
80+
call LT(printf('xYz\x%.2X', n-1), printf('XyZ\x%.2X', n))
81+
endfor
82+
for n in range(0x80, 0xBF)
83+
call EQ(printf('xYz\xc2\x%.2XUvW', n), printf('XyZ\xc2\x%.2XuVw', n))
84+
endfor
85+
for n in range(0xC0, 0xFF)
86+
call LT(printf('xYz\xc2\x%.2XUvW', n), printf('XyZ\xc2\x%.2XuVw', n))
87+
endfor
88+
endfunction
89+
90+
" test that g~ap changes one paragraph only.
91+
function Test_gap()
92+
new
93+
call feedkeys("iabcd\n\ndefggg0g~ap", "tx")
94+
call assert_equal(["ABCD", "", "defg"], getline(1,3))
95+
endfunction

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
684,
767769
/**/
768770
683,
769771
/**/

0 commit comments

Comments
 (0)