Mercurial > vim
comparison src/testdir/test_suspend.vim @ 16336:b1e69c9e4c67 v8.1.1173
patch 8.1.1173: suspend test has duplicated lines
commit https://github.com/vim/vim/commit/a8356bc1734195d130c6eeaf4858356ae3a3f722
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 14 14:31:11 2019 +0200
patch 8.1.1173: suspend test has duplicated lines
Problem: Suspend test has duplicated lines.
Solution: Use a function.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 14 Apr 2019 14:45:04 +0200 |
parents | 47328ce4b7aa |
children | 7927cf327396 |
comparison
equal
deleted
inserted
replaced
16335:759cb1a49570 | 16336:b1e69c9e4c67 |
---|---|
1 " Test :suspend | 1 " Test :suspend |
2 | 2 |
3 source shared.vim | 3 source shared.vim |
4 | |
5 func CheckSuspended(buf, fileExists) | |
6 call WaitForAssert({-> assert_match('[$#] $', term_getline(a:buf, '.'))}) | |
7 | |
8 if a:fileExists | |
9 call assert_equal(['foo'], readfile('Xfoo')) | |
10 else | |
11 " Without 'autowrite', buffer should not be written. | |
12 call assert_equal(0, filereadable('Xfoo')) | |
13 endif | |
14 | |
15 call term_sendkeys(a:buf, "fg\<CR>\<C-L>") | |
16 call WaitForAssert({-> assert_equal(' 1 foo', term_getline(a:buf, '.'))}) | |
17 endfunc | |
4 | 18 |
5 func Test_suspend() | 19 func Test_suspend() |
6 if !has('terminal') || !executable('/bin/sh') | 20 if !has('terminal') || !executable('/bin/sh') |
7 return | 21 return |
8 endif | 22 endif |
24 \ ":suspend!\<CR>", | 38 \ ":suspend!\<CR>", |
25 \ ":stop!\<CR>", | 39 \ ":stop!\<CR>", |
26 \ "\<C-Z>"] | 40 \ "\<C-Z>"] |
27 " Suspend and wait for shell prompt. | 41 " Suspend and wait for shell prompt. |
28 call term_sendkeys(buf, suspend_cmd) | 42 call term_sendkeys(buf, suspend_cmd) |
29 call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))}) | 43 call CheckSuspended(buf, 0) |
30 | |
31 " Without 'autowrite', buffer should not be written. | |
32 call assert_equal(0, filereadable('Xfoo')) | |
33 | |
34 call term_sendkeys(buf, "fg\<CR>") | |
35 call WaitForAssert({-> assert_equal(' 1 foo', term_getline(buf, '.'))}) | |
36 endfor | 44 endfor |
37 | 45 |
38 " Test that :suspend! with 'autowrite' writes content of buffers if modified. | 46 " Test that :suspend! with 'autowrite' writes content of buffers if modified. |
39 call term_sendkeys(buf, ":set autowrite\<CR>") | 47 call term_sendkeys(buf, ":set autowrite\<CR>") |
40 call assert_equal(0, filereadable('Xfoo')) | 48 call assert_equal(0, filereadable('Xfoo')) |
41 call term_sendkeys(buf, ":suspend\<CR>") | 49 call term_sendkeys(buf, ":suspend\<CR>") |
42 " Wait for shell prompt. | 50 " Wait for shell prompt. |
43 call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))}) | 51 call CheckSuspended(buf, 1) |
44 call assert_equal(['foo'], readfile('Xfoo')) | |
45 call term_sendkeys(buf, "fg\<CR>") | |
46 call WaitForAssert({-> assert_equal(' 1 foo', term_getline(buf, '.'))}) | |
47 | 52 |
48 " Quit gracefully to dump coverage information. | 53 " Quit gracefully to dump coverage information. |
49 call term_sendkeys(buf, ":qall!\<CR>") | 54 call term_sendkeys(buf, ":qall!\<CR>") |
50 call term_wait(buf) | 55 call term_wait(buf) |
51 call Stop_shell_in_terminal(buf) | 56 call Stop_shell_in_terminal(buf) |