blob: dd69b832608d069673ed05ce81e9502145818d9a [file] [log] [blame]
Bram Moolenaar88456cd2022-11-18 22:14:09 +00001" Test to verify that the three function lists:
Bram Moolenaar6b0e5282020-06-04 15:52:25 +02002"
Bram Moolenaar88456cd2022-11-18 22:14:09 +00003" - global_functions[] in src/evalfunc.c
4" - *functions* in runtime/doc/builtin.txt
5" - *function-list* in runtime/doc/usr_41.txt
Bram Moolenaar6b0e5282020-06-04 15:52:25 +02006"
Bram Moolenaar88456cd2022-11-18 22:14:09 +00007" contain the same functions and that the global_functions and
8" ":help functions" lists are in ASCII order.
Bram Moolenaar6b0e5282020-06-04 15:52:25 +02009
10func Test_function_lists()
11
12 " Delete any files left over from an earlier run of this test.
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020013 call delete("Xglobal_functions.diff")
14 call delete("Xfunctions.diff")
15 call delete("Xfunction-list.diff")
16
17 " Create a file of the functions in evalfunc.c:global_functions[].
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020018 enew!
19 read ../evalfunc.c
20 1,/^static funcentry_T global_functions\[\] =$/d
21 call search('^};$')
22 .,$d
23 v/^ {/d
24 %s/^ {"//
25 %s/".*//
26 w! Xglobal_functions
27
28 " Verify that those functions are in ASCII order.
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020029 sort u
30 w! Xsorted_global_functions
31 let l:unequal = assert_equalfile("Xsorted_global_functions", "Xglobal_functions",
32 \ "global_functions[] not sorted")
33 if l:unequal && executable("diff")
34 call system("diff -u Xsorted_global_functions Xglobal_functions > Xglobal_functions.diff")
35 endif
36
37 " Create a file of the functions in evalfunc.c:global_functions[] that are
38 " not obsolete, sorted in ASCII order.
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020039 enew!
40 read ../evalfunc.c
41 1,/^static funcentry_T global_functions\[\] =$/d
42 call search('^};$')
43 .,$d
44 v/^ {/d
45 g/\/\/ obsolete$/d
46 %s/^ {"//
47 %s/".*//
48 sort u
Bram Moolenaar91558252020-06-04 17:19:05 +020049 w! ++ff=unix Xsorted_current_global_functions
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020050
51 " Verify that the ":help functions" list is complete and in ASCII order.
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020052 enew!
Bram Moolenaarbe4e2232021-12-27 21:42:57 +000053 if filereadable('../../doc/builtin.txt')
Bram Moolenaar1bb0da22021-05-02 19:15:05 +020054 " unpacked MS-Windows zip archive
Bram Moolenaarbe4e2232021-12-27 21:42:57 +000055 read ../../doc/builtin.txt
Bram Moolenaar1bb0da22021-05-02 19:15:05 +020056 else
Bram Moolenaarbe4e2232021-12-27 21:42:57 +000057 read ../../runtime/doc/builtin.txt
Bram Moolenaar1bb0da22021-05-02 19:15:05 +020058 endif
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020059 call search('^USAGE')
60 1,.d
Bram Moolenaarbe4e2232021-12-27 21:42:57 +000061 call search('^==========')
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020062 .,$d
63 v/^\S/d
64 %s/(.*//
65 let l:lines = getline(1, '$')
66 call uniq(l:lines)
67 call writefile(l:lines, "Xfunctions")
68 let l:unequal = assert_equalfile("Xsorted_current_global_functions", "Xfunctions",
69 \ "\":help functions\" not sorted or incomplete")
70 if l:unequal && executable("diff")
71 call system("diff -u Xsorted_current_global_functions Xfunctions > Xfunctions.diff")
72 endif
73
74 " Verify that the ":help function-list" list is complete.
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020075 enew!
Bram Moolenaar1bb0da22021-05-02 19:15:05 +020076 if filereadable('../../doc/usr_41.txt')
77 " unpacked MS-Windows zip archive
78 read ../../doc/usr_41.txt
79 else
80 read ../../runtime/doc/usr_41.txt
81 endif
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020082 call search('\*function-list\*$')
83 1,.d
84 call search('^==*$')
85 .,$d
86 v/^\t\S/d
87 %s/(.*//
88 %left
89 sort u
Bram Moolenaar91558252020-06-04 17:19:05 +020090 w! ++ff=unix Xfunction-list
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020091 let l:unequal = assert_equalfile("Xsorted_current_global_functions", "Xfunction-list",
Bram Moolenaarf7a023e2021-06-07 18:50:01 +020092 \ "\":help function-list\" incomplete")
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020093 if l:unequal && executable("diff")
94 call system("diff -u Xsorted_current_global_functions Xfunction-list > Xfunction-list.diff")
95 endif
96
97 " Clean up.
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020098 call delete("Xglobal_functions")
99 call delete("Xsorted_global_functions")
100 call delete("Xsorted_current_global_functions")
101 call delete("Xfunctions")
102 call delete("Xfunction-list")
103 enew!
104
105endfunc
106
107" vim: shiftwidth=2 sts=2 expandtab