Mercurial > vim
annotate src/testdir/test_xxd.vim @ 14966:d65790af8514 v8.1.0494
patch 8.1.0494: functions do not check for a window ID in other tabs
commit https://github.com/vim/vim/commit/babfcf54ae9bf9570eddf4958a553635cd589e21
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 25 13:11:16 2018 +0200
patch 8.1.0494: functions do not check for a window ID in other tabs
Problem: Functions do not check for a window ID in other tabs.
Solution: Also find the window ID in other than the current tab.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 25 Oct 2018 13:15:05 +0200 |
parents | 1174611ad715 |
children | 63b02fcf1361 |
rev | line source |
---|---|
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test for the xxd command |
13646
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
2 if empty($XXD) && executable('..\xxd\xxd.exe') |
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
3 let s:xxd_cmd = '..\xxd\xxd.exe' |
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
4 elseif empty($XXD) || !executable($XXD) |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 finish |
13646
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
6 else |
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
7 let s:xxd_cmd = $XXD |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 endif |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 |
13638
b3068807f5df
patch 8.0.1691: xxd test sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
13634
diff
changeset
|
10 func! PrepareBuffer(lines) |
b3068807f5df
patch 8.0.1691: xxd test sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
13634
diff
changeset
|
11 new |
b3068807f5df
patch 8.0.1691: xxd test sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
13634
diff
changeset
|
12 call append(0, a:lines) |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 $d |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 endfunc |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 func! s:Mess(counter) |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 return printf("Failed xxd test %d:", a:counter) |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 endfunc |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 func! Test_xxd() |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 call PrepareBuffer(range(1,30)) |
13646
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
22 set ff=unix |
13638
b3068807f5df
patch 8.0.1691: xxd test sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
13634
diff
changeset
|
23 w XXDfile |
b3068807f5df
patch 8.0.1691: xxd test sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
13634
diff
changeset
|
24 |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 " Test 1: simple, filter the result through xxd |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 let s:test = 1 |
13646
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
27 exe '%!' . s:xxd_cmd . ' %' |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 let expected = [ |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 \ '00000000: 310a 320a 330a 340a 350a 360a 370a 380a 1.2.3.4.5.6.7.8.', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 \ '00000010: 390a 3130 0a31 310a 3132 0a31 330a 3134 9.10.11.12.13.14', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 \ '00000020: 0a31 350a 3136 0a31 370a 3138 0a31 390a .15.16.17.18.19.', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 \ '00000030: 3230 0a32 310a 3232 0a32 330a 3234 0a32 20.21.22.23.24.2', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 \ '00000040: 350a 3236 0a32 370a 3238 0a32 390a 3330 5.26.27.28.29.30', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 \ '00000050: 0a .'] |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 call assert_equal(expected, getline(1,'$'), s:Mess(s:test)) |
13638
b3068807f5df
patch 8.0.1691: xxd test sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
13634
diff
changeset
|
36 |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 " Test 2: reverse the result |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 let s:test += 1 |
13646
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
39 exe '%!' . s:xxd_cmd . ' -r' |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 call assert_equal(map(range(1,30), {v,c -> string(c)}), getline(1,'$'), s:Mess(s:test)) |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 " Test 3: Skip the first 30 bytes |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 let s:test += 1 |
13646
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
44 exe '%!' . s:xxd_cmd . ' -s 0x30 %' |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 call assert_equal(expected[3:], getline(1,'$'), s:Mess(s:test)) |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 " Test 4: Skip the first 30 bytes |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 let s:test += 1 |
13646
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
49 exe '%!' . s:xxd_cmd . ' -s -0x31 %' |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 call assert_equal(expected[2:], getline(1,'$'), s:Mess(s:test)) |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 " Test 5: Print 120 bytes as continuous hexdump with 20 octets per line |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 let s:test += 1 |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 %d |
13963 | 55 let fname = '../../runtime/doc/xxd.1' |
56 if has('win32') && !filereadable(fname) | |
57 let fname = '../../doc/xxd.1' | |
58 endif | |
59 exe '0r! ' . s:xxd_cmd . ' -l 120 -ps -c 20 ' . fname | |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 $d |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 let expected = [ |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 \ '2e54482058584420312022417567757374203139', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 \ '39362220224d616e75616c207061676520666f72', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 \ '20787864220a2e5c220a2e5c222032317374204d', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 \ '617920313939360a2e5c22204d616e2070616765', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 \ '20617574686f723a0a2e5c2220202020546f6e79', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 \ '204e7567656e74203c746f6e79407363746e7567'] |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 call assert_equal(expected, getline(1,'$'), s:Mess(s:test)) |
13638
b3068807f5df
patch 8.0.1691: xxd test sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
13634
diff
changeset
|
69 |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 " Test 6: Print the date from xxd.1 |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 let s:test += 1 |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 %d |
13963 | 73 exe '0r! ' . s:xxd_cmd . ' -s 0x36 -l 13 -c 13 ' . fname |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 $d |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 call assert_equal('00000036: 3231 7374 204d 6179 2031 3939 36 21st May 1996', getline(1), s:Mess(s:test)) |
13638
b3068807f5df
patch 8.0.1691: xxd test sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
13634
diff
changeset
|
76 |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 " Test 7: Print C include |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 let s:test += 1 |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 call writefile(['TESTabcd09'], 'XXDfile') |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 %d |
13646
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
81 exe '0r! ' . s:xxd_cmd . ' -i XXDfile' |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 $d |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 let expected = ['unsigned char XXDfile[] = {', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 \ ' 0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 0x0a', '};', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 \ 'unsigned int XXDfile_len = 11;'] |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 call assert_equal(expected, getline(1,'$'), s:Mess(s:test)) |
13638
b3068807f5df
patch 8.0.1691: xxd test sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
13634
diff
changeset
|
87 |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 " Test 8: Print C include capitalized |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 let s:test += 1 |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 call writefile(['TESTabcd09'], 'XXDfile') |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 %d |
13646
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
92 exe '0r! ' . s:xxd_cmd . ' -i -C XXDfile' |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 $d |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 let expected = ['unsigned char XXDFILE[] = {', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 \ ' 0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 0x0a', '};', |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 \ 'unsigned int XXDFILE_LEN = 11;'] |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 call assert_equal(expected, getline(1,'$'), s:Mess(s:test)) |
13638
b3068807f5df
patch 8.0.1691: xxd test sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
13634
diff
changeset
|
98 |
b3068807f5df
patch 8.0.1691: xxd test sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
13634
diff
changeset
|
99 " Test 9: Create a file with containing a single 'A' |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 let s:test += 1 |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 call delete('XXDfile') |
13638
b3068807f5df
patch 8.0.1691: xxd test sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
13634
diff
changeset
|
102 bwipe! XXDfile |
13646
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
103 if has('unix') |
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
104 call system('echo "010000: 41"|' . s:xxd_cmd . ' -r -s -0x10000 > XXDfile') |
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
105 else |
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
106 call writefile(['010000: 41'], 'Xinput') |
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
107 silent exe '!' . s:xxd_cmd . ' -r -s -0x10000 < Xinput > XXDfile' |
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
108 call delete('Xinput') |
86eb21bb5920
patch 8.0.1695: xxd test not run on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13638
diff
changeset
|
109 endif |
13634
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 call PrepareBuffer(readfile('XXDfile')[0]) |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 call assert_equal('A', getline(1), s:Mess(s:test)) |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 call delete('XXDfile') |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
113 %d |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
114 bw! |
2678e38e1de6
patch 8.0.1689: no tests for xxd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 endfunc |