| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 1 | " Test to verify that the three function lists, |
| 2 | " |
| 3 | " global_functions[] in src/evalfunc.c |
| 4 | " *functions* in runtime/doc/eval.txt |
| 5 | " *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 | |
| 10 | func 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 Moolenaar | 9155825 | 2020-06-04 17:19:05 +0200 | [diff] [blame] | 53 | w! ++ff=unix Xsorted_current_global_functions |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 54 | |
| 55 | " Verify that the ":help functions" list is complete and in ASCII order. |
| 56 | |
| 57 | enew! |
| Bram Moolenaar | 1bb0da2 | 2021-05-02 19:15:05 +0200 | [diff] [blame] | 58 | if filereadable('../../doc/eval.txt') |
| 59 | " unpacked MS-Windows zip archive |
| 60 | read ../../doc/eval.txt |
| 61 | else |
| 62 | read ../../runtime/doc/eval.txt |
| 63 | endif |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 64 | call search('\*functions\*$') |
| 65 | call search('^USAGE') |
| 66 | 1,.d |
| 67 | call search('\*\K\k*()\*$') |
| 68 | .,$d |
| 69 | v/^\S/d |
| 70 | %s/(.*// |
| 71 | let l:lines = getline(1, '$') |
| 72 | call uniq(l:lines) |
| 73 | call writefile(l:lines, "Xfunctions") |
| 74 | let l:unequal = assert_equalfile("Xsorted_current_global_functions", "Xfunctions", |
| 75 | \ "\":help functions\" not sorted or incomplete") |
| 76 | if l:unequal && executable("diff") |
| 77 | call system("diff -u Xsorted_current_global_functions Xfunctions > Xfunctions.diff") |
| 78 | endif |
| 79 | |
| 80 | " Verify that the ":help function-list" list is complete. |
| 81 | |
| 82 | enew! |
| Bram Moolenaar | 1bb0da2 | 2021-05-02 19:15:05 +0200 | [diff] [blame] | 83 | if filereadable('../../doc/usr_41.txt') |
| 84 | " unpacked MS-Windows zip archive |
| 85 | read ../../doc/usr_41.txt |
| 86 | else |
| 87 | read ../../runtime/doc/usr_41.txt |
| 88 | endif |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 89 | call search('\*function-list\*$') |
| 90 | 1,.d |
| 91 | call search('^==*$') |
| 92 | .,$d |
| 93 | v/^\t\S/d |
| 94 | %s/(.*// |
| 95 | %left |
| 96 | sort u |
| Bram Moolenaar | 9155825 | 2020-06-04 17:19:05 +0200 | [diff] [blame] | 97 | w! ++ff=unix Xfunction-list |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 98 | let l:unequal = assert_equalfile("Xsorted_current_global_functions", "Xfunction-list", |
| Bram Moolenaar | f7a023e | 2021-06-07 18:50:01 +0200 | [diff] [blame] | 99 | \ "\":help function-list\" incomplete") |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 100 | if l:unequal && executable("diff") |
| 101 | call system("diff -u Xsorted_current_global_functions Xfunction-list > Xfunction-list.diff") |
| 102 | endif |
| 103 | |
| 104 | " Clean up. |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 105 | call delete("Xglobal_functions") |
| 106 | call delete("Xsorted_global_functions") |
| 107 | call delete("Xsorted_current_global_functions") |
| 108 | call delete("Xfunctions") |
| 109 | call delete("Xfunction-list") |
| 110 | enew! |
| 111 | |
| 112 | endfunc |
| 113 | |
| 114 | " vim: shiftwidth=2 sts=2 expandtab |