blob: 50c89f8dc2f33c0c0cfbf2130a6330859e76b673 [file] [log] [blame]
Bram Moolenaar6b0e5282020-06-04 15:52:25 +02001" Test to verify that the three function lists,
2"
3" global_functions[] in src/evalfunc.c
Bram Moolenaarbe4e2232021-12-27 21:42:57 +00004" *functions* in runtime/doc/builtin.txt
Bram Moolenaar6b0e5282020-06-04 15:52:25 +02005" *function-list* in runtime/doc/usr_41.txt
6"
7" contain the same functions and that the global_functions and ":help
8" functions" lists are in ASCII order.
9
10func Test_function_lists()
11
12 " Delete any files left over from an earlier run of this test.
13
14 call delete("Xglobal_functions.diff")
15 call delete("Xfunctions.diff")
16 call delete("Xfunction-list.diff")
17
18 " Create a file of the functions in evalfunc.c:global_functions[].
19
20 enew!
21 read ../evalfunc.c
22 1,/^static funcentry_T global_functions\[\] =$/d
23 call search('^};$')
24 .,$d
25 v/^ {/d
26 %s/^ {"//
27 %s/".*//
28 w! Xglobal_functions
29
30 " Verify that those functions are in ASCII order.
31
32 sort u
33 w! Xsorted_global_functions
34 let l:unequal = assert_equalfile("Xsorted_global_functions", "Xglobal_functions",
35 \ "global_functions[] not sorted")
36 if l:unequal && executable("diff")
37 call system("diff -u Xsorted_global_functions Xglobal_functions > Xglobal_functions.diff")
38 endif
39
40 " Create a file of the functions in evalfunc.c:global_functions[] that are
41 " not obsolete, sorted in ASCII order.
42
43 enew!
44 read ../evalfunc.c
45 1,/^static funcentry_T global_functions\[\] =$/d
46 call search('^};$')
47 .,$d
48 v/^ {/d
49 g/\/\/ obsolete$/d
50 %s/^ {"//
51 %s/".*//
52 sort u
Bram Moolenaar91558252020-06-04 17:19:05 +020053 w! ++ff=unix Xsorted_current_global_functions
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020054
55 " Verify that the ":help functions" list is complete and in ASCII order.
56
57 enew!
Bram Moolenaarbe4e2232021-12-27 21:42:57 +000058 if filereadable('../../doc/builtin.txt')
Bram Moolenaar1bb0da22021-05-02 19:15:05 +020059 " unpacked MS-Windows zip archive
Bram Moolenaarbe4e2232021-12-27 21:42:57 +000060 read ../../doc/builtin.txt
Bram Moolenaar1bb0da22021-05-02 19:15:05 +020061 else
Bram Moolenaarbe4e2232021-12-27 21:42:57 +000062 read ../../runtime/doc/builtin.txt
Bram Moolenaar1bb0da22021-05-02 19:15:05 +020063 endif
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020064 call search('^USAGE')
65 1,.d
Bram Moolenaarbe4e2232021-12-27 21:42:57 +000066 call search('^==========')
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020067 .,$d
68 v/^\S/d
69 %s/(.*//
70 let l:lines = getline(1, '$')
71 call uniq(l:lines)
72 call writefile(l:lines, "Xfunctions")
73 let l:unequal = assert_equalfile("Xsorted_current_global_functions", "Xfunctions",
74 \ "\":help functions\" not sorted or incomplete")
75 if l:unequal && executable("diff")
76 call system("diff -u Xsorted_current_global_functions Xfunctions > Xfunctions.diff")
77 endif
78
79 " Verify that the ":help function-list" list is complete.
80
81 enew!
Bram Moolenaar1bb0da22021-05-02 19:15:05 +020082 if filereadable('../../doc/usr_41.txt')
83 " unpacked MS-Windows zip archive
84 read ../../doc/usr_41.txt
85 else
86 read ../../runtime/doc/usr_41.txt
87 endif
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020088 call search('\*function-list\*$')
89 1,.d
90 call search('^==*$')
91 .,$d
92 v/^\t\S/d
93 %s/(.*//
94 %left
95 sort u
Bram Moolenaar91558252020-06-04 17:19:05 +020096 w! ++ff=unix Xfunction-list
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020097 let l:unequal = assert_equalfile("Xsorted_current_global_functions", "Xfunction-list",
Bram Moolenaarf7a023e2021-06-07 18:50:01 +020098 \ "\":help function-list\" incomplete")
Bram Moolenaar6b0e5282020-06-04 15:52:25 +020099 if l:unequal && executable("diff")
100 call system("diff -u Xsorted_current_global_functions Xfunction-list > Xfunction-list.diff")
101 endif
102
103 " Clean up.
Bram Moolenaar6b0e5282020-06-04 15:52:25 +0200104 call delete("Xglobal_functions")
105 call delete("Xsorted_global_functions")
106 call delete("Xsorted_current_global_functions")
107 call delete("Xfunctions")
108 call delete("Xfunction-list")
109 enew!
110
111endfunc
112
113" vim: shiftwidth=2 sts=2 expandtab