aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/045_folding_spec.lua
diff options
context:
space:
mode:
authorLucas Hoffmann <l-m-h@web.de>2015-05-15 19:03:46 +0200
committerwatiko <service@mail.watiko.net>2016-02-05 13:55:27 +0900
commit86c5696c274577ceec1dfabe6e92cf480250f865 (patch)
tree08a5d21938bc92721529162e6266e1ebbf842170 /test/functional/legacy/045_folding_spec.lua
parent69e448d1d871c648bd1fc0c6067803bdc06c3e5b (diff)
downloadrneovim-86c5696c274577ceec1dfabe6e92cf480250f865.tar.gz
rneovim-86c5696c274577ceec1dfabe6e92cf480250f865.tar.bz2
rneovim-86c5696c274577ceec1dfabe6e92cf480250f865.zip
tests: Migrate legacy test 45.
Diffstat (limited to 'test/functional/legacy/045_folding_spec.lua')
-rw-r--r--test/functional/legacy/045_folding_spec.lua117
1 files changed, 117 insertions, 0 deletions
diff --git a/test/functional/legacy/045_folding_spec.lua b/test/functional/legacy/045_folding_spec.lua
new file mode 100644
index 0000000000..79299a253c
--- /dev/null
+++ b/test/functional/legacy/045_folding_spec.lua
@@ -0,0 +1,117 @@
+-- Tests for folding.
+
+local helpers = require('test.functional.helpers')
+local feed, insert, clear, execute, expect =
+ helpers.feed, helpers.insert, helpers.clear, helpers.execute, helpers.expect
+
+describe('folding', function()
+ setup(clear)
+
+ it('is working', function()
+ insert([[
+ 1 aa
+ 2 bb
+ 3 cc
+ 4 dd {{{
+ 5 ee {{{ }}}
+ 6 ff }}}
+ 7 gg
+ 8 hh
+ 9 ii
+ a jj
+ b kk
+ last]])
+
+ -- Basic test if a fold can be created, opened, moving to the end and
+ -- closed.
+ execute('/^1')
+ feed('zf2j')
+ execute('call append("$", "manual " . getline(foldclosed(".")))')
+ feed('zo')
+ execute('call append("$", foldclosed("."))')
+ feed(']z')
+ execute('call append("$", getline("."))')
+ feed('zc')
+ execute('call append("$", getline(foldclosed(".")))')
+ -- Test folding with markers.
+ execute('set fdm=marker fdl=1 fdc=3')
+ execute('/^5')
+ execute('call append("$", "marker " . foldlevel("."))')
+ feed('[z')
+ execute('call append("$", foldlevel("."))')
+ feed('jo{{ <esc>r{jj')
+ execute('call append("$", foldlevel("."))')
+ feed('kYpj')
+ execute('call append("$", foldlevel("."))')
+ -- Test folding with indent.
+ execute('set fdm=indent sw=2')
+ execute('/^2 b')
+ feed('i <esc>jI <esc>')
+ execute('call append("$", "indent " . foldlevel("."))')
+ feed('k')
+ execute('call append("$", foldlevel("."))')
+ -- Test syntax folding.
+ execute('set fdm=syntax fdl=0')
+ execute('syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3')
+ execute('syn region Fd1 start="ee" end="ff" fold contained')
+ execute('syn region Fd2 start="gg" end="hh" fold contained')
+ execute('syn region Fd3 start="commentstart" end="commentend" fold contained')
+ feed('Gzk')
+ execute('call append("$", "folding " . getline("."))')
+ feed('k')
+ execute('call append("$", getline("."))')
+ feed('jAcommentstart <esc>Acommentend<esc>')
+ execute('set fdl=1')
+ feed('3j')
+ execute('call append("$", getline("."))')
+ execute('set fdl=0')
+ feed('zO<C-L>j')
+ execute('call append("$", getline("."))')
+ -- Test expression folding.
+ execute('fun Flvl()')
+ execute(' let l = getline(v:lnum)')
+ execute(' if l =~ "bb$"')
+ execute(' return 2')
+ execute(' elseif l =~ "gg$"')
+ execute(' return "s1"')
+ execute(' elseif l =~ "ii$"')
+ execute(' return ">2"')
+ execute(' elseif l =~ "kk$"')
+ execute(' return "0"')
+ execute(' endif')
+ execute(' return "="')
+ execute('endfun')
+ execute('set fdm=expr fde=Flvl()')
+ execute('/bb$')
+ execute('call append("$", "expr " . foldlevel("."))')
+ execute('/hh$')
+ execute('call append("$", foldlevel("."))')
+ execute('/ii$')
+ execute('call append("$", foldlevel("."))')
+ execute('/kk$')
+ execute('call append("$", foldlevel("."))')
+ execute('0,/^last/delete')
+ execute('delfun Flvl')
+
+ -- Assert buffer contents.
+ expect([[
+ manual 1 aa
+ -1
+ 3 cc
+ 1 aa
+ marker 2
+ 1
+ 1
+ 0
+ indent 2
+ 1
+ folding 9 ii
+ 3 cc
+ 7 gg
+ 8 hh
+ expr 2
+ 1
+ 2
+ 0]])
+ end)
+end)