diff options
Diffstat (limited to 'test/functional/ui/mode_spec.lua')
-rw-r--r-- | test/functional/ui/mode_spec.lua | 257 |
1 files changed, 152 insertions, 105 deletions
diff --git a/test/functional/ui/mode_spec.lua b/test/functional/ui/mode_spec.lua index e870d6f25f..8d7fae3e91 100644 --- a/test/functional/ui/mode_spec.lua +++ b/test/functional/ui/mode_spec.lua @@ -11,39 +11,45 @@ describe('ui mode_change event', function() before_each(function() clear() screen = Screen.new(25, 4) - screen:attach({rgb= true}) - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=255}, - [1] = {bold=true, reverse=true}, - [2] = {bold=true}, - [3] = {reverse=true}, - [4] = {background=Screen.colors.Red, foreground=Screen.colors.White}, -- ErrorMsg + screen:attach({ rgb = true }) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = 255 }, + [1] = { bold = true, reverse = true }, + [2] = { bold = true }, + [3] = { reverse = true }, + [4] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- ErrorMsg }) end) it('works in normal mode', function() - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="operator"} + ]], + mode = 'operator', + } feed('<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } end) -- oldtest: Test_mouse_shape_after_failed_change() @@ -52,185 +58,226 @@ describe('ui mode_change event', function() command('set nomodifiable') feed('c') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="operator"} + ]], + mode = 'operator', + } feed('c') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {4:E21: Cannot make changes, 'modifiable' is off} | - ]], mode="normal"} + ]], + mode = 'normal', + } end) -- oldtest: Test_mouse_shape_after_cancelling_gr() it('is restored to Normal mode after cancelling "gr"', function() feed('gr') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="replace"} + ]], + mode = 'replace', + } feed('<Esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } end) it('works in insert mode', function() feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- INSERT --} | - ]], mode="insert"} + ]], + mode = 'insert', + } feed('word<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ wor^d | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } local matchtime = 0 - command("set showmatch") + command('set showmatch') retry(nil, nil, function() matchtime = matchtime + 1 - local screen_timeout = 1000 * matchtime -- fail faster for retry. + local screen_timeout = 1000 * matchtime -- fail faster for retry. - command("set matchtime=" .. matchtime) -- tenths of seconds + command('set matchtime=' .. matchtime) -- tenths of seconds feed('a(stuff') - screen:expect{grid=[[ + screen:expect { + grid = [[ word(stuff^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- INSERT --} | - ]], mode="insert", timeout=screen_timeout} + ]], + mode = 'insert', + timeout = screen_timeout, + } feed(')') - screen:expect{grid=[[ + screen:expect { + grid = [[ word^(stuff) | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- INSERT --} | - ]], mode="showmatch", timeout=screen_timeout} + ]], + mode = 'showmatch', + timeout = screen_timeout, + } - screen:expect{grid=[[ + screen:expect { + grid = [[ word(stuff)^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- INSERT --} | - ]], mode="insert", timeout=screen_timeout} + ]], + mode = 'insert', + timeout = screen_timeout, + } end) end) it('works in replace mode', function() feed('R') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- REPLACE --} | - ]], mode="replace"} + ]], + mode = 'replace', + } feed('word<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ wor^d | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } end) it('works in cmdline mode', function() feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 :^ | - ]], mode="cmdline_normal"} + ]], + mode = 'cmdline_normal', + } feed('x<left>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 :^x | - ]], mode="cmdline_insert"} + ]], + mode = 'cmdline_insert', + } feed('<insert>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 :^x | - ]], mode="cmdline_replace"} - + ]], + mode = 'cmdline_replace', + } feed('<right>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 :x^ | - ]], mode="cmdline_normal"} + ]], + mode = 'cmdline_normal', + } feed('<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } end) it('works in visual mode', function() - insert("text") + insert('text') feed('v') - screen:expect{grid=[[ + screen:expect { + grid = [[ tex^t | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- VISUAL --} | - ]], mode="visual"} + ]], + mode = 'visual', + } feed('<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ tex^t | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } command('set selection=exclusive') feed('v') - screen:expect{grid=[[ + screen:expect { + grid = [[ tex^t | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- VISUAL --} | - ]], mode="visual_select"} + ]], + mode = 'visual_select', + } feed('<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ tex^t | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } end) end) - |