annotate src/testing.c @ 24606:a4fda40e0bb9 v8.2.2842

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