Mercurial > vim
annotate src/testdir/test_function_lists.vim @ 21604:d9c45474cac1 v8.2.1352
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Commit: https://github.com/vim/vim/commit/ad486a0f0dd194826fdb733516bf0f35382c9dd7
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 1 23:22:18 2020 +0200
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Problem: Vim9: no error for shadowing a script-local function by a nested
function.
Solution: Check for script-local function. (closes #6586)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 01 Aug 2020 23:30:03 +0200 |
parents | f342bdc79295 |
children | 27033b8bba0e |
rev | line source |
---|---|
20689
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Test to verify that the three function lists, |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 " |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 " global_functions[] in src/evalfunc.c |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 " *functions* in runtime/doc/eval.txt |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 " *function-list* in runtime/doc/usr_41.txt |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 " |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 " contain the same functions and that the global_functions and ":help |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 " functions" lists are in ASCII order. |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 func Test_function_lists() |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 " Delete any files left over from an earlier run of this test. |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 call delete("Xglobal_functions.diff") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 call delete("Xfunctions.diff") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 call delete("Xfunction-list.diff") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 " Create a file of the functions in evalfunc.c:global_functions[]. |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 enew! |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 read ../evalfunc.c |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 1,/^static funcentry_T global_functions\[\] =$/d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 call search('^};$') |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 .,$d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 v/^ {/d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 %s/^ {"// |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 %s/".*// |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 w! Xglobal_functions |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 " Verify that those functions are in ASCII order. |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 sort u |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 w! Xsorted_global_functions |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 let l:unequal = assert_equalfile("Xsorted_global_functions", "Xglobal_functions", |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 \ "global_functions[] not sorted") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 if l:unequal && executable("diff") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 call system("diff -u Xsorted_global_functions Xglobal_functions > Xglobal_functions.diff") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 endif |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 " Create a file of the functions in evalfunc.c:global_functions[] that are |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 " not obsolete, sorted in ASCII order. |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 enew! |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 read ../evalfunc.c |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 1,/^static funcentry_T global_functions\[\] =$/d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 call search('^};$') |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 .,$d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 v/^ {/d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 g/\/\/ obsolete$/d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 %s/^ {"// |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 %s/".*// |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 sort u |
20693
f342bdc79295
patch 8.2.0900: function list test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
20689
diff
changeset
|
53 w! ++ff=unix Xsorted_current_global_functions |
20689
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 " Verify that the ":help functions" list is complete and in ASCII order. |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 enew! |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 read ../../runtime/doc/eval.txt |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 call search('\*functions\*$') |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 call search('^USAGE') |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 1,.d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 call search('\*\K\k*()\*$') |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 .,$d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 v/^\S/d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 %s/(.*// |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 let l:lines = getline(1, '$') |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 call uniq(l:lines) |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 call writefile(l:lines, "Xfunctions") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 let l:unequal = assert_equalfile("Xsorted_current_global_functions", "Xfunctions", |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 \ "\":help functions\" not sorted or incomplete") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 if l:unequal && executable("diff") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 call system("diff -u Xsorted_current_global_functions Xfunctions > Xfunctions.diff") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 endif |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 " Verify that the ":help function-list" list is complete. |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 enew! |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 read ../../runtime/doc/usr_41.txt |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 call search('\*function-list\*$') |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 1,.d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 call search('^==*$') |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 .,$d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 v/^\t\S/d |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 %s/(.*// |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 %left |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 sort u |
20693
f342bdc79295
patch 8.2.0900: function list test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
20689
diff
changeset
|
87 w! ++ff=unix Xfunction-list |
20689
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 let l:unequal = assert_equalfile("Xsorted_current_global_functions", "Xfunction-list", |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 \ "\":help functions-list\" incomplete") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 if l:unequal && executable("diff") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 call system("diff -u Xsorted_current_global_functions Xfunction-list > Xfunction-list.diff") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 endif |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 " Clean up. |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 call delete("Xglobal_functions") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 call delete("Xsorted_global_functions") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 call delete("Xsorted_current_global_functions") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 call delete("Xfunctions") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 call delete("Xfunction-list") |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 enew! |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 endfunc |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 |
b005de48b374
patch 8.2.0898: missing help for a function goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 " vim: shiftwidth=2 sts=2 expandtab |