Mercurial > vim
annotate src/testdir/test_suspend.vim @ 15000:32787e326de2 v8.1.0511
patch 8.1.0511: ml_get error when calling a function with a range
commit https://github.com/vim/vim/commit/9e353b5265bd7fa103caf4e5a9b3c99f344f548e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Nov 4 23:39:38 2018 +0100
patch 8.1.0511: ml_get error when calling a function with a range
Problem: ml_get error when calling a function with a range.
Solution: Don't position the cursor after the last line.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 04 Nov 2018 23:45:07 +0100 |
parents | 4234c348aa90 |
children | 47328ce4b7aa |
rev | line source |
---|---|
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test :suspend |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 source shared.vim |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 func Test_suspend() |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 if !has('terminal') || !executable('/bin/sh') |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 return |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 endif |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 let buf = term_start('/bin/sh') |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 " Wait for shell prompt. |
14993
4234c348aa90
patch 8.1.0508: suspend test fails when run by root
Bram Moolenaar <Bram@vim.org>
parents:
14832
diff
changeset
|
12 call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))}) |
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call term_sendkeys(buf, v:progpath |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 \ . " --clean -X" |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 \ . " -c 'set nu'" |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 \ . " -c 'call setline(1, \"foo\")'" |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 \ . " Xfoo\<CR>") |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 " Cursor in terminal buffer should be on first line in spawned vim. |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 call WaitForAssert({-> assert_equal(' 1 foo', term_getline(buf, '.'))}) |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 for suspend_cmd in [":suspend\<CR>", |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 \ ":stop\<CR>", |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 \ ":suspend!\<CR>", |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 \ ":stop!\<CR>", |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 \ "\<C-Z>"] |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 " Suspend and wait for shell prompt. |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 call term_sendkeys(buf, suspend_cmd) |
14993
4234c348aa90
patch 8.1.0508: suspend test fails when run by root
Bram Moolenaar <Bram@vim.org>
parents:
14832
diff
changeset
|
29 call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))}) |
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 " Without 'autowrite', buffer should not be written. |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 call assert_equal(0, filereadable('Xfoo')) |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 call term_sendkeys(buf, "fg\<CR>") |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 call WaitForAssert({-> assert_equal(' 1 foo', term_getline(buf, '.'))}) |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 endfor |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 " Test that :suspend! with 'autowrite' writes content of buffers if modified. |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 call term_sendkeys(buf, ":set autowrite\<CR>") |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 call assert_equal(0, filereadable('Xfoo')) |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 call term_sendkeys(buf, ":suspend\<CR>") |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 " Wait for shell prompt. |
14993
4234c348aa90
patch 8.1.0508: suspend test fails when run by root
Bram Moolenaar <Bram@vim.org>
parents:
14832
diff
changeset
|
43 call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))}) |
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 call assert_equal(['foo'], readfile('Xfoo')) |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 call term_sendkeys(buf, "fg\<CR>") |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 call WaitForAssert({-> assert_equal(' 1 foo', term_getline(buf, '.'))}) |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 exe buf . 'bwipe!' |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 call delete('Xfoo') |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 set autowrite& |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 endfunc |