Mercurial > vim
annotate src/testing.c @ 30132:01919e5a070c v9.0.0402
patch 9.0.0402: javascript module files are not recoginzed
Commit: https://github.com/vim/vim/commit/bb6c4073e79e86ef69c315338e00c12f0d8d6395
Author: Brett Holman <bholman.devel@gmail.com>
Date: Wed Sep 7 14:13:31 2022 +0100
patch 9.0.0402: javascript module files are not recoginzed
Problem: Javascript module files are not recoginzed.
Solution: Recognize "*.jsm" files as Javascript. (Brett Holman,
closes #11069)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 07 Sep 2022 15:15:03 +0200 |
parents | fd855ad74887 |
children | 5380551172aa |
rev | line source |
---|---|
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * testing.c: Support for tests. |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #include "vim.h" |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 #if defined(FEAT_EVAL) || defined(PROTO) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 * Prepare "gap" for an assert error and add the sourcing position. |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 static void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 prepare_assert_error(garray_T *gap) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
24 char buf[NUMBUFLEN]; |
22208
a607f02fd17a
patch 8.2.1653: expand('<stack>') does not include the final line number
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
25 char_u *sname = estack_sfile(ESTACK_NONE); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 ga_init2(gap, 1, 100); |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
28 if (sname != NULL) |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
30 ga_concat(gap, sname); |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
31 if (SOURCING_LNUM > 0) |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 ga_concat(gap, (char_u *)" "); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 } |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
34 if (SOURCING_LNUM > 0) |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
36 sprintf(buf, "line %ld", (long)SOURCING_LNUM); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 ga_concat(gap, (char_u *)buf); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 } |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
39 if (sname != NULL || SOURCING_LNUM > 0) |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 ga_concat(gap, (char_u *)": "); |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
41 vim_free(sname); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 * Append "p[clen]" to "gap", escaping unprintable characters. |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 * Changes NL to \n, CR to \r, etc. |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 static void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 ga_concat_esc(garray_T *gap, char_u *p, int clen) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 char_u buf[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 if (clen > 1) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 mch_memmove(buf, p, clen); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 buf[clen] = NUL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 ga_concat(gap, buf); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 else switch (*p) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 case BS: ga_concat(gap, (char_u *)"\\b"); break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 case ESC: ga_concat(gap, (char_u *)"\\e"); break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 case FF: ga_concat(gap, (char_u *)"\\f"); break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 case NL: ga_concat(gap, (char_u *)"\\n"); break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 case TAB: ga_concat(gap, (char_u *)"\\t"); break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 case CAR: ga_concat(gap, (char_u *)"\\r"); break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 case '\\': ga_concat(gap, (char_u *)"\\\\"); break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 default: |
21297
3ef53d66f30d
patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
69 if (*p < ' ' || *p == 0x7f) |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 vim_snprintf((char *)buf, NUMBUFLEN, "\\x%02x", *p); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 ga_concat(gap, buf); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 ga_append(gap, *p); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 * Append "str" to "gap", escaping unprintable characters. |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 * Changes NL to \n, CR to \r, etc. |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 static void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 ga_concat_shorten_esc(garray_T *gap, char_u *str) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 char_u *p; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 char_u *s; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 int c; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 int clen; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 char_u buf[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 int same_len; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 if (str == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 ga_concat(gap, (char_u *)"NULL"); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 return; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 for (p = str; *p != NUL; ++p) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 same_len = 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 s = p; |
27742
3b2c75c0a7ab
patch 8.2.4397: crash when using many composing characters in error message
Bram Moolenaar <Bram@vim.org>
parents:
27501
diff
changeset
|
104 c = mb_cptr2char_adv(&s); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 clen = s - p; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 while (*s != NUL && c == mb_ptr2char(s)) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 ++same_len; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 s += clen; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 if (same_len > 20) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 ga_concat(gap, (char_u *)"\\["); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 ga_concat_esc(gap, p, clen); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 ga_concat(gap, (char_u *)" occurs "); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 vim_snprintf((char *)buf, NUMBUFLEN, "%d", same_len); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 ga_concat(gap, buf); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 ga_concat(gap, (char_u *)" times]"); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 p = s - 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 ga_concat_esc(gap, p, clen); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 * Fill "gap" with information about an assert error. |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 static void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 fill_assert_error( |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 garray_T *gap, |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 typval_T *opt_msg_tv, |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 char_u *exp_str, |
20834
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
134 typval_T *exp_tv_arg, |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
135 typval_T *got_tv_arg, |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 assert_type_T atype) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 char_u numbuf[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 char_u *tofree; |
20834
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
140 typval_T *exp_tv = exp_tv_arg; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
141 typval_T *got_tv = got_tv_arg; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
142 int did_copy = FALSE; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
143 int omitted = 0; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 |
21859
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
145 if (opt_msg_tv->v_type != VAR_UNKNOWN |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
146 && !(opt_msg_tv->v_type == VAR_STRING |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
147 && (opt_msg_tv->vval.v_string == NULL |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
148 || *opt_msg_tv->vval.v_string == NUL))) |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 ga_concat(gap, echo_string(opt_msg_tv, &tofree, numbuf, 0)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 vim_free(tofree); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 ga_concat(gap, (char_u *)": "); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 ga_concat(gap, (char_u *)"Pattern "); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 else if (atype == ASSERT_NOTEQUAL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 ga_concat(gap, (char_u *)"Expected not equal to "); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 ga_concat(gap, (char_u *)"Expected "); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 if (exp_str == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 { |
20834
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
163 // When comparing dictionaries, drop the items that are equal, so that |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
164 // it's a lot easier to see what differs. |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
165 if (atype != ASSERT_NOTEQUAL |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
166 && exp_tv->v_type == VAR_DICT && got_tv->v_type == VAR_DICT |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
167 && exp_tv->vval.v_dict != NULL && got_tv->vval.v_dict != NULL) |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
168 { |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
169 dict_T *exp_d = exp_tv->vval.v_dict; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
170 dict_T *got_d = got_tv->vval.v_dict; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
171 hashitem_T *hi; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
172 dictitem_T *item2; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
173 int todo; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
174 |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
175 did_copy = TRUE; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
176 exp_tv->vval.v_dict = dict_alloc(); |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
177 got_tv->vval.v_dict = dict_alloc(); |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
178 if (exp_tv->vval.v_dict == NULL || got_tv->vval.v_dict == NULL) |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
179 return; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
180 |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
181 todo = (int)exp_d->dv_hashtab.ht_used; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
182 for (hi = exp_d->dv_hashtab.ht_array; todo > 0; ++hi) |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
183 { |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
184 if (!HASHITEM_EMPTY(hi)) |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
185 { |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
186 item2 = dict_find(got_d, hi->hi_key, -1); |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
187 if (item2 == NULL || !tv_equal(&HI2DI(hi)->di_tv, |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
188 &item2->di_tv, FALSE, FALSE)) |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
189 { |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
190 // item of exp_d not present in got_d or values differ. |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
191 dict_add_tv(exp_tv->vval.v_dict, |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
192 (char *)hi->hi_key, &HI2DI(hi)->di_tv); |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
193 if (item2 != NULL) |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
194 dict_add_tv(got_tv->vval.v_dict, |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
195 (char *)hi->hi_key, &item2->di_tv); |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
196 } |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
197 else |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
198 ++omitted; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
199 --todo; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
200 } |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
201 } |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
202 |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
203 // Add items only present in got_d. |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
204 todo = (int)got_d->dv_hashtab.ht_used; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
205 for (hi = got_d->dv_hashtab.ht_array; todo > 0; ++hi) |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
206 { |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
207 if (!HASHITEM_EMPTY(hi)) |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
208 { |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
209 item2 = dict_find(exp_d, hi->hi_key, -1); |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
210 if (item2 == NULL) |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
211 // item of got_d not present in exp_d |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
212 dict_add_tv(got_tv->vval.v_dict, |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
213 (char *)hi->hi_key, &HI2DI(hi)->di_tv); |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
214 --todo; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
215 } |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
216 } |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
217 } |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
218 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 ga_concat_shorten_esc(gap, tv2string(exp_tv, &tofree, numbuf, 0)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 vim_free(tofree); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 else |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
223 { |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
224 ga_concat(gap, (char_u *)"'"); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 ga_concat_shorten_esc(gap, exp_str); |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
226 ga_concat(gap, (char_u *)"'"); |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
227 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 if (atype != ASSERT_NOTEQUAL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 if (atype == ASSERT_MATCH) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 ga_concat(gap, (char_u *)" does not match "); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 else if (atype == ASSERT_NOTMATCH) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 ga_concat(gap, (char_u *)" does match "); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 ga_concat(gap, (char_u *)" but got "); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 ga_concat_shorten_esc(gap, tv2string(got_tv, &tofree, numbuf, 0)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 vim_free(tofree); |
20834
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
238 |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
239 if (omitted != 0) |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
240 { |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
241 char buf[100]; |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
242 |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
243 vim_snprintf(buf, 100, " - %d equal item%s omitted", |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
244 omitted, omitted == 1 ? "" : "s"); |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
245 ga_concat(gap, (char_u *)buf); |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
246 } |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
247 } |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
248 |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
249 if (did_copy) |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
250 { |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
251 clear_tv(exp_tv); |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
252 clear_tv(got_tv); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 assert_equal_common(typval_T *argvars, assert_type_T atype) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 if (tv_equal(&argvars[0], &argvars[1], FALSE, FALSE) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 != (atype == ASSERT_EQUAL)) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 fill_assert_error(&ga, &argvars[2], NULL, &argvars[0], &argvars[1], |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 atype); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
274 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 assert_match_common(typval_T *argvars, assert_type_T atype) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 char_u buf1[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 char_u buf2[NUMBUFLEN]; |
21297
3ef53d66f30d
patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
280 int called_emsg_before = called_emsg; |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
281 char_u *pat; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
282 char_u *text; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
284 if (in_vim9script() |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
285 && (check_for_string_arg(argvars, 0) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
286 || check_for_string_arg(argvars, 1) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
287 || check_for_opt_string_arg(argvars, 2) == FAIL)) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
288 return 1; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
289 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
290 pat = tv_get_string_buf_chk(&argvars[0], buf1); |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
291 text = tv_get_string_buf_chk(&argvars[1], buf2); |
21297
3ef53d66f30d
patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
292 if (called_emsg == called_emsg_before |
3ef53d66f30d
patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
293 && pattern_match(pat, text, FALSE) != (atype == ASSERT_MATCH)) |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 fill_assert_error(&ga, &argvars[2], NULL, &argvars[0], &argvars[1], |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 atype); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 * Common for assert_true() and assert_false(). |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 * Return non-zero for failure. |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 assert_bool(typval_T *argvars, int isTrue) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 int error = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 |
19102
ba9f50bfda83
patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
315 if (argvars[0].v_type == VAR_BOOL |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 && argvars[0].vval.v_number == (isTrue ? VVAL_TRUE : VVAL_FALSE)) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
318 if (argvars[0].v_type != VAR_NUMBER |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 || (tv_get_number_chk(&argvars[0], &error) == 0) == isTrue |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 || error) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
321 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
322 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
323 fill_assert_error(&ga, &argvars[1], |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 (char_u *)(isTrue ? "True" : "False"), |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 NULL, &argvars[0], ASSERT_OTHER); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 static void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 assert_append_cmd_or_arg(garray_T *gap, typval_T *argvars, char_u *cmd) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 char_u *tofree; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 char_u numbuf[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
339 if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
341 ga_concat(gap, echo_string(&argvars[2], &tofree, numbuf, 0)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
342 vim_free(tofree); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
344 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 ga_concat(gap, cmd); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 static int |
24307
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
349 assert_beeps(typval_T *argvars, int no_beep) |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 { |
25252
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
351 char_u *cmd; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 int ret = 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 |
25252
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
355 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) |
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
356 return 0; |
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
357 |
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
358 cmd = tv_get_string_chk(&argvars[0]); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 called_vim_beep = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 suppress_errthrow = TRUE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
361 emsg_silent = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 do_cmdline_cmd(cmd); |
24307
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
363 if (no_beep ? called_vim_beep : !called_vim_beep) |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 prepare_assert_error(&ga); |
24307
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
366 if (no_beep) |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
367 ga_concat(&ga, (char_u *)"command did beep: "); |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
368 else |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
369 ga_concat(&ga, (char_u *)"command did not beep: "); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 ga_concat(&ga, cmd); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 ret = 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
375 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 suppress_errthrow = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 emsg_on_display = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 return ret; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 /* |
25252
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
382 * "assert_beeps(cmd)" function |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 f_assert_beeps(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
387 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
388 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
389 |
24307
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
390 rettv->vval.v_number = assert_beeps(argvars, FALSE); |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
391 } |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
392 |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
393 /* |
25252
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
394 * "assert_nobeep(cmd)" function |
24307
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
395 */ |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
396 void |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
397 f_assert_nobeep(typval_T *argvars, typval_T *rettv) |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
398 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
399 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
400 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
401 |
24307
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
402 rettv->vval.v_number = assert_beeps(argvars, TRUE); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
403 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 * "assert_equal(expected, actual[, msg])" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 f_assert_equal(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 rettv->vval.v_number = assert_equal_common(argvars, ASSERT_EQUAL); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 assert_equalfile(typval_T *argvars) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 char_u buf1[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 char_u buf2[NUMBUFLEN]; |
21297
3ef53d66f30d
patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
419 int called_emsg_before = called_emsg; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 char_u *fname1 = tv_get_string_buf_chk(&argvars[0], buf1); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 char_u *fname2 = tv_get_string_buf_chk(&argvars[1], buf2); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 FILE *fd1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 FILE *fd2; |
20691
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
425 char line1[200]; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
426 char line2[200]; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
427 int lineidx = 0; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 |
21297
3ef53d66f30d
patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
429 if (called_emsg > called_emsg_before) |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 IObuff[0] = NUL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
433 fd1 = mch_fopen((char *)fname1, READBIN); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
434 if (fd1 == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
435 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
436 vim_snprintf((char *)IObuff, IOSIZE, (char *)e_cant_read_file_str, fname1); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
438 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 fd2 = mch_fopen((char *)fname2, READBIN); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
441 if (fd2 == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 fclose(fd1); |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
444 vim_snprintf((char *)IObuff, IOSIZE, (char *)e_cant_read_file_str, fname2); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 { |
20691
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
448 int c1, c2; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
449 long count = 0; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
450 long linecount = 1; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 for (;;) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 c1 = fgetc(fd1); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 c2 = fgetc(fd2); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 if (c1 == EOF) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 if (c2 != EOF) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 STRCPY(IObuff, "first file is shorter"); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 else if (c2 == EOF) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 STRCPY(IObuff, "second file is shorter"); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 } |
20691
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
467 else |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 { |
20691
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
469 line1[lineidx] = c1; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
470 line2[lineidx] = c2; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
471 ++lineidx; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
472 if (c1 != c2) |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
473 { |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
474 vim_snprintf((char *)IObuff, IOSIZE, |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
475 "difference at byte %ld, line %ld", |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
476 count, linecount); |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
477 break; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
478 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
479 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 ++count; |
20691
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
481 if (c1 == NL) |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
482 { |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
483 ++linecount; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
484 lineidx = 0; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
485 } |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
486 else if (lineidx + 2 == (int)sizeof(line1)) |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
487 { |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
488 mch_memmove(line1, line1 + 100, lineidx - 100); |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
489 mch_memmove(line2, line2 + 100, lineidx - 100); |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
490 lineidx -= 100; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
491 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
492 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
493 fclose(fd1); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
494 fclose(fd2); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
497 if (IObuff[0] != NUL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
499 prepare_assert_error(&ga); |
20679
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
500 if (argvars[2].v_type != VAR_UNKNOWN) |
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
501 { |
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
502 char_u numbuf[NUMBUFLEN]; |
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
503 char_u *tofree; |
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
504 |
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
505 ga_concat(&ga, echo_string(&argvars[2], &tofree, numbuf, 0)); |
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
506 vim_free(tofree); |
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
507 ga_concat(&ga, (char_u *)": "); |
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
508 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
509 ga_concat(&ga, IObuff); |
20691
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
510 if (lineidx > 0) |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
511 { |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
512 line1[lineidx] = NUL; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
513 line2[lineidx] = NUL; |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
514 ga_concat(&ga, (char_u *)" after \""); |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
515 ga_concat(&ga, (char_u *)line1); |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
516 if (STRCMP(line1, line2) != 0) |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
517 { |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
518 ga_concat(&ga, (char_u *)"\" vs \""); |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
519 ga_concat(&ga, (char_u *)line2); |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
520 } |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
521 ga_concat(&ga, (char_u *)"\""); |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
522 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
526 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 /* |
20679
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
531 * "assert_equalfile(fname-one, fname-two[, msg])" function |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
532 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
534 f_assert_equalfile(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
536 if (in_vim9script() |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
537 && (check_for_string_arg(argvars, 0) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
538 || check_for_string_arg(argvars, 1) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
539 || check_for_opt_string_arg(argvars, 2) == FAIL)) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
540 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
541 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 rettv->vval.v_number = assert_equalfile(argvars); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
544 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 * "assert_notequal(expected, actual[, msg])" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 f_assert_notequal(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 rettv->vval.v_number = assert_equal_common(argvars, ASSERT_NOTEQUAL); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 * "assert_exception(string[, msg])" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 f_assert_exception(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
560 garray_T ga; |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
561 char_u *error; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
563 if (in_vim9script() |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
564 && (check_for_string_arg(argvars, 0) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
565 || check_for_opt_string_arg(argvars, 1) == FAIL)) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
566 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
567 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
568 error = tv_get_string_chk(&argvars[0]); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 if (*get_vim_var_str(VV_EXCEPTION) == NUL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 ga_concat(&ga, (char_u *)"v:exception is not set"); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 rettv->vval.v_number = 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 else if (error != NULL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 && strstr((char *)get_vim_var_str(VV_EXCEPTION), (char *)error) == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 fill_assert_error(&ga, &argvars[1], NULL, &argvars[0], |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 get_vim_var_tv(VV_EXCEPTION), ASSERT_OTHER); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 rettv->vval.v_number = 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 * "assert_fails(cmd [, error[, msg]])" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 f_assert_fails(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 { |
25368
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
595 char_u *cmd; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 int save_trylevel = trylevel; |
18949
5c405689da3e
patch 8.2.0035: saving and restoring called_emsg is clumsy
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
598 int called_emsg_before = called_emsg; |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
599 char *wrong_arg_msg = NULL; |
29746
567b5a2a1884
patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
600 char_u *tofree = NULL; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
601 |
25368
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
602 if (check_for_string_or_number_arg(argvars, 0) == FAIL |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
603 || check_for_opt_string_or_list_arg(argvars, 1) == FAIL |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
604 || (argvars[1].v_type != VAR_UNKNOWN |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
605 && (argvars[2].v_type != VAR_UNKNOWN |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
606 && (check_for_opt_number_arg(argvars, 3) == FAIL |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
607 || (argvars[3].v_type != VAR_UNKNOWN |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
608 && check_for_opt_string_arg(argvars, 4) == FAIL))))) |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
609 return; |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
610 |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
611 cmd = tv_get_string_chk(&argvars[0]); |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
612 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
613 // trylevel must be zero for a ":throw" command to be considered failed |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
614 trylevel = 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
615 suppress_errthrow = TRUE; |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
616 in_assert_fails = TRUE; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 do_cmdline_cmd(cmd); |
18949
5c405689da3e
patch 8.2.0035: saving and restoring called_emsg is clumsy
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
619 if (called_emsg == called_emsg_before) |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 ga_concat(&ga, (char_u *)"command did not fail: "); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 assert_append_cmd_or_arg(&ga, argvars, cmd); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
624 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
626 rettv->vval.v_number = 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
628 else if (argvars[1].v_type != VAR_UNKNOWN) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
630 char_u buf[NUMBUFLEN]; |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
631 char_u *expected; |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
632 char_u *expected_str = NULL; |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
633 int error_found = FALSE; |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
634 int error_found_index = 1; |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
635 char_u *actual = emsg_assert_fails_msg == NULL ? (char_u *)"[unknown]" |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
636 : emsg_assert_fails_msg; |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
637 |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
638 if (argvars[1].v_type == VAR_STRING) |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
639 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
640 expected = tv_get_string_buf_chk(&argvars[1], buf); |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
641 error_found = expected == NULL |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
642 || strstr((char *)actual, (char *)expected) == NULL; |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
643 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
644 else if (argvars[1].v_type == VAR_LIST) |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
645 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
646 list_T *list = argvars[1].vval.v_list; |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
647 typval_T *tv; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
649 if (list == NULL || list->lv_len < 1 || list->lv_len > 2) |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
650 { |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
651 wrong_arg_msg = e_assert_fails_second_arg; |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
652 goto theend; |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
653 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
654 CHECK_LIST_MATERIALIZE(list); |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
655 tv = &list->lv_first->li_tv; |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
656 expected = tv_get_string_buf_chk(tv, buf); |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
657 if (!pattern_match(expected, actual, FALSE)) |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
658 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
659 error_found = TRUE; |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
660 expected_str = expected; |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
661 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
662 else if (list->lv_len == 2) |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
663 { |
29746
567b5a2a1884
patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
664 // make a copy, an error in pattern_match() may free it |
567b5a2a1884
patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
665 tofree = actual = vim_strsave(get_vim_var_str(VV_ERRMSG)); |
567b5a2a1884
patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
666 if (actual != NULL) |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
667 { |
29746
567b5a2a1884
patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
668 tv = &list->lv_u.mat.lv_last->li_tv; |
567b5a2a1884
patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
669 expected = tv_get_string_buf_chk(tv, buf); |
567b5a2a1884
patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
670 if (!pattern_match(expected, actual, FALSE)) |
567b5a2a1884
patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
671 { |
567b5a2a1884
patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
672 error_found = TRUE; |
567b5a2a1884
patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
673 expected_str = expected; |
567b5a2a1884
patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
674 } |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
675 } |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
676 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
677 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
678 else |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
679 { |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
680 wrong_arg_msg = e_assert_fails_second_arg; |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
681 goto theend; |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
682 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
683 |
21869
25ef87c95880
patch 8.2.1484: flaky failure in assert_fails()
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
684 if (!error_found && argvars[2].v_type != VAR_UNKNOWN |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
685 && argvars[3].v_type != VAR_UNKNOWN) |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
686 { |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
687 if (argvars[3].v_type != VAR_NUMBER) |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
688 { |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
689 wrong_arg_msg = e_assert_fails_fourth_argument; |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
690 goto theend; |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
691 } |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
692 else if (argvars[3].vval.v_number >= 0 |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
693 && argvars[3].vval.v_number != emsg_assert_fails_lnum) |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
694 { |
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
695 error_found = TRUE; |
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
696 error_found_index = 3; |
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
697 } |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
698 if (!error_found && argvars[4].v_type != VAR_UNKNOWN) |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
699 { |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
700 if (argvars[4].v_type != VAR_STRING) |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
701 { |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
702 wrong_arg_msg = e_assert_fails_fifth_argument; |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
703 goto theend; |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
704 } |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
705 else if (argvars[4].vval.v_string != NULL |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
706 && !pattern_match(argvars[4].vval.v_string, |
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
707 emsg_assert_fails_context, FALSE)) |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
708 { |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
709 error_found = TRUE; |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
710 error_found_index = 4; |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
711 } |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
712 } |
21859
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
713 } |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
714 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
715 if (error_found) |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
716 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
717 typval_T actual_tv; |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
718 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
719 prepare_assert_error(&ga); |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
720 if (error_found_index == 3) |
21859
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
721 { |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
722 actual_tv.v_type = VAR_NUMBER; |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
723 actual_tv.vval.v_number = emsg_assert_fails_lnum; |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
724 } |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
725 else if (error_found_index == 4) |
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
726 { |
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
727 actual_tv.v_type = VAR_STRING; |
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
728 actual_tv.vval.v_string = emsg_assert_fails_context; |
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
729 } |
21859
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
730 else |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
731 { |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
732 actual_tv.v_type = VAR_STRING; |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
733 actual_tv.vval.v_string = actual; |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
734 } |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
735 fill_assert_error(&ga, &argvars[2], expected_str, |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
736 &argvars[error_found_index], &actual_tv, ASSERT_OTHER); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 ga_concat(&ga, (char_u *)": "); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 assert_append_cmd_or_arg(&ga, argvars, cmd); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
741 rettv->vval.v_number = 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
743 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
744 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
745 theend: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 trylevel = save_trylevel; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 suppress_errthrow = FALSE; |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
748 in_assert_fails = FALSE; |
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
749 did_emsg = FALSE; |
29165
0e0e298e05c1
patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents:
28885
diff
changeset
|
750 got_int = FALSE; |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
751 msg_col = 0; |
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
752 need_wait_return = FALSE; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 emsg_on_display = FALSE; |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
754 msg_scrolled = 0; |
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
755 lines_left = Rows; |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
756 VIM_CLEAR(emsg_assert_fails_msg); |
29746
567b5a2a1884
patch 9.0.0213: using freed memory with error in assert argument
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
757 vim_free(tofree); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 set_vim_var_string(VV_ERRMSG, NULL, 0); |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
759 if (wrong_arg_msg != NULL) |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
760 emsg(_(wrong_arg_msg)); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 * "assert_false(actual[, msg])" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 f_assert_false(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 rettv->vval.v_number = assert_bool(argvars, FALSE); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 assert_inrange(typval_T *argvars) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 int error = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 char_u *tofree; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 char msg[200]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 char_u numbuf[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 #ifdef FEAT_FLOAT |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 if (argvars[0].v_type == VAR_FLOAT |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 || argvars[1].v_type == VAR_FLOAT |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 || argvars[2].v_type == VAR_FLOAT) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 float_T flower = tv_get_float(&argvars[0]); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 float_T fupper = tv_get_float(&argvars[1]); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 float_T factual = tv_get_float(&argvars[2]); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
789 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 if (factual < flower || factual > fupper) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
793 if (argvars[3].v_type != VAR_UNKNOWN) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 ga_concat(&ga, tv2string(&argvars[3], &tofree, numbuf, 0)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 vim_free(tofree); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 vim_snprintf(msg, 200, "Expected range %g - %g, but got %g", |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 flower, fupper, factual); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 ga_concat(&ga, (char_u *)msg); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 varnumber_T lower = tv_get_number_chk(&argvars[0], &error); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 varnumber_T upper = tv_get_number_chk(&argvars[1], &error); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 varnumber_T actual = tv_get_number_chk(&argvars[2], &error); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
816 if (error) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
818 if (actual < lower || actual > upper) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 if (argvars[3].v_type != VAR_UNKNOWN) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
822 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
823 ga_concat(&ga, tv2string(&argvars[3], &tofree, numbuf, 0)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
824 vim_free(tofree); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
825 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
826 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
827 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
828 vim_snprintf(msg, 200, "Expected range %ld - %ld, but got %ld", |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
829 (long)lower, (long)upper, (long)actual); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
830 ga_concat(&ga, (char_u *)msg); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
831 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
832 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
833 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
834 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
835 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
836 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
838 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
841 * "assert_inrange(lower, upper[, msg])" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
844 f_assert_inrange(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 { |
25368
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
846 if (check_for_float_or_nr_arg(argvars, 0) == FAIL |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
847 || check_for_float_or_nr_arg(argvars, 1) == FAIL |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
848 || check_for_float_or_nr_arg(argvars, 2) == FAIL |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
849 || check_for_opt_string_arg(argvars, 3) == FAIL) |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
850 return; |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
851 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 rettv->vval.v_number = assert_inrange(argvars); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 * "assert_match(pattern, actual[, msg])" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
857 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 f_assert_match(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 rettv->vval.v_number = assert_match_common(argvars, ASSERT_MATCH); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 * "assert_notmatch(pattern, actual[, msg])" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 f_assert_notmatch(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 rettv->vval.v_number = assert_match_common(argvars, ASSERT_NOTMATCH); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 * "assert_report(msg)" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 f_assert_report(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 |
25228
a703b3f28ef4
patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25198
diff
changeset
|
881 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) |
a703b3f28ef4
patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25198
diff
changeset
|
882 return; |
a703b3f28ef4
patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25198
diff
changeset
|
883 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 ga_concat(&ga, tv_get_string(&argvars[0])); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 rettv->vval.v_number = 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 * "assert_true(actual[, msg])" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 f_assert_true(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 rettv->vval.v_number = assert_bool(argvars, TRUE); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 * "test_alloc_fail(id, countdown, repeat)" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 f_test_alloc_fail(typval_T *argvars, typval_T *rettv UNUSED) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
906 if (in_vim9script() |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
907 && (check_for_number_arg(argvars, 0) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
908 || check_for_number_arg(argvars, 1) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
909 || check_for_number_arg(argvars, 2) == FAIL)) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
910 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
911 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 if (argvars[0].v_type != VAR_NUMBER |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 || argvars[0].vval.v_number <= 0 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 || argvars[1].v_type != VAR_NUMBER |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 || argvars[1].vval.v_number < 0 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 || argvars[2].v_type != VAR_NUMBER) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
917 emsg(_(e_invalid_argument)); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 alloc_fail_id = argvars[0].vval.v_number; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 if (alloc_fail_id >= aid_last) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
922 emsg(_(e_invalid_argument)); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 alloc_fail_countdown = argvars[1].vval.v_number; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 alloc_fail_repeat = argvars[2].vval.v_number; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 did_outofmem_msg = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 * "test_autochdir()" |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 f_test_autochdir(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 #if defined(FEAT_AUTOCHDIR) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 test_autochdir = TRUE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 * "test_feedinput()" |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 f_test_feedinput(typval_T *argvars, typval_T *rettv UNUSED) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 #ifdef USE_INPUT_BUF |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
947 char_u *val; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
949 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
950 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
951 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
952 val = tv_get_string_chk(&argvars[0]); |
19209
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
953 # ifdef VIMDLL |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
954 // this doesn't work in the console |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
955 if (!gui.in_use) |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
956 return; |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
957 # endif |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
958 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 if (val != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
961 trash_input_buf(); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 add_to_input_buf_csi(val, (int)STRLEN(val)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
964 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
967 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 * "test_getvalue({name})" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 f_test_getvalue(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 { |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
973 char_u *name; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
974 |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
975 if (check_for_string_arg(argvars, 0) == FAIL) |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
976 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
977 |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
978 name = tv_get_string(&argvars[0]); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
980 if (STRCMP(name, (char_u *)"need_fileinfo") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
981 rettv->vval.v_number = need_fileinfo; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
982 else |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
983 semsg(_(e_invalid_argument_str), name); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 * "test_option_not_set({name})" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 f_test_option_not_set(typval_T *argvars, typval_T *rettv UNUSED) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 char_u *name = (char_u *)""; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
994 if (check_for_string_arg(argvars, 0) == FAIL) |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
995 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
996 |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
997 name = tv_get_string(&argvars[0]); |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
998 if (reset_option_was_set(name) == FAIL) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
999 semsg(_(e_invalid_argument_str), name); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1001 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 * "test_override({name}, {val})" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 f_test_override(typval_T *argvars, typval_T *rettv UNUSED) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 char_u *name = (char_u *)""; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 int val; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 static int save_starting = -1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1012 if (check_for_string_arg(argvars, 0) == FAIL |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1013 || check_for_number_arg(argvars, 1) == FAIL) |
25252
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
1014 return; |
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
1015 |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1016 name = tv_get_string(&argvars[0]); |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1017 val = (int)tv_get_number(&argvars[1]); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1019 if (STRCMP(name, (char_u *)"redraw") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1020 disable_redraw_for_testing = val; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1021 else if (STRCMP(name, (char_u *)"redraw_flag") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1022 ignore_redraw_flag_for_testing = val; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1023 else if (STRCMP(name, (char_u *)"char_avail") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1024 disable_char_avail_for_testing = val; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1025 else if (STRCMP(name, (char_u *)"starting") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1026 { |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1027 if (val) |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 { |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1029 if (save_starting < 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1030 save_starting = starting; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1031 starting = 0; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 else |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1034 { |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1035 starting = save_starting; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1036 save_starting = -1; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1037 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 } |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1039 else if (STRCMP(name, (char_u *)"nfa_fail") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1040 nfa_fail_for_testing = val; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1041 else if (STRCMP(name, (char_u *)"no_query_mouse") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1042 no_query_mouse_for_testing = val; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1043 else if (STRCMP(name, (char_u *)"no_wait_return") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1044 no_wait_return = val; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1045 else if (STRCMP(name, (char_u *)"ui_delay") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1046 ui_delay_for_testing = val; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1047 else if (STRCMP(name, (char_u *)"term_props") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1048 reset_term_props_on_termresponse = val; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1049 else if (STRCMP(name, (char_u *)"vterm_title") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1050 disable_vterm_title_for_testing = val; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1051 else if (STRCMP(name, (char_u *)"uptime") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1052 override_sysinfo_uptime = val; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1053 else if (STRCMP(name, (char_u *)"alloc_lines") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1054 ml_get_alloc_lines = val; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1055 else if (STRCMP(name, (char_u *)"autoload") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1056 override_autoload = val; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1057 else if (STRCMP(name, (char_u *)"ALL") == 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1058 { |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1059 disable_char_avail_for_testing = FALSE; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1060 disable_redraw_for_testing = FALSE; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1061 ignore_redraw_flag_for_testing = FALSE; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1062 nfa_fail_for_testing = FALSE; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1063 no_query_mouse_for_testing = FALSE; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1064 ui_delay_for_testing = 0; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1065 reset_term_props_on_termresponse = FALSE; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1066 override_sysinfo_uptime = -1; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1067 // ml_get_alloc_lines is not reset by "ALL" |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1068 if (save_starting >= 0) |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1069 { |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1070 starting = save_starting; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1071 save_starting = -1; |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1072 } |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1073 } |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1074 else |
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1075 semsg(_(e_invalid_argument_str), name); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1076 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 * "test_refcount({expr})" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 f_test_refcount(typval_T *argvars, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 int retval = -1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1085 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1086 switch (argvars[0].v_type) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 case VAR_UNKNOWN: |
19922
1f42c49c3d29
patch 8.2.0517: Vim9: cannot separate "func" and "func(): void"
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
1089 case VAR_ANY: |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19102
diff
changeset
|
1090 case VAR_VOID: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 case VAR_NUMBER: |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19102
diff
changeset
|
1092 case VAR_BOOL: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 case VAR_FLOAT: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 case VAR_SPECIAL: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 case VAR_STRING: |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24307
diff
changeset
|
1096 case VAR_INSTR: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 case VAR_JOB: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1099 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1100 if (argvars[0].vval.v_job != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1101 retval = argvars[0].vval.v_job->jv_refcount - 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1102 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1104 case VAR_CHANNEL: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1105 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 if (argvars[0].vval.v_channel != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1107 retval = argvars[0].vval.v_channel->ch_refcount - 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1108 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1109 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1110 case VAR_FUNC: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1111 if (argvars[0].vval.v_string != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1112 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1113 ufunc_T *fp; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1114 |
27114
98a01021e465
patch 8.2.4086: "cctx" argument of find_func_even_dead() is unused
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
1115 fp = find_func(argvars[0].vval.v_string, FALSE); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1116 if (fp != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1117 retval = fp->uf_refcount; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1118 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1119 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1120 case VAR_PARTIAL: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1121 if (argvars[0].vval.v_partial != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1122 retval = argvars[0].vval.v_partial->pt_refcount - 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1123 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1124 case VAR_BLOB: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1125 if (argvars[0].vval.v_blob != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1126 retval = argvars[0].vval.v_blob->bv_refcount - 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1127 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1128 case VAR_LIST: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1129 if (argvars[0].vval.v_list != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1130 retval = argvars[0].vval.v_list->lv_refcount - 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1131 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1132 case VAR_DICT: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1133 if (argvars[0].vval.v_dict != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1134 retval = argvars[0].vval.v_dict->dv_refcount - 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1135 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1138 rettv->v_type = VAR_NUMBER; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1139 rettv->vval.v_number = retval; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1140 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1142 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1144 * "test_garbagecollect_now()" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1145 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1146 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 f_test_garbagecollect_now(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1148 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
1149 // This is dangerous, any Lists and Dicts used internally may be freed |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
1150 // while still in use. |
27412
557a50b0d10b
patch 8.2.4234: test_garbagecollect_now() does not check v:testing
Bram Moolenaar <Bram@vim.org>
parents:
27400
diff
changeset
|
1151 if (!get_vim_var_nr(VV_TESTING)) |
557a50b0d10b
patch 8.2.4234: test_garbagecollect_now() does not check v:testing
Bram Moolenaar <Bram@vim.org>
parents:
27400
diff
changeset
|
1152 emsg(_(e_calling_test_garbagecollect_now_while_v_testing_is_not_set)); |
557a50b0d10b
patch 8.2.4234: test_garbagecollect_now() does not check v:testing
Bram Moolenaar <Bram@vim.org>
parents:
27400
diff
changeset
|
1153 else |
557a50b0d10b
patch 8.2.4234: test_garbagecollect_now() does not check v:testing
Bram Moolenaar <Bram@vim.org>
parents:
27400
diff
changeset
|
1154 garbage_collect(TRUE); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1156 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 * "test_garbagecollect_soon()" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1160 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 f_test_garbagecollect_soon(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1163 may_garbage_collect = TRUE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1165 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1166 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1167 * "test_ignore_error()" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1168 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1169 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1170 f_test_ignore_error(typval_T *argvars, typval_T *rettv UNUSED) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1171 { |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1172 if (check_for_string_arg(argvars, 0) == FAIL) |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
1173 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
1174 |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1175 ignore_error_for_testing(tv_get_string(&argvars[0])); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1176 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1178 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 f_test_null_blob(typval_T *argvars UNUSED, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 rettv->v_type = VAR_BLOB; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 rettv->vval.v_blob = NULL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1184 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 f_test_null_channel(typval_T *argvars UNUSED, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 rettv->v_type = VAR_CHANNEL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 rettv->vval.v_channel = NULL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 f_test_null_dict(typval_T *argvars UNUSED, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 rettv_dict_set(rettv, NULL); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1202 f_test_null_job(typval_T *argvars UNUSED, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 rettv->v_type = VAR_JOB; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 rettv->vval.v_job = NULL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1206 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1209 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1210 f_test_null_list(typval_T *argvars UNUSED, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 rettv_list_set(rettv, NULL); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 void |
19874
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1216 f_test_null_function(typval_T *argvars UNUSED, typval_T *rettv) |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1217 { |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1218 rettv->v_type = VAR_FUNC; |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1219 rettv->vval.v_string = NULL; |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1220 } |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1221 |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1222 void |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 f_test_null_partial(typval_T *argvars UNUSED, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1225 rettv->v_type = VAR_PARTIAL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 rettv->vval.v_partial = NULL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 f_test_null_string(typval_T *argvars UNUSED, typval_T *rettv) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 rettv->v_type = VAR_STRING; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1233 rettv->vval.v_string = NULL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1235 |
19483
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1236 void |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1237 f_test_unknown(typval_T *argvars UNUSED, typval_T *rettv) |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1238 { |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1239 rettv->v_type = VAR_UNKNOWN; |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1240 } |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1241 |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1242 void |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1243 f_test_void(typval_T *argvars UNUSED, typval_T *rettv) |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1244 { |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1245 rettv->v_type = VAR_VOID; |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1246 } |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1247 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1248 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1249 f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1250 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
1251 if (in_vim9script() |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
1252 && (check_for_number_arg(argvars, 0) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
1253 || check_for_number_arg(argvars, 1) == FAIL)) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
1254 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
1255 |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
29746
diff
changeset
|
1256 if (argvars[0].v_type != VAR_NUMBER || argvars[1].v_type != VAR_NUMBER) |
24998
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1257 { |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1258 emsg(_(e_invalid_argument)); |
24998
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1259 return; |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1260 } |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1261 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1262 mouse_row = (time_t)tv_get_number(&argvars[0]) - 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 mouse_col = (time_t)tv_get_number(&argvars[1]) - 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1266 # ifdef FEAT_GUI |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1267 static int |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1268 test_gui_drop_files(dict_T *args UNUSED) |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1269 { |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1270 # if defined(HAVE_DROP_FILE) |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1271 int row; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1272 int col; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1273 int_u mods; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1274 char_u **fnames; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1275 int count = 0; |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1276 typval_T t; |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1277 list_T *l; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1278 listitem_T *li; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1279 |
28315
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1280 if (!dict_has_key(args, "files") |
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1281 || !dict_has_key(args, "row") |
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1282 || !dict_has_key(args, "col") |
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1283 || !dict_has_key(args, "modifiers")) |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1284 return FALSE; |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1285 |
29442
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1286 (void)dict_get_tv(args, "files", &t); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1287 row = (int)dict_get_number(args, "row"); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1288 col = (int)dict_get_number(args, "col"); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1289 mods = (int)dict_get_number(args, "modifiers"); |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1290 |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1291 if (t.v_type != VAR_LIST || list_len(t.vval.v_list) == 0) |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1292 return FALSE; |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1293 |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1294 l = t.vval.v_list; |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1295 fnames = ALLOC_MULT(char_u *, list_len(l)); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1296 if (fnames == NULL) |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1297 return FALSE; |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1298 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1299 FOR_ALL_LIST_ITEMS(l, li) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1300 { |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1301 // ignore non-string items |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1302 if (li->li_tv.v_type != VAR_STRING |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1303 || li->li_tv.vval.v_string == NULL) |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1304 continue; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1305 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1306 fnames[count] = vim_strsave(li->li_tv.vval.v_string); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1307 if (fnames[count] == NULL) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1308 { |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1309 while (--count >= 0) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1310 vim_free(fnames[count]); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1311 vim_free(fnames); |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1312 return FALSE; |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1313 } |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1314 count++; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1315 } |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1316 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1317 if (count > 0) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1318 gui_handle_drop(TEXT_X(col - 1), TEXT_Y(row - 1), mods, fnames, count); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1319 else |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1320 vim_free(fnames); |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1321 # endif |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1322 |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1323 return TRUE; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1324 } |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1325 |
27501
378d3f7483e9
patch 8.2.4278: build with Athena GUI fails
Bram Moolenaar <Bram@vim.org>
parents:
27497
diff
changeset
|
1326 #if defined(FIND_REPLACE_DIALOG) |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1327 static int |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1328 test_gui_find_repl(dict_T *args) |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1329 { |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1330 int flags; |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1331 char_u *find_text; |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1332 char_u *repl_text; |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1333 int forward; |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1334 int retval; |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1335 |
28315
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1336 if (!dict_has_key(args, "find_text") |
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1337 || !dict_has_key(args, "repl_text") |
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1338 || !dict_has_key(args, "flags") |
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1339 || !dict_has_key(args, "forward")) |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1340 return FALSE; |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1341 |
29442
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1342 find_text = dict_get_string(args, "find_text", TRUE); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1343 repl_text = dict_get_string(args, "repl_text", TRUE); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1344 flags = (int)dict_get_number(args, "flags"); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1345 forward = (int)dict_get_number(args, "forward"); |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1346 |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1347 retval = gui_do_findrepl(flags, find_text, repl_text, forward); |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1348 vim_free(find_text); |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1349 vim_free(repl_text); |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1350 |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1351 return retval; |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1352 } |
27501
378d3f7483e9
patch 8.2.4278: build with Athena GUI fails
Bram Moolenaar <Bram@vim.org>
parents:
27497
diff
changeset
|
1353 #endif |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1354 |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1355 static int |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1356 test_gui_mouse_event(dict_T *args) |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1357 { |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1358 int button; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1359 int row; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1360 int col; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1361 int repeated_click; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1362 int_u mods; |
28297
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1363 int move; |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1364 |
28315
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1365 if (!dict_has_key(args, "row") |
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1366 || !dict_has_key(args, "col")) |
28297
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1367 return FALSE; |
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1368 |
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1369 // Note: "move" is optional, requires fewer arguments |
29442
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1370 move = (int)dict_get_bool(args, "move", FALSE); |
28297
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1371 |
28315
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1372 if (!move && (!dict_has_key(args, "button") |
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1373 || !dict_has_key(args, "multiclick") |
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1374 || !dict_has_key(args, "modifiers"))) |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1375 return FALSE; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1376 |
29442
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1377 row = (int)dict_get_number(args, "row"); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1378 col = (int)dict_get_number(args, "col"); |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1379 |
28297
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1380 if (move) |
28885
947b7d061b07
patch 8.2.4965: GUI: testing mouse move event depends on screen cell size
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
1381 { |
29442
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1382 if (dict_get_bool(args, "cell", FALSE)) |
28885
947b7d061b07
patch 8.2.4965: GUI: testing mouse move event depends on screen cell size
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
1383 { |
947b7d061b07
patch 8.2.4965: GUI: testing mouse move event depends on screen cell size
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
1384 // click in the middle of the character cell |
947b7d061b07
patch 8.2.4965: GUI: testing mouse move event depends on screen cell size
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
1385 row = row * gui.char_height + gui.char_height / 2; |
947b7d061b07
patch 8.2.4965: GUI: testing mouse move event depends on screen cell size
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
1386 col = col * gui.char_width + gui.char_width / 2; |
947b7d061b07
patch 8.2.4965: GUI: testing mouse move event depends on screen cell size
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
1387 } |
28297
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1388 gui_mouse_moved(col, row); |
28885
947b7d061b07
patch 8.2.4965: GUI: testing mouse move event depends on screen cell size
Bram Moolenaar <Bram@vim.org>
parents:
28755
diff
changeset
|
1389 } |
28297
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1390 else |
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1391 { |
29442
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1392 button = (int)dict_get_number(args, "button"); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1393 repeated_click = (int)dict_get_number(args, "multiclick"); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1394 mods = (int)dict_get_number(args, "modifiers"); |
28297
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1395 |
28755
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28315
diff
changeset
|
1396 // Reset the scroll values to known values. |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28315
diff
changeset
|
1397 // XXX: Remove this when/if the scroll step is made configurable. |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28315
diff
changeset
|
1398 mouse_set_hor_scroll_step(6); |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28315
diff
changeset
|
1399 mouse_set_vert_scroll_step(3); |
26a2836923d6
patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
28315
diff
changeset
|
1400 |
28297
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1401 gui_send_mouse_event(button, TEXT_X(col - 1), TEXT_Y(row - 1), |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1402 repeated_click, mods); |
28297
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1403 } |
4190b932e6ca
patch 8.2.4674: cannot force getting MouseMove events
Bram Moolenaar <Bram@vim.org>
parents:
27742
diff
changeset
|
1404 |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1405 return TRUE; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1406 } |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1407 |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1408 static int |
27497
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1409 test_gui_scrollbar(dict_T *args) |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1410 { |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1411 char_u *which; |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1412 long value; |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1413 int dragging; |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1414 scrollbar_T *sb = NULL; |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1415 |
28315
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1416 if (!dict_has_key(args, "which") |
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1417 || !dict_has_key(args, "value") |
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1418 || !dict_has_key(args, "dragging")) |
27497
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1419 return FALSE; |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1420 |
29442
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1421 which = dict_get_string(args, "which", FALSE); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1422 value = (long)dict_get_number(args, "value"); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1423 dragging = (int)dict_get_number(args, "dragging"); |
27497
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1424 |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1425 if (STRCMP(which, "left") == 0) |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1426 sb = &curwin->w_scrollbars[SBAR_LEFT]; |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1427 else if (STRCMP(which, "right") == 0) |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1428 sb = &curwin->w_scrollbars[SBAR_RIGHT]; |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1429 else if (STRCMP(which, "hor") == 0) |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1430 sb = &gui.bottom_sbar; |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1431 if (sb == NULL) |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1432 { |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1433 semsg(_(e_invalid_argument_str), which); |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1434 return FALSE; |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1435 } |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1436 gui_drag_scrollbar(sb, value, dragging); |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1437 # ifndef USE_ON_FLY_SCROLL |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1438 // need to loop through normal_cmd() to handle the scroll events |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1439 exec_normal(FALSE, TRUE, FALSE); |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1440 # endif |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1441 |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1442 return TRUE; |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1443 } |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1444 |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1445 static int |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1446 test_gui_tabline_event(dict_T *args UNUSED) |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1447 { |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1448 # ifdef FEAT_GUI_TABLINE |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1449 int tabnr; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1450 |
28315
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1451 if (!dict_has_key(args, "tabnr")) |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1452 return FALSE; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1453 |
29442
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1454 tabnr = (int)dict_get_number(args, "tabnr"); |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1455 |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1456 return send_tabline_event(tabnr); |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1457 # else |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1458 return FALSE; |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1459 # endif |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1460 } |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1461 |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1462 static int |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1463 test_gui_tabmenu_event(dict_T *args UNUSED) |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1464 { |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1465 # ifdef FEAT_GUI_TABLINE |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1466 int tabnr; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1467 int item; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1468 |
28315
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1469 if (!dict_has_key(args, "tabnr") |
62cc3b60493b
patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents:
28297
diff
changeset
|
1470 || !dict_has_key(args, "item")) |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1471 return FALSE; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1472 |
29442
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1473 tabnr = (int)dict_get_number(args, "tabnr"); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29432
diff
changeset
|
1474 item = (int)dict_get_number(args, "item"); |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1475 |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1476 send_tabline_menu_event(tabnr, item); |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1477 # endif |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1478 return TRUE; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1479 } |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1480 # endif |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1481 |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1482 void |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1483 f_test_gui_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1484 { |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1485 # ifdef FEAT_GUI |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1486 char_u *event; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1487 |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1488 rettv->v_type = VAR_BOOL; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1489 rettv->vval.v_number = FALSE; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1490 |
29432
339fe2968690
patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents:
29342
diff
changeset
|
1491 if (sandbox != 0) |
339fe2968690
patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents:
29342
diff
changeset
|
1492 { |
339fe2968690
patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents:
29342
diff
changeset
|
1493 emsg(_(e_not_allowed_in_sandbox)); |
339fe2968690
patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents:
29342
diff
changeset
|
1494 return; |
339fe2968690
patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents:
29342
diff
changeset
|
1495 } |
339fe2968690
patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents:
29342
diff
changeset
|
1496 |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1497 if (check_for_string_arg(argvars, 0) == FAIL |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1498 || check_for_dict_arg(argvars, 1) == FAIL |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1499 || argvars[1].vval.v_dict == NULL) |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1500 return; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1501 |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1502 event = tv_get_string(&argvars[0]); |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1503 if (STRCMP(event, "dropfiles") == 0) |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1504 rettv->vval.v_number = test_gui_drop_files(argvars[1].vval.v_dict); |
27501
378d3f7483e9
patch 8.2.4278: build with Athena GUI fails
Bram Moolenaar <Bram@vim.org>
parents:
27497
diff
changeset
|
1505 # if defined(FIND_REPLACE_DIALOG) |
27470
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1506 else if (STRCMP(event, "findrepl") == 0) |
f0096e5b3df9
patch 8.2.4263: no test for the GUI find/replace dialog
Bram Moolenaar <Bram@vim.org>
parents:
27462
diff
changeset
|
1507 rettv->vval.v_number = test_gui_find_repl(argvars[1].vval.v_dict); |
27501
378d3f7483e9
patch 8.2.4278: build with Athena GUI fails
Bram Moolenaar <Bram@vim.org>
parents:
27497
diff
changeset
|
1508 # endif |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1509 else if (STRCMP(event, "mouse") == 0) |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1510 rettv->vval.v_number = test_gui_mouse_event(argvars[1].vval.v_dict); |
27497
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1511 else if (STRCMP(event, "scrollbar") == 0) |
7480a2e2ca0f
patch 8.2.4276: separate test function for the GUI scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
27470
diff
changeset
|
1512 rettv->vval.v_number = test_gui_scrollbar(argvars[1].vval.v_dict); |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1513 else if (STRCMP(event, "tabline") == 0) |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1514 rettv->vval.v_number = test_gui_tabline_event(argvars[1].vval.v_dict); |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1515 else if (STRCMP(event, "tabmenu") == 0) |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1516 rettv->vval.v_number = test_gui_tabmenu_event(argvars[1].vval.v_dict); |
29432
339fe2968690
patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents:
29342
diff
changeset
|
1517 # ifdef FEAT_GUI_MSWIN |
339fe2968690
patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents:
29342
diff
changeset
|
1518 else if (STRCMP(event, "sendevent") == 0) |
339fe2968690
patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents:
29342
diff
changeset
|
1519 rettv->vval.v_number = test_gui_w32_sendevent(argvars[1].vval.v_dict); |
339fe2968690
patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents:
29342
diff
changeset
|
1520 # endif |
27462
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1521 else |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1522 { |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1523 semsg(_(e_invalid_argument_str), event); |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1524 return; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1525 } |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1526 # endif |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1527 } |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1528 |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1529 void |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1530 f_test_settime(typval_T *argvars, typval_T *rettv UNUSED) |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1531 { |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1532 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL) |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1533 return; |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1534 |
b43f6c879d52
patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents:
27422
diff
changeset
|
1535 time_for_testing = (time_t)tv_get_number(&argvars[0]); |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1536 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1538 #endif // defined(FEAT_EVAL) |