Mercurial > vim
annotate src/testing.c @ 25252:acda780ffc3e v8.2.3162
patch 8.2.3162: Vim9: argument types are not checked at compile time
Commit: https://github.com/vim/vim/commit/1a71d31bf34b0b2b08517903826004ec6fd440e5
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Thu Jul 15 12:49:58 2021 +0200
patch 8.2.3162: Vim9: argument types are not checked at compile time
Problem: Vim9: argument types are not checked at compile time.
Solution: Add more type checks. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/8560)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 15 Jul 2021 13:00:06 +0200 |
parents | a703b3f28ef4 |
children | 4d3c68196d05 |
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; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 c = mb_ptr2char_adv(&s); |
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; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 char_u *pat = 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
|
282 char_u *text = 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
|
283 |
21297
3ef53d66f30d
patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
284 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
|
285 && 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
|
286 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 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
|
289 atype); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 * 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
|
299 * 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
|
300 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 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
|
303 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 int error = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 |
19102
ba9f50bfda83
patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
307 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
|
308 && 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
|
309 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 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
|
311 || (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
|
312 || error) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
315 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
|
316 (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
|
317 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
|
318 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 return 1; |
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 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
323 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 static void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 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
|
327 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 char_u *tofree; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 char_u numbuf[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 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
|
332 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 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
|
334 vim_free(tofree); |
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 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 ga_concat(gap, cmd); |
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 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 static int |
24307
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
341 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
|
342 { |
25252
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
343 char_u *cmd; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
344 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 int ret = 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 |
25252
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
347 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
|
348 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
|
349 |
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
350 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
|
351 called_vim_beep = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 suppress_errthrow = TRUE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 emsg_silent = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 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
|
355 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
|
356 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 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
|
358 if (no_beep) |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
359 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
|
360 else |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
361 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
|
362 ga_concat(&ga, cmd); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 ret = 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 suppress_errthrow = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 emsg_on_display = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 return ret; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 /* |
25252
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
374 * "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
|
375 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 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
|
378 { |
24307
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
379 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
|
380 } |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
381 |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
382 /* |
25252
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
383 * "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
|
384 */ |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
385 void |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
386 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
|
387 { |
55f458d35292
patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents:
24089
diff
changeset
|
388 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
|
389 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 * "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
|
393 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 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
|
396 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 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
|
398 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 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
|
402 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
403 char_u buf1[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 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
|
405 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
|
406 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
|
407 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
|
408 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 FILE *fd1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 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
|
411 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
|
412 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
|
413 int lineidx = 0; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 |
21297
3ef53d66f30d
patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
415 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
|
416 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 IObuff[0] = NUL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 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
|
420 if (fd1 == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 vim_snprintf((char *)IObuff, IOSIZE, (char *)e_notread, fname1); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 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
|
427 if (fd2 == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 fclose(fd1); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 vim_snprintf((char *)IObuff, IOSIZE, (char *)e_notread, fname2); |
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 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
433 { |
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
|
434 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
|
435 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
|
436 long linecount = 1; |
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 for (;;) |
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 c1 = fgetc(fd1); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
441 c2 = fgetc(fd2); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 if (c1 == EOF) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
444 if (c2 != EOF) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 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
|
446 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 else if (c2 == EOF) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
449 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 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
|
451 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 } |
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
|
453 else |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 { |
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
|
455 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
|
456 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
|
457 ++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
|
458 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
|
459 { |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
460 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
|
461 "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
|
462 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
|
463 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
|
464 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 ++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
|
467 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
|
468 { |
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 ++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
|
470 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
|
471 } |
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 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
|
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 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
|
475 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
|
476 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
|
477 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
479 fclose(fd1); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 fclose(fd2); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
481 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
482 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 if (IObuff[0] != NUL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 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
|
486 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
|
487 { |
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
488 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
|
489 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
|
490 |
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
491 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
|
492 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
|
493 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
|
494 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 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
|
496 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
|
497 { |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
498 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
|
499 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
|
500 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
|
501 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
|
502 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
|
503 { |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
504 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
|
505 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
|
506 } |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
507 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
|
508 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
509 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
510 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
511 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
512 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
513 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 /* |
20679
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
517 * "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
|
518 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
519 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
520 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
|
521 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 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
|
523 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
526 * "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
|
527 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 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
|
530 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 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
|
532 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
534 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 * "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
|
536 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 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
|
539 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
541 char_u *error = tv_get_string_chk(&argvars[0]); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 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
|
544 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 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
|
547 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 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
|
550 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 else if (error != NULL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 && 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
|
553 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 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
|
556 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
|
557 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 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
|
560 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 * "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
|
565 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 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
|
568 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 char_u *cmd = tv_get_string_chk(&argvars[0]); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 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
|
572 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
|
573 char *wrong_arg_msg = NULL; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 // 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
|
576 trylevel = 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 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
|
578 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
|
579 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 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
|
581 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
|
582 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 prepare_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_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
|
585 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
|
586 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 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
|
589 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 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
|
591 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 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
|
593 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
|
594 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
|
595 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
|
596 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
|
597 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
|
598 : 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
|
599 |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
600 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
|
601 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
602 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
|
603 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
|
604 || 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
|
605 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
606 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
|
607 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
608 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
|
609 typval_T *tv; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
610 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
611 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
|
612 { |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
613 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
|
614 goto theend; |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
615 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
616 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
|
617 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
|
618 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
|
619 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
|
620 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
621 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
|
622 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
|
623 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
624 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
|
625 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
626 tv = &list->lv_u.mat.lv_last->li_tv; |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
627 actual = get_vim_var_str(VV_ERRMSG); |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
628 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
|
629 if (!pattern_match(expected, actual, FALSE)) |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
630 { |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
631 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
|
632 expected_str = expected; |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
633 } |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
634 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
635 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
636 else |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 { |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
638 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
|
639 goto theend; |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
640 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
641 |
21869
25ef87c95880
patch 8.2.1484: flaky failure in assert_fails()
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
642 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
|
643 && 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
|
644 { |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
645 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
|
646 { |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
647 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
|
648 goto theend; |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
649 } |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
650 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
|
651 && 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
|
652 { |
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
|
653 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
|
654 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
|
655 } |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
656 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
|
657 { |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
658 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
|
659 { |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
660 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
|
661 goto theend; |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
662 } |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
663 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
|
664 && !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
|
665 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
|
666 { |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
667 error_found = TRUE; |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
668 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
|
669 } |
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
|
670 } |
21859
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
671 } |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
672 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
673 if (error_found) |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
674 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
675 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
|
676 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 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
|
678 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
|
679 { |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
680 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
|
681 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
|
682 } |
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
|
683 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
|
684 { |
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
|
685 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
|
686 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
|
687 } |
21859
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
688 else |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
689 { |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
690 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
|
691 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
|
692 } |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
693 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
|
694 &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
|
695 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
|
696 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
|
697 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 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
|
700 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
703 theend: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 trylevel = save_trylevel; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
705 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
|
706 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
|
707 did_emsg = FALSE; |
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
708 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
|
709 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
|
710 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
|
711 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
|
712 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
|
713 VIM_CLEAR(emsg_assert_fails_msg); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 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
|
715 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
|
716 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
|
717 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
719 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
720 * "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
|
721 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 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
|
724 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
725 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
|
726 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
729 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
|
730 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
732 int error = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
733 char_u *tofree; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 char msg[200]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
735 char_u numbuf[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
736 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 #ifdef FEAT_FLOAT |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 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
|
739 || 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
|
740 || 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
|
741 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 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
|
743 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
|
744 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
|
745 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 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
|
747 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 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
|
750 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
751 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
|
752 vim_free(tofree); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
754 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 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
|
757 flower, fupper, factual); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 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
|
759 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 return 1; |
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 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 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
|
769 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
|
770 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
|
771 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 if (error) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 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
|
775 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 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
|
778 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 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
|
780 vim_free(tofree); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 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
|
785 (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
|
786 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
|
787 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
789 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 return 1; |
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 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
793 return 0; |
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 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 * "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
|
798 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 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
|
801 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 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
|
803 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 * "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
|
807 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 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
|
810 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 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
|
812 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 * "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
|
816 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
818 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
|
819 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 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
|
821 } |
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 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
824 * "assert_report(msg)" function |
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 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
827 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
|
828 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
829 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
830 |
25228
a703b3f28ef4
patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25198
diff
changeset
|
831 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
|
832 return; |
a703b3f28ef4
patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25198
diff
changeset
|
833 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
834 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
835 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
|
836 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
838 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
|
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 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 * "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
|
843 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
844 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 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
|
846 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 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
|
848 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
850 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 * "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
|
852 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 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
|
855 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 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
|
857 || 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
|
858 || 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
|
859 || 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
|
860 || argvars[2].v_type != VAR_NUMBER) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 else |
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 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
|
865 if (alloc_fail_id >= aid_last) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 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
|
868 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
|
869 did_outofmem_msg = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 } |
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 * "test_autochdir()" |
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_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
|
878 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 #if defined(FEAT_AUTOCHDIR) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 test_autochdir = TRUE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 * "test_feedinput()" |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 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
|
889 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 #ifdef USE_INPUT_BUF |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 char_u *val = tv_get_string_chk(&argvars[0]); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 |
19209
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
893 # ifdef VIMDLL |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
894 // 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
|
895 if (!gui.in_use) |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
896 return; |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
897 # endif |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
898 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 if (val != NULL) |
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 trash_input_buf(); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 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
|
903 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 * "test_getvalue({name})" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
909 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 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
|
912 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 if (argvars[0].v_type != VAR_STRING) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 char_u *name = 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
|
918 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 if (STRCMP(name, (char_u *)"need_fileinfo") == 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 rettv->vval.v_number = need_fileinfo; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 semsg(_(e_invarg2), name); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 |
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 * "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
|
928 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 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
|
931 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 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
|
933 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 if (argvars[0].v_type != VAR_STRING) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 name = 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
|
939 if (reset_option_was_set(name) == FAIL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 semsg(_(e_invarg2), name); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 } |
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 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 * "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
|
946 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 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
|
949 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 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
|
951 int val; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 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
|
953 |
25252
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
954 if (in_vim9script() |
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
955 && (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
|
956 || check_for_number_arg(argvars, 1) == FAIL)) |
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
957 return; |
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
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 (argvars[0].v_type != VAR_STRING |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 || (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
|
961 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 else |
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 name = 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
|
965 val = (int)tv_get_number(&argvars[1]); |
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 if (STRCMP(name, (char_u *)"redraw") == 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 disable_redraw_for_testing = val; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 else if (STRCMP(name, (char_u *)"redraw_flag") == 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 ignore_redraw_flag_for_testing = val; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 else if (STRCMP(name, (char_u *)"char_avail") == 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 disable_char_avail_for_testing = val; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
973 else if (STRCMP(name, (char_u *)"starting") == 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
974 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
975 if (val) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 if (save_starting < 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
978 save_starting = starting; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 starting = 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 starting = save_starting; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 save_starting = -1; |
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 else if (STRCMP(name, (char_u *)"nfa_fail") == 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 nfa_fail_for_testing = val; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 else if (STRCMP(name, (char_u *)"no_query_mouse") == 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 no_query_mouse_for_testing = val; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 else if (STRCMP(name, (char_u *)"no_wait_return") == 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 no_wait_return = val; |
20861
1725bb56178a
patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
993 else if (STRCMP(name, (char_u *)"ui_delay") == 0) |
1725bb56178a
patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
994 ui_delay_for_testing = val; |
20836
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20834
diff
changeset
|
995 else if (STRCMP(name, (char_u *)"term_props") == 0) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20834
diff
changeset
|
996 reset_term_props_on_termresponse = val; |
24089
cdeec1389c8c
patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
997 else if (STRCMP(name, (char_u *)"uptime") == 0) |
cdeec1389c8c
patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
998 override_sysinfo_uptime = val; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
999 else if (STRCMP(name, (char_u *)"ALL") == 0) |
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 disable_char_avail_for_testing = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 disable_redraw_for_testing = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 ignore_redraw_flag_for_testing = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 nfa_fail_for_testing = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 no_query_mouse_for_testing = FALSE; |
20861
1725bb56178a
patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents:
20836
diff
changeset
|
1006 ui_delay_for_testing = 0; |
20836
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20834
diff
changeset
|
1007 reset_term_props_on_termresponse = FALSE; |
24089
cdeec1389c8c
patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
1008 override_sysinfo_uptime = -1; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 if (save_starting >= 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 starting = save_starting; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1012 save_starting = -1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1013 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1015 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1016 semsg(_(e_invarg2), name); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1019 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1020 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1021 * "test_refcount({expr})" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1022 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1024 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
|
1025 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 int retval = -1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1027 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 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
|
1029 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 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
|
1031 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
|
1032 case VAR_VOID: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 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
|
1034 case VAR_BOOL: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 case VAR_FLOAT: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 case VAR_SPECIAL: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1037 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
|
1038 case VAR_INSTR: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 case VAR_JOB: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 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
|
1043 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
|
1044 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 case VAR_CHANNEL: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 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
|
1049 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
|
1050 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 case VAR_FUNC: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 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
|
1054 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 ufunc_T *fp; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
1057 fp = find_func(argvars[0].vval.v_string, FALSE, NULL); |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 if (fp != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 retval = fp->uf_refcount; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1062 case VAR_PARTIAL: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 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
|
1064 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
|
1065 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1066 case VAR_BLOB: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 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
|
1068 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
|
1069 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 case VAR_LIST: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 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
|
1072 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
|
1073 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 case VAR_DICT: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 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
|
1076 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
|
1077 break; |
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 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 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
|
1081 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
|
1082 |
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 |
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 * "test_garbagecollect_now()" function |
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 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 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
|
1090 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
1091 // 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
|
1092 // while still in use. |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 garbage_collect(TRUE); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1096 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 * "test_garbagecollect_soon()" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1099 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1100 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
|
1101 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1102 may_garbage_collect = TRUE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1104 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1105 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 * "test_ignore_error()" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1107 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1108 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1109 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
|
1110 { |
25198
eafc0e07b188
patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25060
diff
changeset
|
1111 if (argvars[0].v_type != VAR_STRING) |
eafc0e07b188
patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25060
diff
changeset
|
1112 emsg(_(e_invarg)); |
eafc0e07b188
patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25060
diff
changeset
|
1113 else |
eafc0e07b188
patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25060
diff
changeset
|
1114 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
|
1115 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1116 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1117 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1118 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
|
1119 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1120 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
|
1121 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
|
1122 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1123 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1124 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1125 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1126 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
|
1127 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1128 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
|
1129 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
|
1130 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1131 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1132 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1133 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1134 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
|
1135 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 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
|
1137 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1138 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1139 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1140 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 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
|
1142 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 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
|
1144 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
|
1145 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1146 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1148 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1149 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
|
1150 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1151 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
|
1152 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1154 void |
19874
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1155 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
|
1156 { |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1157 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
|
1158 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
|
1159 } |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1160 |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1161 void |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 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
|
1163 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 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
|
1165 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
|
1166 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1167 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1168 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1169 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
|
1170 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1171 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
|
1172 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
|
1173 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 |
19483
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1175 void |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1176 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
|
1177 { |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1178 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
|
1179 } |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1180 |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1181 void |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1182 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
|
1183 { |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1184 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
|
1185 } |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1186 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 #ifdef FEAT_GUI |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 f_test_scrollbar(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
|
1190 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 char_u *which; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 long value; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 int dragging; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 scrollbar_T *sb = NULL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 if (argvars[0].v_type != VAR_STRING |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 || (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
|
1198 || (argvars[2].v_type) != VAR_NUMBER) |
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 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 return; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1202 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 which = 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
|
1204 value = tv_get_number(&argvars[1]); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 dragging = tv_get_number(&argvars[2]); |
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 if (STRCMP(which, "left") == 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 sb = &curwin->w_scrollbars[SBAR_LEFT]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1209 else if (STRCMP(which, "right") == 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1210 sb = &curwin->w_scrollbars[SBAR_RIGHT]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 else if (STRCMP(which, "hor") == 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 sb = &gui.bottom_sbar; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 if (sb == NULL) |
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 semsg(_(e_invarg2), which); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 return; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 gui_drag_scrollbar(sb, value, dragging); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 # ifndef USE_ON_FLY_SCROLL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 // need to loop through normal_cmd() to handle the scroll events |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 exec_normal(FALSE, TRUE, FALSE); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 # endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1225 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 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
|
1228 { |
24998
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1229 if (argvars[0].v_type != VAR_NUMBER || (argvars[1].v_type) != VAR_NUMBER) |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1230 { |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1231 emsg(_(e_invarg)); |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1232 return; |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1233 } |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1234 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1235 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
|
1236 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
|
1237 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1238 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1239 void |
24982
4cb423b9250d
patch 8.2.3028: GUI mouse events not tested
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1240 f_test_gui_mouse_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
4cb423b9250d
patch 8.2.3028: GUI mouse events not tested
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1241 { |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1242 # ifdef FEAT_GUI |
24998
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1243 int button; |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1244 int row; |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1245 int col; |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1246 int repeated_click; |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1247 int_u mods; |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1248 |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1249 if (argvars[0].v_type != VAR_NUMBER |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1250 || (argvars[1].v_type) != VAR_NUMBER |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1251 || (argvars[2].v_type) != VAR_NUMBER |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1252 || (argvars[3].v_type) != VAR_NUMBER |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1253 || (argvars[4].v_type) != VAR_NUMBER) |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1254 { |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1255 emsg(_(e_invarg)); |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1256 return; |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1257 } |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1258 |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1259 button = tv_get_number(&argvars[0]); |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1260 row = tv_get_number(&argvars[1]); |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1261 col = tv_get_number(&argvars[2]); |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1262 repeated_click = tv_get_number(&argvars[3]); |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1263 mods = tv_get_number(&argvars[4]); |
24982
4cb423b9250d
patch 8.2.3028: GUI mouse events not tested
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1264 |
4cb423b9250d
patch 8.2.3028: GUI mouse events not tested
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1265 gui_send_mouse_event(button, TEXT_X(col - 1), TEXT_Y(row - 1), repeated_click, mods); |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1266 # endif |
24982
4cb423b9250d
patch 8.2.3028: GUI mouse events not tested
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1267 } |
4cb423b9250d
patch 8.2.3028: GUI mouse events not tested
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1268 |
4cb423b9250d
patch 8.2.3028: GUI mouse events not tested
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1269 void |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 f_test_settime(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
|
1271 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 time_for_testing = (time_t)tv_get_number(&argvars[0]); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1275 void |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1276 f_test_gui_drop_files(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1277 { |
25060
54c0cb81e6a7
patch 8.2.3067: building fails with Athena
Bram Moolenaar <Bram@vim.org>
parents:
25006
diff
changeset
|
1278 #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
|
1279 int row; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1280 int col; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1281 int_u mods; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1282 char_u **fnames; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1283 int count = 0; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1284 list_T *l; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1285 listitem_T *li; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1286 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1287 if (argvars[0].v_type != VAR_LIST |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1288 || (argvars[1].v_type) != VAR_NUMBER |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1289 || (argvars[2].v_type) != VAR_NUMBER |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1290 || (argvars[3].v_type) != VAR_NUMBER) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1291 { |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1292 emsg(_(e_invarg)); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1293 return; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1294 } |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1295 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1296 row = tv_get_number(&argvars[1]); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1297 col = tv_get_number(&argvars[2]); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1298 mods = tv_get_number(&argvars[3]); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1299 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1300 l = argvars[0].vval.v_list; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1301 if (list_len(l) == 0) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1302 return; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1303 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1304 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
|
1305 if (fnames == NULL) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1306 return; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1307 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1308 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
|
1309 { |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1310 // ignore non-string items |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1311 if (li->li_tv.v_type != VAR_STRING) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1312 continue; |
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 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
|
1315 if (fnames[count] == NULL) |
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 while (--count >= 0) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1318 vim_free(fnames[count]); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1319 vim_free(fnames); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1320 return; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1321 } |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1322 count++; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1323 } |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1324 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1325 if (count > 0) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1326 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
|
1327 else |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1328 vim_free(fnames); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1329 # endif |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1330 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 #endif // defined(FEAT_EVAL) |