Mercurial > vim
annotate runtime/doc/test_urls.vim @ 33278:b5ed566262d3 v9.0.1906
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Commit: https://github.com/vim/vim/commit/92d9ee5f4ca0d2de04c39afbafc7609da43fb2e9
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sun Sep 17 17:03:19 2023 +0200
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Problem: Vim9: Interfaces should not support class methods and
variables
Solution: Make sure interface follow the interface specification
Vim9 interface changes to follow the new interface specification:
1) An interface can have only read-only and read-write instance
variables.
2) An interface can have only public instance methods.
3) An interface cannot have class variables and class methods.
4) An interface cannot have private instance variables and private
instance methods.
5) A interface can extend another interface using "extends". The
sub-interface gets all the variables and methods in the super
interface.
That means:
- Interfaces should not support class methods and variables.
- Adjust error numbers and add additional tests.
- Interface methods can be defined in one of the super classes.
- Interface variables can be defined in one of the super classes.
and instance variables can be repeated in sub interfaces.
- Check the class variable types with the type in interface.
closes: #13100
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 17 Sep 2023 17:15:06 +0200 |
parents | 7fd105bfe992 |
children | e09acb1daea7 |
rev | line source |
---|---|
12952
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test for URLs in help documents. |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 " Opens a new window with all found URLS followed by return code from curl |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 " (anything other than 0 means unreachable) |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 " |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 " Written by Christian Brabandt. |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 func Test_check_URLs() |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 if has("win32") |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 echoerr "Doesn't work on MS-Windows" |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 return |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 endif |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 if executable('curl') |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 " Note: does not follow redirects! |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 let s:command = 'curl --silent --fail --output /dev/null --head ' |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 elseif executable('wget') |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 " Note: only allow a couple of redirects |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 let s:command = 'wget --quiet -S --spider --max-redirect=2 --timeout=5 --tries=2 -O /dev/null ' |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 else |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 echoerr 'Only works when "curl" or "wget" is available' |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 return |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 endif |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 let pat='\(https\?\|ftp\)://[^\t* ]\+' |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 exe 'helpgrep' pat |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 helpclose |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 let urls = map(getqflist(), 'v:val.text') |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 " do not use submatch(1)! |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 let urls = map(urls, {key, val -> matchstr(val, pat)}) |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 " remove examples like user@host (invalid urls) |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 let urls = filter(urls, 'v:val !~ "@"') |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 " Remove example URLs which are invalid |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 let urls = filter(urls, {key, val -> val !~ '\<\(\(my\|some\)\?host\|machine\|hostname\|file\)\>'}) |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 new |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 put =urls |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 " remove some more invalid items |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 " empty lines |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 v/./d |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 " remove # anchors |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 %s/#.*$//e |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 " remove trailing stuff (parenthesis, dot, comma, quotes), but only for HTTP |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 " links |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 g/^h/s#[.,)'"/>][:.]\?$## |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 g#^[hf]t\?tp:/\(/\?\.*\)$#d |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 silent! g/ftp://,$/d |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 silent! g/=$/d |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 let a = getline(1,'$') |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 let a = uniq(sort(a)) |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 %d |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 call setline(1, a) |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 " Do the testing. |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 set nomore |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 %s/.*/\=TestURL(submatch(0))/ |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 " highlight the failures |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 /.* \([0-9]*[1-9]\|[0-9]\{2,}\)$ |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 endfunc |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 func TestURL(url) |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 " Relies on the return code to determine whether a page is valid |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 echom printf("Testing URL: %d/%d %s", line('.'), line('$'), a:url) |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 call system(s:command . shellescape(a:url)) |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 return printf("%s %d", a:url, v:shell_error) |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 endfunc |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 |
7fd105bfe992
patch 8.0.1352: dead URLs in the help go unnoticed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 call Test_check_URLs() |