Mercurial > vim
annotate src/testdir/test_exit.vim @ 21646:a640bc762196 v8.2.1373
patch 8.2.1373: Vim9: no error for assigning to non-existing script var
Commit: https://github.com/vim/vim/commit/f9b2b49663226235f94f08230fe9023caf80a6e9
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 5 14:34:14 2020 +0200
patch 8.2.1373: Vim9: no error for assigning to non-existing script var
Problem: Vim9: no error for assigning to non-existing script var.
Solution: Check that in Vim9 script the variable was defined. (closes https://github.com/vim/vim/issues/6630)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 05 Aug 2020 14:45:03 +0200 |
parents | fa6efc49d71f |
children | 08940efa6b4e |
rev | line source |
---|---|
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for exiting Vim. |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 source shared.vim |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 func Test_exiting() |
16720
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
6 let after =<< trim [CODE] |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
7 au QuitPre * call writefile(["QuitPre"], "Xtestout") |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
8 au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
9 quit |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
10 [CODE] |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
11 |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 if RunVim([], after, '') |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout')) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 endif |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 call delete('Xtestout') |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 |
16720
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
17 let after =<< trim [CODE] |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
18 au QuitPre * call writefile(["QuitPre"], "Xtestout") |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
19 au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
20 help |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
21 wincmd w |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
22 quit |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
23 [CODE] |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
24 |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 if RunVim([], after, '') |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout')) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 endif |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 call delete('Xtestout') |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 |
16720
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
30 let after =<< trim [CODE] |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
31 au QuitPre * call writefile(["QuitPre"], "Xtestout") |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
32 au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
33 split |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
34 new |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
35 qall |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
36 [CODE] |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
37 |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 if RunVim([], after, '') |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout')) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 endif |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 call delete('Xtestout') |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 |
18406
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
43 " ExitPre autocommand splits the window, so that it's no longer the last one. |
16720
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
44 let after =<< trim [CODE] |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
45 au QuitPre * call writefile(["QuitPre"], "Xtestout", "a") |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
46 au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
47 augroup nasty |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
48 au ExitPre * split |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
49 augroup END |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
50 quit |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
51 augroup nasty |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
52 au! ExitPre |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
53 augroup END |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
54 quit |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
55 [CODE] |
9c90cf08cfa8
patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents:
13442
diff
changeset
|
56 |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 if RunVim([], after, '') |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'], |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 \ readfile('Xtestout')) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 endif |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 call delete('Xtestout') |
18406
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
62 |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
63 " ExitPre autocommand splits and closes the window, so that there is still |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
64 " one window but it's a different one. |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
65 let after =<< trim [CODE] |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
66 au QuitPre * call writefile(["QuitPre"], "Xtestout", "a") |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
67 au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
68 augroup nasty |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
69 au ExitPre * split | only |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
70 augroup END |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
71 quit |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
72 augroup nasty |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
73 au! ExitPre |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
74 augroup END |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
75 quit |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
76 [CODE] |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
77 |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
78 if RunVim([], after, '') |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
79 call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'], |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
80 \ readfile('Xtestout')) |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
81 endif |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
16720
diff
changeset
|
82 call delete('Xtestout') |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 endfunc |