Mercurial > vim
annotate src/testing.c @ 20861:1725bb56178a v8.2.0982
patch 8.2.0982: insufficient testing for reading/writing files
Commit: https://github.com/vim/vim/commit/b340baed9f7fc1c19a0742e2214d54982190c15e
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 15 19:51:56 2020 +0200
patch 8.2.0982: insufficient testing for reading/writing files
Problem: Insufficient testing for reading/writing files.
Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6257)
Add "ui_delay" to test_override() and use it for the CTRL-O test.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 15 Jun 2020 20:00:05 +0200 |
parents | 2616c5a337e0 |
children | 6a4806e326dd |
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]; |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
25 char_u *sname = estack_sfile(); |
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: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 if (*p < ' ') |
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 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 if (opt_msg_tv->v_type != VAR_UNKNOWN) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 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
|
148 vim_free(tofree); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 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
|
150 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 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
|
153 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
|
154 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
|
155 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
|
156 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 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
|
158 if (exp_str == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 { |
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
|
160 // 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
|
161 // 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
|
162 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
|
163 && 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
|
164 && 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
|
165 { |
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 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 |
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 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
|
173 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
|
174 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
|
175 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
|
176 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
|
177 |
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 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
|
179 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
|
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 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
|
182 { |
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 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
|
184 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
|
185 &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
|
186 { |
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 // 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
|
188 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
|
189 (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
|
190 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
|
191 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
|
192 (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
|
193 } |
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 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
|
195 ++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
|
196 --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
|
197 } |
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 } |
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 |
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 // 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
|
201 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
|
202 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
|
203 { |
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 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
|
205 { |
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 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
|
207 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
|
208 // 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
|
209 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
|
210 (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
|
211 --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
|
212 } |
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 } |
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 } |
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 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 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
|
217 vim_free(tofree); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 ga_concat_shorten_esc(gap, exp_str); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 if (atype != ASSERT_NOTEQUAL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 if (atype == ASSERT_MATCH) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 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
|
225 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
|
226 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
|
227 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 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
|
229 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
|
230 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
|
231 |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
232 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
|
233 { |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
234 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
|
235 |
9a624c1672a3
patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents:
20691
diff
changeset
|
236 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
|
237 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
|
238 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
|
239 } |
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 |
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 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
|
243 { |
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 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
|
245 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
|
246 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 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
|
251 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 garray_T ga; |
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 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
|
255 != (atype == ASSERT_EQUAL)) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 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
|
259 atype); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 return 1; |
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 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 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
|
269 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 char_u buf1[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 char_u buf2[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 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
|
274 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
|
275 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 if (pat == NULL || text == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 else if (pattern_match(pat, text, FALSE) != (atype == ASSERT_MATCH)) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 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
|
282 atype); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 return 1; |
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 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 * 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
|
292 * 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
|
293 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 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
|
296 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 int error = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 |
19102
ba9f50bfda83
patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
300 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
|
301 && 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
|
302 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 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
|
304 || (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
|
305 || error) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 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
|
309 (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
|
310 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
|
311 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
315 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
318 static void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 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
|
320 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
321 char_u *tofree; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
322 char_u numbuf[NUMBUFLEN]; |
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 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
|
325 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 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
|
327 vim_free(tofree); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 ga_concat(gap, cmd); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 assert_beeps(typval_T *argvars) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 char_u *cmd = tv_get_string_chk(&argvars[0]); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 int ret = 0; |
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 called_vim_beep = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
341 suppress_errthrow = TRUE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
342 emsg_silent = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 do_cmdline_cmd(cmd); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
344 if (!called_vim_beep) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 ga_concat(&ga, (char_u *)"command did not beep: "); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 ga_concat(&ga, cmd); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 ret = 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 suppress_errthrow = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 emsg_on_display = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 return ret; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 * "assert_beeps(cmd [, error])" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
361 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 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
|
364 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 rettv->vval.v_number = assert_beeps(argvars); |
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 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 * "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
|
370 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 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
|
373 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 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
|
375 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 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
|
379 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 char_u buf1[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 char_u buf2[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
382 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
|
383 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
|
384 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 FILE *fd1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 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
|
387 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
|
388 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
|
389 int lineidx = 0; |
17377
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 if (fname1 == NULL || fname2 == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 return 0; |
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 IObuff[0] = NUL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 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
|
396 if (fd1 == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 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
|
399 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
402 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
|
403 if (fd2 == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 fclose(fd1); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 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
|
407 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 { |
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
|
410 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
|
411 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
|
412 long linecount = 1; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 for (;;) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 c1 = fgetc(fd1); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 c2 = fgetc(fd2); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 if (c1 == EOF) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 if (c2 != EOF) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 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
|
422 break; |
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 if (c2 == EOF) |
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 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
|
427 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 } |
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
|
429 else |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 { |
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
|
431 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
|
432 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
|
433 ++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
|
434 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
|
435 { |
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 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
|
437 "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
|
438 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
|
439 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
|
440 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
441 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 ++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
|
443 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
|
444 { |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
445 ++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
|
446 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
|
447 } |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
448 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
|
449 { |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
450 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
|
451 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
|
452 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
|
453 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 fclose(fd1); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 fclose(fd2); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 if (IObuff[0] != NUL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 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
|
462 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
|
463 { |
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
464 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
|
465 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
|
466 |
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
467 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
|
468 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
|
469 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
|
470 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 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
|
472 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
|
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 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
|
475 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
|
476 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
|
477 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
|
478 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
|
479 { |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
480 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
|
481 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
|
482 } |
b9a6a129b94e
patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents:
20679
diff
changeset
|
483 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
|
484 } |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
489 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
491 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
492 /* |
20679
1af1d8ff2aa8
patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
493 * "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
|
494 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 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
|
497 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 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
|
499 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
500 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
501 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 * "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
|
503 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
504 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
505 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
|
506 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
507 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
|
508 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
509 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
510 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
511 * "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
|
512 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
513 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 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
|
515 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
517 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
|
518 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
519 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
|
520 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 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
|
523 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 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
|
526 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 else if (error != NULL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 && 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
|
529 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 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
|
532 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
|
533 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
534 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 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
|
536 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 |
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 * "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
|
541 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 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
|
544 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 char_u *cmd = tv_get_string_chk(&argvars[0]); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 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
|
548 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
|
549 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 // 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
|
551 trylevel = 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 suppress_errthrow = TRUE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 emsg_silent = TRUE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 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
|
556 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
|
557 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 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
|
560 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
|
561 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 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
|
564 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 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
|
566 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 char_u buf[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 char *error = (char *)tv_get_string_buf_chk(&argvars[1], buf); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 if (error == NULL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 || strstr((char *)get_vim_var_str(VV_ERRMSG), error) == NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 fill_assert_error(&ga, &argvars[2], NULL, &argvars[1], |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 get_vim_var_tv(VV_ERRMSG), ASSERT_OTHER); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 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
|
577 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
|
578 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 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
|
581 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 trylevel = save_trylevel; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 suppress_errthrow = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 emsg_silent = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 emsg_on_display = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 set_vim_var_string(VV_ERRMSG, NULL, 0); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 * "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
|
593 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 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
|
596 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 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
|
598 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 static int |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
601 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
|
602 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
603 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
604 int error = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
605 char_u *tofree; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
606 char msg[200]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
607 char_u numbuf[NUMBUFLEN]; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
608 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
609 #ifdef FEAT_FLOAT |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
610 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
|
611 || 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
|
612 || 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
|
613 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
614 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
|
615 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
|
616 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
|
617 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 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
|
619 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 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
|
622 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 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
|
624 vim_free(tofree); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
626 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
628 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
|
629 flower, fupper, factual); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
630 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
|
631 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 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
|
641 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
|
642 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
|
643 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
644 if (error) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 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
|
647 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 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
|
650 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 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
|
652 vim_free(tofree); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
653 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 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
|
657 (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
|
658 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
|
659 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
660 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 return 1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 return 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
668 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
669 * "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
|
670 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 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
|
673 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 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
|
675 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
678 * "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
|
679 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 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
|
682 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 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
|
684 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
685 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 * "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
|
688 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 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
|
691 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
692 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
|
693 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
694 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 * "assert_report(msg)" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 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
|
700 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 garray_T ga; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 prepare_assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 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
|
705 assert_error(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
706 ga_clear(&ga); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
707 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
|
708 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
711 * "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
|
712 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 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
|
715 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 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
|
717 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
719 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
720 * "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
|
721 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 f_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
|
724 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
725 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
|
726 || 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
|
727 || 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
|
728 || 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
|
729 || 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
|
730 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 else |
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 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
|
734 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
|
735 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
736 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
|
737 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
|
738 did_outofmem_msg = FALSE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 } |
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 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
743 * "test_autochdir()" |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
744 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
745 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 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
|
747 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 #if defined(FEAT_AUTOCHDIR) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 test_autochdir = TRUE; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
750 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
751 } |
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 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
754 * "test_feedinput()" |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 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
|
758 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 #ifdef USE_INPUT_BUF |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 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
|
761 |
19209
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
762 # ifdef VIMDLL |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
763 // 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
|
764 if (!gui.in_use) |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
765 return; |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
766 # endif |
b780229f5792
patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
767 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 if (val != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 trash_input_buf(); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 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
|
772 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 #endif |
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 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 * "test_getvalue({name})" function |
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 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 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
|
781 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 if (argvars[0].v_type != VAR_STRING) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 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
|
787 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 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
|
789 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
|
790 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 semsg(_(e_invarg2), name); |
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 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 * "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
|
797 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 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
|
800 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 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
|
802 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 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
|
804 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 else |
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 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
|
808 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
|
809 semsg(_(e_invarg2), name); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 * "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
|
815 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
816 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 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
|
818 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 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
|
820 int val; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 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
|
822 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
823 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
|
824 || (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
|
825 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
826 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
827 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
828 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
|
829 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
|
830 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
831 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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 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
|
837 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
|
838 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 if (val) |
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 if (save_starting < 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 save_starting = starting; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 starting = 0; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
844 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 starting = save_starting; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
848 save_starting = -1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
850 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 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
|
852 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
|
853 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
|
854 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
|
855 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
|
856 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
|
857 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
|
858 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
|
859 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
|
860 reset_term_props_on_termresponse = val; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 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
|
862 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 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
|
864 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
|
865 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
|
866 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
|
867 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
|
868 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
|
869 reset_term_props_on_termresponse = FALSE; |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 if (save_starting >= 0) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 starting = save_starting; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 save_starting = -1; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 else |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 semsg(_(e_invarg2), name); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 } |
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 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 * "test_refcount({expr})" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 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
|
886 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 int retval = -1; |
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 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
|
890 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 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
|
892 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
|
893 case VAR_VOID: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 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
|
895 case VAR_BOOL: |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 case VAR_FLOAT: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 case VAR_SPECIAL: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 case VAR_STRING: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 case VAR_JOB: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 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
|
903 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
|
904 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 case VAR_CHANNEL: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 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
|
909 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
|
910 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 case VAR_FUNC: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 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
|
914 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 ufunc_T *fp; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
917 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
|
918 if (fp != NULL) |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 retval = fp->uf_refcount; |
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 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 case VAR_PARTIAL: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 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
|
924 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
|
925 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 case VAR_BLOB: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 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
|
928 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
|
929 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 case VAR_LIST: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 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
|
932 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
|
933 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 case VAR_DICT: |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 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
|
936 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
|
937 break; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 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
|
941 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
|
942 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 * "test_garbagecollect_now()" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 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
|
950 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
951 // 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
|
952 // 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
|
953 garbage_collect(TRUE); |
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 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 * "test_garbagecollect_soon()" function |
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 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 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
|
961 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 may_garbage_collect = TRUE; |
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 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 /* |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 * "test_ignore_error()" function |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
967 */ |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 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
|
970 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 ignore_error_for_testing(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
|
972 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
973 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
974 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
975 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
|
976 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 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
|
978 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
|
979 } |
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 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 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
|
984 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 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
|
986 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
|
987 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 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
|
992 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 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
|
994 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 #ifdef FEAT_JOB_CHANNEL |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
998 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
|
999 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 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
|
1001 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
|
1002 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 f_test_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
|
1007 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 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
|
1009 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 void |
19874
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1012 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
|
1013 { |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1014 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
|
1015 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
|
1016 } |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1017 |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19483
diff
changeset
|
1018 void |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1019 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
|
1020 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1021 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
|
1022 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
|
1023 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1024 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 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
|
1027 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 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
|
1029 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
|
1030 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 |
19483
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1032 void |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1033 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
|
1034 { |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1035 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
|
1036 } |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1037 |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1038 void |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1039 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
|
1040 { |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1041 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
|
1042 } |
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
1043 |
17377
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 #ifdef FEAT_GUI |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 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
|
1047 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 char_u *which; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 long value; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 int dragging; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 scrollbar_T *sb = NULL; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 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
|
1054 || (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
|
1055 || (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
|
1056 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 emsg(_(e_invarg)); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 return; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 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
|
1061 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
|
1062 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
|
1063 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 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
|
1065 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
|
1066 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
|
1067 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
|
1068 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
|
1069 sb = &gui.bottom_sbar; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 if (sb == 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 semsg(_(e_invarg2), which); |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 return; |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 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
|
1076 # 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
|
1077 // 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
|
1078 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
|
1079 # endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 #endif |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 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
|
1085 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1086 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
|
1087 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
|
1088 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1090 void |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 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
|
1092 { |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 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
|
1094 } |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1096 |
cb008de2a6ec
patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 #endif // defined(FEAT_EVAL) |