| Bram Moolenaar | 88456cd | 2022-11-18 22:14:09 +0000 | [diff] [blame] | 1 | " Test to verify that the three function lists: |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 2 | " |
| Bram Moolenaar | 88456cd | 2022-11-18 22:14:09 +0000 | [diff] [blame] | 3 | " - global_functions[] in src/evalfunc.c |
| 4 | " - *functions* in runtime/doc/builtin.txt |
| 5 | " - *function-list* in runtime/doc/usr_41.txt |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 6 | " |
| Bram Moolenaar | 88456cd | 2022-11-18 22:14:09 +0000 | [diff] [blame] | 7 | " contain the same functions and that the global_functions and |
| 8 | " ":help functions" lists are in ASCII order. |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 9 | |
| 10 | func Test_function_lists() |
| 11 | |
| 12 | " Delete any files left over from an earlier run of this test. |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 13 | 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 Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 18 | 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 Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 29 | 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 Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 39 | 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 Moolenaar | 9155825 | 2020-06-04 17:19:05 +0200 | [diff] [blame] | 49 | w! ++ff=unix Xsorted_current_global_functions |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 50 | |
| 51 | " Verify that the ":help functions" list is complete and in ASCII order. |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 52 | enew! |
| Bram Moolenaar | be4e223 | 2021-12-27 21:42:57 +0000 | [diff] [blame] | 53 | if filereadable('../../doc/builtin.txt') |
| Bram Moolenaar | 1bb0da2 | 2021-05-02 19:15:05 +0200 | [diff] [blame] | 54 | " unpacked MS-Windows zip archive |
| Bram Moolenaar | be4e223 | 2021-12-27 21:42:57 +0000 | [diff] [blame] | 55 | read ../../doc/builtin.txt |
| Bram Moolenaar | 1bb0da2 | 2021-05-02 19:15:05 +0200 | [diff] [blame] | 56 | else |
| Bram Moolenaar | be4e223 | 2021-12-27 21:42:57 +0000 | [diff] [blame] | 57 | read ../../runtime/doc/builtin.txt |
| Bram Moolenaar | 1bb0da2 | 2021-05-02 19:15:05 +0200 | [diff] [blame] | 58 | endif |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 59 | call search('^USAGE') |
| 60 | 1,.d |
| Bram Moolenaar | be4e223 | 2021-12-27 21:42:57 +0000 | [diff] [blame] | 61 | call search('^==========') |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 62 | .,$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 Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 75 | enew! |
| Bram Moolenaar | 1bb0da2 | 2021-05-02 19:15:05 +0200 | [diff] [blame] | 76 | 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 Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 82 | 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 Moolenaar | 9155825 | 2020-06-04 17:19:05 +0200 | [diff] [blame] | 90 | w! ++ff=unix Xfunction-list |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 91 | let l:unequal = assert_equalfile("Xsorted_current_global_functions", "Xfunction-list", |
| Bram Moolenaar | f7a023e | 2021-06-07 18:50:01 +0200 | [diff] [blame] | 92 | \ "\":help function-list\" incomplete") |
| Bram Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 93 | 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 Moolenaar | 6b0e528 | 2020-06-04 15:52:25 +0200 | [diff] [blame] | 98 | 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 | |
| 105 | endfunc |
| 106 | |
| 107 | " vim: shiftwidth=2 sts=2 expandtab |