Mercurial > vim
annotate src/testing.c @ 25368:1ffa8eb30353 v8.2.3221
patch 8.2.3221: Vim9: argument types are not checked at compile time
Commit: https://github.com/vim/vim/commit/a764e73d4ffc5d046807c757eaacb9b0a5408152
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sun Jul 25 15:57:32 2021 +0200
patch 8.2.3221: Vim9: argument types are not checked at compile time
Problem: Vim9: argument types are not checked at compile time.
Solution: Add several more type checks. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/8632)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 25 Jul 2021 16:00:05 +0200 |
parents | 1cde96e768e4 |
children | e8e2c4d33b9b |
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 { |
25368
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
569 char_u *cmd; |
17377
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 |
25368
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
575 if (check_for_string_or_number_arg(argvars, 0) == FAIL |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
576 || check_for_opt_string_or_list_arg(argvars, 1) == FAIL |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
577 || (argvars[1].v_type != VAR_UNKNOWN |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
578 && (argvars[2].v_type != VAR_UNKNOWN |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
579 && (check_for_opt_number_arg(argvars, 3) == FAIL |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
580 || (argvars[3].v_type != VAR_UNKNOWN |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
581 && check_for_opt_string_arg(argvars, 4) == FAIL))))) |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
582 return; |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
583 |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
584 cmd = tv_get_string_chk(&argvars[0]); |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
585 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 // 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
|
587 trylevel = 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 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
|
589 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
|
590 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 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
|
592 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
|
593 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 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
|
596 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
|
597 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 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
|
600 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
601 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
|
602 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
603 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
|
604 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
|
605 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
|
606 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
|
607 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
|
608 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
|
609 : 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
|
610 |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
611 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
|
612 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
613 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
|
614 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
|
615 || 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
|
616 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
617 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
|
618 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
619 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
|
620 typval_T *tv; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
622 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
|
623 { |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
624 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
|
625 goto theend; |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
626 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
627 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
|
628 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
|
629 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
|
630 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
|
631 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
632 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
|
633 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
|
634 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
635 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
|
636 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
637 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
|
638 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
|
639 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
|
640 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
|
641 { |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
642 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
|
643 expected_str = expected; |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
644 } |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
645 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
646 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
647 else |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 { |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
649 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
|
650 goto theend; |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
651 } |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
652 |
21869
25ef87c95880
patch 8.2.1484: flaky failure in assert_fails()
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
653 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
|
654 && 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
|
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 (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
|
657 { |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
658 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
|
659 goto theend; |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
660 } |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
661 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
|
662 && 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
|
663 { |
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 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
|
665 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
|
666 } |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
667 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
|
668 { |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
669 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
|
670 { |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
671 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
|
672 goto theend; |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
673 } |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
674 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
|
675 && !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
|
676 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
|
677 { |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
678 error_found = TRUE; |
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22163
diff
changeset
|
679 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
|
680 } |
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
|
681 } |
21859
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
682 } |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
683 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
684 if (error_found) |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
685 { |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
686 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
|
687 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
688 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
|
689 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
|
690 { |
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.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
|
692 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
|
693 } |
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 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
|
695 { |
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
21869
diff
changeset
|
696 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
|
697 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
|
698 } |
21859
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
699 else |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
700 { |
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
701 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
|
702 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
|
703 } |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
704 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
|
705 &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
|
706 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
|
707 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
|
708 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 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
|
711 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20861
diff
changeset
|
714 theend: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
715 trylevel = save_trylevel; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 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
|
717 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
|
718 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
|
719 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
|
720 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
|
721 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
|
722 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
|
723 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
|
724 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
|
725 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
|
726 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
|
727 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
|
728 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
729 |
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 * "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
|
732 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
733 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 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
|
735 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
736 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
|
737 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 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
|
741 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
743 int error = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
744 char_u *tofree; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
745 char msg[200]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 char_u numbuf[NUMBUFLEN]; |
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 #ifdef FEAT_FLOAT |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 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
|
750 || 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
|
751 || 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
|
752 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 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
|
754 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
|
755 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
|
756 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 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
|
758 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 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
|
761 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 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
|
763 vim_free(tofree); |
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 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 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
|
768 flower, fupper, factual); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 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
|
770 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 #endif |
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 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
|
780 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
|
781 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
|
782 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 if (error) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 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
|
786 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 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
|
789 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 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
|
791 vim_free(tofree); |
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 else |
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 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
|
796 (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
|
797 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
|
798 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 } |
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 return 0; |
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 |
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 * "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
|
809 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 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
|
812 { |
25368
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
813 if (check_for_float_or_nr_arg(argvars, 0) == FAIL |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
814 || check_for_float_or_nr_arg(argvars, 1) == FAIL |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
815 || check_for_float_or_nr_arg(argvars, 2) == FAIL |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
816 || check_for_opt_string_arg(argvars, 3) == FAIL) |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
817 return; |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
818 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 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
|
820 } |
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 * "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
|
824 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
825 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
826 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
|
827 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
828 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
|
829 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
830 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
831 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
832 * "assert_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
|
833 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
834 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
835 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
|
836 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 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
|
838 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
841 * "assert_report(msg)" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
844 f_assert_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
|
845 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 |
25228
a703b3f28ef4
patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25198
diff
changeset
|
848 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
|
849 return; |
a703b3f28ef4
patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25198
diff
changeset
|
850 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 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
|
853 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 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
|
856 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
857 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 * "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
|
860 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 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
|
863 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 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
|
865 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 * "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
|
869 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 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
|
872 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 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
|
874 || 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
|
875 || 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
|
876 || 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
|
877 || 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
|
878 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 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
|
882 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
|
883 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 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
|
885 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
|
886 did_outofmem_msg = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 * "test_autochdir()" |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 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
|
895 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 #if defined(FEAT_AUTOCHDIR) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 test_autochdir = TRUE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 * "test_feedinput()" |
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 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 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
|
906 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 #ifdef USE_INPUT_BUF |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 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
|
909 |
19209
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
910 # ifdef VIMDLL |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
911 // 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
|
912 if (!gui.in_use) |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
913 return; |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
914 # endif |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
915 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 if (val != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 trash_input_buf(); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 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
|
920 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 } |
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 * "test_getvalue({name})" function |
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 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 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
|
929 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 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
|
931 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 else |
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 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
|
935 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 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
|
937 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
|
938 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 semsg(_(e_invarg2), name); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 } |
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 * "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
|
945 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 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
|
948 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 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
|
950 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 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
|
952 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 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
|
956 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
|
957 semsg(_(e_invarg2), name); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
961 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 * "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
|
963 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
964 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 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
|
966 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
967 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
|
968 int val; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 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
|
970 |
25252
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
971 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
|
972 && (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
|
973 || 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
|
974 return; |
acda780ffc3e
patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25228
diff
changeset
|
975 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 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
|
977 || (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
|
978 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 else |
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 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
|
982 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
|
983 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 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
|
985 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
|
986 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
|
987 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
|
988 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
|
989 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
|
990 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
|
991 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 if (val) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 if (save_starting < 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 save_starting = starting; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 starting = 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
998 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
999 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 starting = save_starting; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1001 save_starting = -1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 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
|
1005 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
|
1006 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
|
1007 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
|
1008 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
|
1009 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
|
1010 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
|
1011 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
|
1012 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
|
1013 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
|
1014 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
|
1015 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
|
1016 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
|
1017 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 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
|
1019 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
|
1020 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
|
1021 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
|
1022 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
|
1023 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
|
1024 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
|
1025 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
|
1026 if (save_starting >= 0) |
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 starting = save_starting; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 save_starting = -1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 semsg(_(e_invarg2), name); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1037 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 * "test_refcount({expr})" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 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
|
1042 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 int retval = -1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 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
|
1046 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 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
|
1048 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
|
1049 case VAR_VOID: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 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
|
1051 case VAR_BOOL: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 case VAR_FLOAT: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 case VAR_SPECIAL: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 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
|
1055 case VAR_INSTR: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 case VAR_JOB: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 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
|
1060 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
|
1061 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1062 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 case VAR_CHANNEL: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 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
|
1066 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
|
1067 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 case VAR_FUNC: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 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
|
1071 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 ufunc_T *fp; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
1074 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
|
1075 if (fp != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1076 retval = fp->uf_refcount; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 case VAR_PARTIAL: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 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
|
1081 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
|
1082 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 case VAR_BLOB: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 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
|
1085 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
|
1086 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 case VAR_LIST: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 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
|
1089 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
|
1090 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 case VAR_DICT: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 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
|
1093 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
|
1094 break; |
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 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
|
1098 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
|
1099 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1100 } |
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 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 * "test_garbagecollect_now()" function |
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 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 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
|
1107 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
1108 // 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
|
1109 // 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
|
1110 garbage_collect(TRUE); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1111 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1112 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1113 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1114 * "test_garbagecollect_soon()" function |
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 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1117 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
|
1118 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1119 may_garbage_collect = TRUE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1120 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1121 |
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 * "test_ignore_error()" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1124 */ |
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_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
|
1127 { |
25198
eafc0e07b188
patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25060
diff
changeset
|
1128 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
|
1129 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
|
1130 else |
eafc0e07b188
patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25060
diff
changeset
|
1131 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
|
1132 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1133 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1134 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1135 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
|
1136 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 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
|
1138 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
|
1139 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1140 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1142 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 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
|
1144 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1145 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
|
1146 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
|
1147 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1148 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1149 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1150 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1151 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
|
1152 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 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
|
1154 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1156 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 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
|
1159 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1160 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
|
1161 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
|
1162 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1163 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1165 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1166 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
|
1167 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1168 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
|
1169 } |
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 void |
19874
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1172 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
|
1173 { |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1174 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
|
1175 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
|
1176 } |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1177 |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1178 void |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 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
|
1180 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 rettv->v_type = VAR_PARTIAL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 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
|
1183 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1184 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 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
|
1187 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 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
|
1189 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
|
1190 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 |
19483
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1192 void |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1193 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
|
1194 { |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1195 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
|
1196 } |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1197 |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1198 void |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1199 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
|
1200 { |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1201 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
|
1202 } |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1203 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 #ifdef FEAT_GUI |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1206 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
|
1207 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 char_u *which; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1209 long value; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1210 int dragging; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 scrollbar_T *sb = NULL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 |
25356
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
1213 if (check_for_string_arg(argvars, 0) == FAIL |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
1214 || check_for_number_arg(argvars, 1) == FAIL |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
1215 || check_for_number_arg(argvars, 2) == FAIL) |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
1216 return; |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
1217 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 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
|
1219 || (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
|
1220 || (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
|
1221 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 return; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1225 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
|
1226 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
|
1227 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
|
1228 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 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
|
1230 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
|
1231 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
|
1232 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
|
1233 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
|
1234 sb = &gui.bottom_sbar; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1235 if (sb == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1236 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1237 semsg(_(e_invarg2), which); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1238 return; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1239 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1240 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
|
1241 # 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
|
1242 // 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
|
1243 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
|
1244 # endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1245 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1246 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1247 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1248 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1249 f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1250 { |
24998
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1251 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
|
1252 { |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1253 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
|
1254 return; |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1255 } |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1256 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1257 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
|
1258 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
|
1259 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1260 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1261 void |
24982
4cb423b9250d
patch 8.2.3028: GUI mouse events not tested
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1262 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
|
1263 { |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1264 # 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
|
1265 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
|
1266 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
|
1267 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
|
1268 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
|
1269 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
|
1270 |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25252
diff
changeset
|
1271 if (check_for_number_arg(argvars, 0) == FAIL |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25252
diff
changeset
|
1272 || check_for_number_arg(argvars, 1) == FAIL |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25252
diff
changeset
|
1273 || check_for_number_arg(argvars, 2) == FAIL |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25252
diff
changeset
|
1274 || check_for_number_arg(argvars, 3) == FAIL |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25252
diff
changeset
|
1275 || check_for_number_arg(argvars, 4) == FAIL) |
24998
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1276 return; |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1277 |
3b1770226f85
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24982
diff
changeset
|
1278 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
|
1279 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
|
1280 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
|
1281 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
|
1282 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
|
1283 |
4cb423b9250d
patch 8.2.3028: GUI mouse events not tested
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1284 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
|
1285 # endif |
24982
4cb423b9250d
patch 8.2.3028: GUI mouse events not tested
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1286 } |
4cb423b9250d
patch 8.2.3028: GUI mouse events not tested
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1287 |
4cb423b9250d
patch 8.2.3028: GUI mouse events not tested
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1288 void |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 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
|
1290 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1291 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
|
1292 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1294 void |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1295 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
|
1296 { |
25060
54c0cb81e6a7
patch 8.2.3067: building fails with Athena
Bram Moolenaar <Bram@vim.org>
parents:
25006
diff
changeset
|
1297 #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
|
1298 int row; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1299 int col; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1300 int_u mods; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1301 char_u **fnames; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1302 int count = 0; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1303 list_T *l; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1304 listitem_T *li; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1305 |
25356
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
1306 if (check_for_list_arg(argvars, 0) == FAIL |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
1307 || check_for_number_arg(argvars, 1) == FAIL |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
1308 || check_for_number_arg(argvars, 2) == FAIL |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
1309 || check_for_number_arg(argvars, 3) == FAIL) |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1310 return; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1311 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1312 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
|
1313 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
|
1314 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
|
1315 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1316 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
|
1317 if (list_len(l) == 0) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1318 return; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1319 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1320 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
|
1321 if (fnames == NULL) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1322 return; |
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 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
|
1325 { |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1326 // ignore non-string items |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1327 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
|
1328 continue; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1329 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1330 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
|
1331 if (fnames[count] == NULL) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1332 { |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1333 while (--count >= 0) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1334 vim_free(fnames[count]); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1335 vim_free(fnames); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1336 return; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1337 } |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1338 count++; |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1339 } |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1340 |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1341 if (count > 0) |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1342 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
|
1343 else |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1344 vim_free(fnames); |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1345 # endif |
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24998
diff
changeset
|
1346 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1347 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1348 #endif // defined(FEAT_EVAL) |