annotate src/testing.c @ 22165:c512e6f57ff2 v8.2.1632

patch 8.2.1632: not checking the context of test_fails() Commit: https://github.com/vim/vim/commit/44d6652d561d628d12e3ff7f6636ea7d1f805ced Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 6 22:26:57 2020 +0200 patch 8.2.1632: not checking the context of test_fails() Problem: Not checking the context of test_fails(). Solution: Add the line number and context arguments. Give error if assert_fails() argument types are wrong.
author Bram Moolenaar <Bram@vim.org>
date Sun, 06 Sep 2020 22:30:03 +0200
parents b6d36f0b4f03
children a607f02fd17a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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];
21493
7449921216bc patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents: 21297
diff changeset
25 char_u *sname = estack_sfile(FALSE);
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 ga_init2(gap, 1, 100);
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18949
diff changeset
28 if (sname != NULL)
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 {
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18949
diff changeset
30 ga_concat(gap, sname);
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18949
diff changeset
31 if (SOURCING_LNUM > 0)
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 ga_concat(gap, (char_u *)" ");
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 }
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18949
diff changeset
34 if (SOURCING_LNUM > 0)
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 {
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18949
diff changeset
36 sprintf(buf, "line %ld", (long)SOURCING_LNUM);
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 ga_concat(gap, (char_u *)buf);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 }
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18949
diff changeset
39 if (sname != NULL || SOURCING_LNUM > 0)
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 ga_concat(gap, (char_u *)": ");
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18949
diff changeset
41 vim_free(sname);
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 * Append "p[clen]" to "gap", escaping unprintable characters.
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 * Changes NL to \n, CR to \r, etc.
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 static void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 ga_concat_esc(garray_T *gap, char_u *p, int clen)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 char_u buf[NUMBUFLEN];
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 if (clen > 1)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 mch_memmove(buf, p, clen);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 buf[clen] = NUL;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 ga_concat(gap, buf);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 else switch (*p)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 case BS: ga_concat(gap, (char_u *)"\\b"); break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 case ESC: ga_concat(gap, (char_u *)"\\e"); break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 case FF: ga_concat(gap, (char_u *)"\\f"); break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 case NL: ga_concat(gap, (char_u *)"\\n"); break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 case TAB: ga_concat(gap, (char_u *)"\\t"); break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 case CAR: ga_concat(gap, (char_u *)"\\r"); break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 case '\\': ga_concat(gap, (char_u *)"\\\\"); break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 default:
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
69 if (*p < ' ' || *p == 0x7f)
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 vim_snprintf((char *)buf, NUMBUFLEN, "\\x%02x", *p);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 ga_concat(gap, buf);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 ga_append(gap, *p);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 * Append "str" to "gap", escaping unprintable characters.
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 * Changes NL to \n, CR to \r, etc.
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 static void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 ga_concat_shorten_esc(garray_T *gap, char_u *str)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 char_u *p;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 char_u *s;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 int c;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 int clen;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 char_u buf[NUMBUFLEN];
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 int same_len;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 if (str == NULL)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 ga_concat(gap, (char_u *)"NULL");
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 return;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 for (p = str; *p != NUL; ++p)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 same_len = 1;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 s = p;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 c = mb_ptr2char_adv(&s);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 clen = s - p;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 while (*s != NUL && c == mb_ptr2char(s))
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 ++same_len;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 s += clen;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 if (same_len > 20)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 ga_concat(gap, (char_u *)"\\[");
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 ga_concat_esc(gap, p, clen);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 ga_concat(gap, (char_u *)" occurs ");
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 vim_snprintf((char *)buf, NUMBUFLEN, "%d", same_len);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 ga_concat(gap, buf);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 ga_concat(gap, (char_u *)" times]");
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 p = s - 1;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 ga_concat_esc(gap, p, clen);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 * Fill "gap" with information about an assert error.
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 static void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 fill_assert_error(
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 garray_T *gap,
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 typval_T *opt_msg_tv,
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 char_u *exp_str,
20834
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
134 typval_T *exp_tv_arg,
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
135 typval_T *got_tv_arg,
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 assert_type_T atype)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 char_u numbuf[NUMBUFLEN];
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 char_u *tofree;
20834
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
140 typval_T *exp_tv = exp_tv_arg;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
141 typval_T *got_tv = got_tv_arg;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
142 int did_copy = FALSE;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
143 int omitted = 0;
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144
21859
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
145 if (opt_msg_tv->v_type != VAR_UNKNOWN
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
146 && !(opt_msg_tv->v_type == VAR_STRING
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
147 && (opt_msg_tv->vval.v_string == NULL
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
148 || *opt_msg_tv->vval.v_string == NUL)))
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 ga_concat(gap, echo_string(opt_msg_tv, &tofree, numbuf, 0));
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 vim_free(tofree);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 ga_concat(gap, (char_u *)": ");
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 ga_concat(gap, (char_u *)"Pattern ");
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 else if (atype == ASSERT_NOTEQUAL)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 ga_concat(gap, (char_u *)"Expected not equal to ");
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 ga_concat(gap, (char_u *)"Expected ");
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 if (exp_str == NULL)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 {
20834
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
163 // When comparing dictionaries, drop the items that are equal, so that
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
164 // it's a lot easier to see what differs.
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
165 if (atype != ASSERT_NOTEQUAL
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
166 && exp_tv->v_type == VAR_DICT && got_tv->v_type == VAR_DICT
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
167 && exp_tv->vval.v_dict != NULL && got_tv->vval.v_dict != NULL)
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
168 {
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
169 dict_T *exp_d = exp_tv->vval.v_dict;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
170 dict_T *got_d = got_tv->vval.v_dict;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
171 hashitem_T *hi;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
172 dictitem_T *item2;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
173 int todo;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
174
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
175 did_copy = TRUE;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
176 exp_tv->vval.v_dict = dict_alloc();
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
177 got_tv->vval.v_dict = dict_alloc();
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
178 if (exp_tv->vval.v_dict == NULL || got_tv->vval.v_dict == NULL)
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
179 return;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
180
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
181 todo = (int)exp_d->dv_hashtab.ht_used;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
182 for (hi = exp_d->dv_hashtab.ht_array; todo > 0; ++hi)
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
183 {
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
184 if (!HASHITEM_EMPTY(hi))
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
185 {
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
186 item2 = dict_find(got_d, hi->hi_key, -1);
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
187 if (item2 == NULL || !tv_equal(&HI2DI(hi)->di_tv,
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
188 &item2->di_tv, FALSE, FALSE))
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
189 {
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
190 // item of exp_d not present in got_d or values differ.
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
191 dict_add_tv(exp_tv->vval.v_dict,
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
192 (char *)hi->hi_key, &HI2DI(hi)->di_tv);
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
193 if (item2 != NULL)
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
194 dict_add_tv(got_tv->vval.v_dict,
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
195 (char *)hi->hi_key, &item2->di_tv);
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
196 }
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
197 else
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
198 ++omitted;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
199 --todo;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
200 }
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
201 }
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
202
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
203 // Add items only present in got_d.
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
204 todo = (int)got_d->dv_hashtab.ht_used;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
205 for (hi = got_d->dv_hashtab.ht_array; todo > 0; ++hi)
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
206 {
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
207 if (!HASHITEM_EMPTY(hi))
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
208 {
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
209 item2 = dict_find(exp_d, hi->hi_key, -1);
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
210 if (item2 == NULL)
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
211 // item of got_d not present in exp_d
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
212 dict_add_tv(got_tv->vval.v_dict,
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
213 (char *)hi->hi_key, &HI2DI(hi)->di_tv);
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
214 --todo;
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
215 }
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
216 }
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
217 }
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
218
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 ga_concat_shorten_esc(gap, tv2string(exp_tv, &tofree, numbuf, 0));
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 vim_free(tofree);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 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
224 if (atype != ASSERT_NOTEQUAL)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 if (atype == ASSERT_MATCH)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 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
228 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
229 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
230 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 ga_concat(gap, (char_u *)" but got ");
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 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
233 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
234
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 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
236 {
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 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
238
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
239 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
240 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
241 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
242 }
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
243 }
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
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 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
246 {
9a624c1672a3 patch 8.2.0969: assert_equal() output for dicts is hard to figure out
Bram Moolenaar <Bram@vim.org>
parents: 20691
diff changeset
247 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
248 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
249 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 }
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 static int
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 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
254 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 garray_T ga;
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 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
258 != (atype == ASSERT_EQUAL))
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 prepare_assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 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
262 atype);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 ga_clear(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 return 1;
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 return 0;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 }
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 static int
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 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
272 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 garray_T ga;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 char_u buf1[NUMBUFLEN];
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 char_u buf2[NUMBUFLEN];
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
276 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
277 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
278 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
279
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
280 if (called_emsg == called_emsg_before
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
281 && pattern_match(pat, text, FALSE) != (atype == ASSERT_MATCH))
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 prepare_assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 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
285 atype);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 ga_clear(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 return 1;
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 return 0;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292
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 * 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
295 * 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
296 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 static int
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 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
299 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 int error = FALSE;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 garray_T ga;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302
19102
ba9f50bfda83 patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
303 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
304 && 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
305 return 0;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 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
307 || (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
308 || error)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 prepare_assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 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
312 (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
313 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
314 assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 ga_clear(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 return 1;
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 return 0;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 }
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 static void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 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
323 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 char_u *tofree;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 char_u numbuf[NUMBUFLEN];
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 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
328 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 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
330 vim_free(tofree);
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 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 ga_concat(gap, cmd);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 }
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 static int
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 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
338 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 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
340 garray_T ga;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 int ret = 0;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 called_vim_beep = FALSE;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 suppress_errthrow = TRUE;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 emsg_silent = FALSE;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 do_cmdline_cmd(cmd);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 if (!called_vim_beep)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 prepare_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_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
351 ga_concat(&ga, cmd);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 ga_clear(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 ret = 1;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 suppress_errthrow = FALSE;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 emsg_on_display = FALSE;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 return ret;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360 }
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 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 * "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
364 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 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
367 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 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
369 }
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 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 * "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
373 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 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
376 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 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
378 }
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 static int
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 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
382 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 char_u buf1[NUMBUFLEN];
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 char_u buf2[NUMBUFLEN];
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
385 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
386 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
387 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
388 garray_T ga;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 FILE *fd1;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 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
391 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
392 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
393 int lineidx = 0;
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394
21297
3ef53d66f30d patch 8.2.1199: not all assert functions are fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
395 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
396 return 0;
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 IObuff[0] = NUL;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 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
400 if (fd1 == NULL)
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 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
403 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 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
407 if (fd2 == NULL)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 fclose(fd1);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 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
411 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 {
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
414 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
415 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
416 long linecount = 1;
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 for (;;)
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 c1 = fgetc(fd1);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 c2 = fgetc(fd2);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 if (c1 == EOF)
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 if (c2 != EOF)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 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
426 break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 else if (c2 == EOF)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 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
431 break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 }
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
433 else
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 {
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
435 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
436 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
437 ++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
438 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
439 {
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 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
441 "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
442 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
443 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
444 }
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 ++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
447 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
448 {
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 ++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
450 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
451 }
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 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
453 {
b9a6a129b94e patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
454 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
455 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
456 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
457 }
17377
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 fclose(fd1);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 fclose(fd2);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 if (IObuff[0] != NUL)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 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
466 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
467 {
1af1d8ff2aa8 patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
468 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
469 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
470
1af1d8ff2aa8 patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
471 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
472 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
473 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
474 }
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 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
476 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
477 {
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 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
479 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
480 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
481 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
482 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
483 {
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 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
485 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
486 }
b9a6a129b94e patch 8.2.0899: assert_equalfile() does not give a hint about the difference
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
487 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
488 }
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 ga_clear(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 return 1;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 return 0;
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
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 /*
20679
1af1d8ff2aa8 patch 8.2.0893: assert_equalfile() does not take a third argument
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
497 * "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
498 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 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
501 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 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
503 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 * "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
507 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 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
510 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 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
512 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 * "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
516 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 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
519 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 garray_T ga;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 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
522
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 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
524 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 prepare_assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 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
527 assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528 ga_clear(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 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
530 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 else if (error != NULL
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 && 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
533 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 prepare_assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535 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
536 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
537 assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 ga_clear(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539 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
540 }
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
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 * "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
545 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 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
548 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 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
550 garray_T ga;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 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
552 int called_emsg_before = called_emsg;
22165
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
553 char *wrong_arg_msg = NULL;
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555 // 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
556 trylevel = 0;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557 suppress_errthrow = TRUE;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 emsg_silent = TRUE;
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
559 emsg_assert_fails_used = TRUE;
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
561 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
562 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
563 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 prepare_assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 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
566 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
567 assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 ga_clear(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 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
570 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 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
572 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 char_u buf[NUMBUFLEN];
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
574 char_u *expected;
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
575 int error_found = FALSE;
22163
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
576 int error_found_index = 1;
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
577 char_u *actual = emsg_assert_fails_msg == NULL ? (char_u *)"[unknown]"
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
578 : emsg_assert_fails_msg;
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
579
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
580 if (argvars[1].v_type == VAR_STRING)
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
581 {
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
582 expected = tv_get_string_buf_chk(&argvars[1], buf);
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
583 error_found = expected == NULL
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
584 || strstr((char *)actual, (char *)expected) == NULL;
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
585 }
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
586 else if (argvars[1].v_type == VAR_LIST)
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
587 {
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
588 list_T *list = argvars[1].vval.v_list;
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
589 typval_T *tv;
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
591 if (list == NULL || list->lv_len < 1 || list->lv_len > 2)
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
592 {
22165
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
593 wrong_arg_msg = e_assert_fails_second_arg;
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
594 goto theend;
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
595 }
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
596 CHECK_LIST_MATERIALIZE(list);
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
597 tv = &list->lv_first->li_tv;
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
598 expected = tv_get_string_buf_chk(tv, buf);
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
599 if (!pattern_match(expected, actual, FALSE))
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
600 {
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
601 error_found = TRUE;
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
602 }
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
603 else if (list->lv_len == 2)
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
604 {
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
605 tv = &list->lv_u.mat.lv_last->li_tv;
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
606 actual = get_vim_var_str(VV_ERRMSG);
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
607 expected = tv_get_string_buf_chk(tv, buf);
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
608 if (!pattern_match(expected, actual, FALSE))
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
609 error_found = TRUE;
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
610 }
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
611 }
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
612 else
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613 {
22165
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
614 wrong_arg_msg = e_assert_fails_second_arg;
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
615 goto theend;
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
616 }
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
617
21869
25ef87c95880 patch 8.2.1484: flaky failure in assert_fails()
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
618 if (!error_found && argvars[2].v_type != VAR_UNKNOWN
22165
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
619 && argvars[3].v_type != VAR_UNKNOWN)
22163
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
620 {
22165
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
621 if (argvars[3].v_type != VAR_NUMBER)
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
622 {
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
623 wrong_arg_msg = e_assert_fails_fourth_argument;
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
624 goto theend;
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
625 }
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
626 else if (argvars[3].vval.v_number >= 0
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
627 && argvars[3].vval.v_number != emsg_assert_fails_lnum)
22163
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
628 {
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
629 error_found = TRUE;
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
630 error_found_index = 3;
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
631 }
22165
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
632 if (!error_found && argvars[4].v_type != VAR_UNKNOWN)
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
633 {
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
634 if (argvars[4].v_type != VAR_STRING)
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
635 {
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
636 wrong_arg_msg = e_assert_fails_fifth_argument;
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
637 goto theend;
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
638 }
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
639 else if (argvars[4].vval.v_string != NULL
22163
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
640 && !pattern_match(argvars[4].vval.v_string,
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
641 emsg_assert_fails_context, FALSE))
22165
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
642 {
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
643 error_found = TRUE;
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
644 error_found_index = 4;
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
645 }
22163
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
646 }
21859
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
647 }
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
648
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
649 if (error_found)
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
650 {
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
651 typval_T actual_tv;
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
652
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 prepare_assert_error(&ga);
22163
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
654 if (error_found_index == 3)
21859
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
655 {
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
656 actual_tv.v_type = VAR_NUMBER;
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
657 actual_tv.vval.v_number = emsg_assert_fails_lnum;
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
658 }
22163
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
659 else if (error_found_index == 4)
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
660 {
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
661 actual_tv.v_type = VAR_STRING;
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
662 actual_tv.vval.v_string = emsg_assert_fails_context;
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
663 }
21859
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
664 else
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
665 {
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
666 actual_tv.v_type = VAR_STRING;
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
667 actual_tv.vval.v_string = actual;
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
668 }
3e5d0832a2e7 patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
669 fill_assert_error(&ga, &argvars[2], NULL,
22163
b6d36f0b4f03 patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents: 21869
diff changeset
670 &argvars[error_found_index], &actual_tv, ASSERT_OTHER);
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 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
672 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
673 assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 ga_clear(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 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
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
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
679 theend:
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 trylevel = save_trylevel;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
681 suppress_errthrow = FALSE;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 emsg_silent = FALSE;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
683 emsg_on_display = FALSE;
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
684 emsg_assert_fails_used = FALSE;
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
685 VIM_CLEAR(emsg_assert_fails_msg);
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 set_vim_var_string(VV_ERRMSG, NULL, 0);
22165
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
687 if (wrong_arg_msg != NULL)
c512e6f57ff2 patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents: 22163
diff changeset
688 emsg(_(wrong_arg_msg));
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690
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 * "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
693 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695 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
696 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697 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
698 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
700 static int
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701 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
702 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
703 garray_T ga;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 int error = FALSE;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705 char_u *tofree;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 char msg[200];
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
707 char_u numbuf[NUMBUFLEN];
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 #ifdef FEAT_FLOAT
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
710 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
711 || 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
712 || 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
713 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
714 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
715 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
716 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
717
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718 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
719 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 prepare_assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
721 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
722 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
723 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
724 vim_free(tofree);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 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
729 flower, fupper, factual);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
730 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
731 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
733 ga_clear(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
734 return 1;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
735 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
736 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
737 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
738 #endif
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 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
741 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
742 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
743
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
744 if (error)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745 return 0;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746 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
747 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
748 prepare_assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749 if (argvars[3].v_type != VAR_UNKNOWN)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
751 ga_concat(&ga, tv2string(&argvars[3], &tofree, numbuf, 0));
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
752 vim_free(tofree);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
753 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
754 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
755 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
756 vim_snprintf(msg, 200, "Expected range %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
757 (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
758 ga_concat(&ga, (char_u *)msg);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
760 assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
761 ga_clear(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
762 return 1;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
763 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
764 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 return 0;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
767
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
768 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 * "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
770 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772 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
773 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774 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
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 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778 * "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
779 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 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
782 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 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
784 }
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 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 * "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
788 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
789 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
790 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
791 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
792 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
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 * "assert_report(msg)" 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_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
800 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
801 garray_T ga;
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 prepare_assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
804 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
805 assert_error(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
806 ga_clear(&ga);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
807 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
808 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
809
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
810 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
811 * "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
812 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
813 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
814 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
815 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
816 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
817 }
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 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
820 * "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
821 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
822 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
823 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
824 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
825 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
826 || 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
827 || 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
828 || 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
829 || 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
830 emsg(_(e_invarg));
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
831 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
832 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
833 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
834 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
835 emsg(_(e_invarg));
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
836 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
837 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
838 did_outofmem_msg = FALSE;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
839 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
840 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843 * "test_autochdir()"
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 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
846 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
847 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
848 #if defined(FEAT_AUTOCHDIR)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
849 test_autochdir = TRUE;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
850 #endif
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
851 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854 * "test_feedinput()"
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
855 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
856 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
857 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
858 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
859 #ifdef USE_INPUT_BUF
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
860 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
861
19209
b780229f5792 patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
862 # ifdef VIMDLL
b780229f5792 patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
863 // 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
864 if (!gui.in_use)
b780229f5792 patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
865 return;
b780229f5792 patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
866 # endif
b780229f5792 patch 8.2.0163: test hangs on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
867
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
868 if (val != NULL)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
869 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
870 trash_input_buf();
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
871 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
872 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
873 #endif
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 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
877 * "test_getvalue({name})" function
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 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
880 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
881 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
882 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
883 emsg(_(e_invarg));
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
884 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
885 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886 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
887
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
888 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
889 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
890 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
891 semsg(_(e_invarg2), name);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
892 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
893 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
895 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896 * "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
897 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
898 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899 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
900 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 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
902
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
903 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
904 emsg(_(e_invarg));
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
905 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907 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
908 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
909 semsg(_(e_invarg2), name);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
912
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
913 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914 * "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
915 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
916 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
917 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
918 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919 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
920 int val;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921 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
922
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 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
924 || (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
925 emsg(_(e_invarg));
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
926 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
927 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928 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
929 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
930
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931 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
932 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
933 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
934 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
935 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
936 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
937 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
938 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939 if (val)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
940 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
941 if (save_starting < 0)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
942 save_starting = starting;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 starting = 0;
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 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
947 starting = save_starting;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 save_starting = -1;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
949 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
950 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
951 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
952 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
953 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
954 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
955 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
956 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
957 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
958 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
959 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
960 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
961 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
962 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
963 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
964 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
965 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
966 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
967 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
968 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
969 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
970 if (save_starting >= 0)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
971 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
972 starting = save_starting;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
973 save_starting = -1;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
974 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
976 else
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
977 semsg(_(e_invarg2), name);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
978 }
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 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
982 * "test_refcount({expr})" function
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
984 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 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
986 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
987 int retval = -1;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
988
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
989 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
990 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
991 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
992 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
993 case VAR_VOID:
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
994 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
995 case VAR_BOOL:
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
996 case VAR_FLOAT:
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
997 case VAR_SPECIAL:
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
998 case VAR_STRING:
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
999 break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1000 case VAR_JOB:
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1001 #ifdef FEAT_JOB_CHANNEL
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1002 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
1003 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
1004 #endif
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1005 break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1006 case VAR_CHANNEL:
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1007 #ifdef FEAT_JOB_CHANNEL
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1008 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
1009 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
1010 #endif
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1011 break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1012 case VAR_FUNC:
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1013 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
1014 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1015 ufunc_T *fp;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1016
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 19922
diff changeset
1017 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
1018 if (fp != NULL)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1019 retval = fp->uf_refcount;
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 break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1022 case VAR_PARTIAL:
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023 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
1024 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
1025 break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1026 case VAR_BLOB:
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1027 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
1028 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
1029 break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1030 case VAR_LIST:
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1031 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
1032 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
1033 break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1034 case VAR_DICT:
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1035 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
1036 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
1037 break;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1038 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1039
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1040 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
1041 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
1042
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1043 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1044
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1045 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1046 * "test_garbagecollect_now()" function
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 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1049 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
1050 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
1051 // 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
1052 // 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
1053 garbage_collect(TRUE);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1055
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 * "test_garbagecollect_soon()" function
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1058 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1059 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1060 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
1061 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1062 may_garbage_collect = TRUE;
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
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1065 /*
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1066 * "test_ignore_error()" function
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1067 */
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1068 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1069 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
1070 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1071 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
1072 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1073
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1074 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1075 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
1076 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1077 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
1078 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
1079 }
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 #ifdef FEAT_JOB_CHANNEL
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1082 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1083 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
1084 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1085 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
1086 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
1087 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088 #endif
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_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
1092 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1093 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
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 #ifdef FEAT_JOB_CHANNEL
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1097 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1098 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
1099 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1100 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
1101 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
1102 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1103 #endif
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1104
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1105 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1106 f_test_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
1107 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1108 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
1109 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1110
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1111 void
19874
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
1112 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
1113 {
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
1114 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
1115 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
1116 }
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
1117
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
1118 void
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1119 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
1120 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1121 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
1122 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
1123 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1124
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1125 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1126 f_test_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
1127 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1128 rettv->v_type = VAR_STRING;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1129 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
1130 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1131
19483
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19384
diff changeset
1132 void
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19384
diff changeset
1133 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
1134 {
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19384
diff changeset
1135 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
1136 }
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19384
diff changeset
1137
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19384
diff changeset
1138 void
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19384
diff changeset
1139 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
1140 {
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19384
diff changeset
1141 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
1142 }
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19384
diff changeset
1143
17377
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1144 #ifdef FEAT_GUI
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1145 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1146 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
1147 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1148 char_u *which;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1149 long value;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1150 int dragging;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1151 scrollbar_T *sb = NULL;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1152
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1153 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
1154 || (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
1155 || (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
1156 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1157 emsg(_(e_invarg));
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1158 return;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1159 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1160 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
1161 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
1162 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
1163
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1164 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
1165 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
1166 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
1167 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
1168 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
1169 sb = &gui.bottom_sbar;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1170 if (sb == NULL)
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1171 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1172 semsg(_(e_invarg2), which);
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1173 return;
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1174 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1175 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
1176 # 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
1177 // 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
1178 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
1179 # endif
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1180 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1181 #endif
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1182
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1183 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1184 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
1185 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1186 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
1187 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
1188 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1189
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1190 void
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1191 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
1192 {
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1193 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
1194 }
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1196
cb008de2a6ec patch 8.1.1687: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1197 #endif // defined(FEAT_EVAL)