aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2015-06-28 05:18:51 +0300
committerZyX <kp-pav@yandex.ru>2015-10-08 21:59:53 +0300
commitbc5252261684001d39f2d3a491f8e9295d1f76ed (patch)
tree3850a41d594d220864c156ce5f32ee42b65ddf0c
parent0fe9679101037daa6f74deaa52900c077be9ab17 (diff)
downloadrneovim-bc5252261684001d39f2d3a491f8e9295d1f76ed.tar.gz
rneovim-bc5252261684001d39f2d3a491f8e9295d1f76ed.tar.bz2
rneovim-bc5252261684001d39f2d3a491f8e9295d1f76ed.zip
functests: Add history tests
-rw-r--r--test/functional/shada/history_spec.lua105
1 files changed, 105 insertions, 0 deletions
diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua
new file mode 100644
index 0000000000..b73a39f116
--- /dev/null
+++ b/test/functional/shada/history_spec.lua
@@ -0,0 +1,105 @@
+-- ShaDa history saving/reading support
+local helpers = require('test.functional.helpers')
+local nvim, nvim_command, nvim_eval, nvim_feed, eq =
+ helpers.nvim, helpers.command, helpers.eval, helpers.feed, helpers.eq
+
+local shada_helpers = require('test.functional.shada.helpers')
+local reset, set_additional_cmd, clear =
+ shada_helpers.reset, shada_helpers.set_additional_cmd,
+ shada_helpers.clear
+
+describe('ShaDa support code', function()
+ before_each(reset)
+ after_each(clear)
+
+ it('is able to dump and read back command-line history', function()
+ nvim_command('set viminfo=\'0')
+ nvim_feed(':" Test\n')
+ nvim_command('wviminfo')
+ reset()
+ nvim_command('set viminfo=\'0')
+ nvim_command('rviminfo')
+ eq('" Test', nvim_eval('histget(":", -1)'))
+ end)
+
+ it('is able to dump and read back 2 items in command-line history', function()
+ nvim_command('set viminfo=\'0 history=2')
+ nvim_feed(':" Test\n')
+ nvim_feed(':" Test 2\n')
+ nvim_command('qall')
+ reset()
+ nvim_command('set viminfo=\'0 history=2')
+ nvim_command('rviminfo')
+ eq('" Test 2', nvim_eval('histget(":", -1)'))
+ eq('" Test', nvim_eval('histget(":", -2)'))
+ nvim_command('qall')
+ end)
+
+ it('respects &history when dumping',
+ function()
+ nvim_command('set viminfo=\'0 history=1')
+ nvim_feed(':" Test\n')
+ nvim_feed(':" Test 2\n')
+ nvim_command('wviminfo')
+ reset()
+ nvim_command('set viminfo=\'0 history=2')
+ nvim_command('rviminfo')
+ eq('" Test 2', nvim_eval('histget(":", -1)'))
+ eq('', nvim_eval('histget(":", -2)'))
+ end)
+
+ it('respects &history when loading',
+ function()
+ nvim_command('set viminfo=\'0 history=2')
+ nvim_feed(':" Test\n')
+ nvim_feed(':" Test 2\n')
+ nvim_command('wviminfo')
+ reset()
+ nvim_command('set viminfo=\'0 history=1')
+ nvim_command('rviminfo')
+ eq('" Test 2', nvim_eval('histget(":", -1)'))
+ eq('', nvim_eval('histget(":", -2)'))
+ end)
+
+ it('dumps only requested amount of command-line history items', function()
+ nvim_command('set viminfo=\'0,:1')
+ nvim_feed(':" Test\n')
+ nvim_feed(':" Test 2\n')
+ nvim_command('wviminfo')
+ reset()
+ nvim_command('set viminfo=\'0')
+ nvim_command('rviminfo')
+ eq('" Test 2', nvim_eval('histget(":", -1)'))
+ eq('', nvim_eval('histget(":", -2)'))
+ end)
+
+ it('does not respect number in &viminfo when loading history', function()
+ nvim_command('set viminfo=\'0')
+ nvim_feed(':" Test\n')
+ nvim_feed(':" Test 2\n')
+ nvim_command('wviminfo')
+ reset()
+ nvim_command('set viminfo=\'0,:1')
+ nvim_command('rviminfo')
+ eq('" Test 2', nvim_eval('histget(":", -1)'))
+ eq('" Test', nvim_eval('histget(":", -2)'))
+ end)
+
+ it('dumps and loads all kinds of histories', function()
+ nvim_command('debuggreedy')
+ nvim_feed(':debug echo "Test"\n" Test 2\nc\n') -- Debug history.
+ nvim_feed(':call input("")\nTest 2\n') -- Input history.
+ nvim_feed('"="Test"\nyy') -- Expression history.
+ nvim_feed('/Test\n') -- Search history
+ nvim_feed(':" Test\n') -- Command-line history
+ nvim_command('0debuggreedy')
+ nvim_command('wviminfo')
+ reset()
+ nvim_command('rviminfo')
+ eq('" Test', nvim_eval('histget(":", -1)'))
+ eq('Test', nvim_eval('histget("/", -1)'))
+ eq('"Test"', nvim_eval('histget("=", -1)'))
+ eq('Test 2', nvim_eval('histget("@", -1)'))
+ eq('c', nvim_eval('histget(">", -1)'))
+ end)
+end)