annotate src/testdir/test_utf8_comparisons.vim @ 15406:63b02fcf1361 v8.1.0711

patch 8.1.0711: test files still use function! commit https://github.com/vim/vim/commit/1e1153600c0377472d62cc553173fe555ddcf5a7 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 9 23:01:02 2019 +0100 patch 8.1.0711: test files still use function! Problem: Test files still use function!. Solution: Remove the exclamation mark. Fix overwriting a function.
author Bram Moolenaar <Bram@vim.org>
date Wed, 09 Jan 2019 23:15:05 +0100
parents 4e66689bced6
children 2dcaa860e3fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for case-insensitive UTF-8 comparisons (utf_strnicmp() in mbyte.c)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Also test "g~ap".
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 if !has("multi_byte")
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 finish
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 endif
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
8 func Ch(a, op, b, expected)
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 call assert_equal(eval(printf('"%s" %s "%s"', a:a, a:op, a:b)), a:expected,
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 \ printf('"%s" %s "%s" should return %d', a:a, a:op, a:b, a:expected))
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
11 endfunc
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
13 func Chk(a, b, result)
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 if a:result == 0
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call Ch(a:a, '==?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call Ch(a:a, '!=?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call Ch(a:a, '<=?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call Ch(a:a, '>=?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call Ch(a:a, '<?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call Ch(a:a, '>?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 elseif a:result > 0
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call Ch(a:a, '==?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call Ch(a:a, '!=?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 call Ch(a:a, '<=?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call Ch(a:a, '>=?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 call Ch(a:a, '<?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call Ch(a:a, '>?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 else
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 call Ch(a:a, '==?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 call Ch(a:a, '!=?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call Ch(a:a, '<=?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call Ch(a:a, '>=?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 call Ch(a:a, '<?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 call Ch(a:a, '>?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 endif
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
36 endfunc
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
38 func Check(a, b, result)
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 call Chk(a:a, a:b, a:result)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call Chk(a:b, a:a, -a:result)
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
41 endfunc
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
43 func LT(a, b)
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 call Check(a:a, a:b, -1)
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
45 endfunc
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
47 func GT(a, b)
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call Check(a:a, a:b, 1)
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
49 endfunc
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
51 func EQ(a, b)
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call Check(a:a, a:b, 0)
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
53 endfunc
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
55 func Test_comparisons()
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 call EQ('', '')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 call LT('', 'a')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 call EQ('abc', 'abc')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 call EQ('Abc', 'abC')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 call LT('ab', 'abc')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 call LT('AB', 'abc')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 call LT('ab', 'aBc')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
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')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
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')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 call EQ('\xe2\x84\xaa', 'k')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 call LT('\xe2\x84\xaa', 'kkkkkk')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 call EQ('\xe2\x84\xaa\xe2\x84\xaa\xe2\x84\xaa', 'kkk')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 call LT('kk', '\xe2\x84\xaa\xe2\x84\xaa\xe2\x84\xaa')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 call EQ('\xe2\x84\xaa\xe2\x84\xa6k\xe2\x84\xaak\xcf\x89', 'k\xcf\x89\xe2\x84\xaakk\xe2\x84\xa6')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 call EQ('Abc\x80', 'AbC\x80')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 call LT('Abc\x80', 'AbC\x81')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 call LT('Abc', 'AbC\x80')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 call LT('abc\x80DEF', 'abc\x80def') " case folding stops at the first bad character
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 call LT('\xc3XYZ', '\xc3xyz')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 call EQ('\xef\xbc\xba', '\xef\xbd\x9a') " FF3A (upper), FF5A (lower)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
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
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 call LT('\xc3', '\xc3\x83')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 call EQ('\xc3\xa3xYz', '\xc3\x83XyZ')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 for n in range(0x60, 0xFF)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 call LT(printf('xYz\x%.2X', n-1), printf('XyZ\x%.2X', n))
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 endfor
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 for n in range(0x80, 0xBF)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 call EQ(printf('xYz\xc2\x%.2XUvW', n), printf('XyZ\xc2\x%.2XuVw', n))
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 endfor
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 for n in range(0xC0, 0xFF)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 call LT(printf('xYz\xc2\x%.2XUvW', n), printf('XyZ\xc2\x%.2XuVw', n))
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 endfor
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
88 endfunc
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 " test that g~ap changes one paragraph only.
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
91 func Test_gap()
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 new
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 call feedkeys("iabcd\n\ndefggg0g~ap", "tx")
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 call assert_equal(["ABCD", "", "defg"], getline(1,3))
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11603
diff changeset
95 endfunc