From 55806fbe39fa9fff3ce664dff4c46fc9c6f566fd Mon Sep 17 00:00:00 2001 From: Lucas Hoffmann Date: Thu, 11 Jun 2015 01:28:27 +0200 Subject: tests: Migrate legacy test argument_count. --- test/functional/legacy/argument_count_spec.lua | 64 ++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 test/functional/legacy/argument_count_spec.lua (limited to 'test') diff --git a/test/functional/legacy/argument_count_spec.lua b/test/functional/legacy/argument_count_spec.lua new file mode 100644 index 0000000000..ece875d235 --- /dev/null +++ b/test/functional/legacy/argument_count_spec.lua @@ -0,0 +1,64 @@ +-- Tests for :[count]argument! and :[count]argdelete + +local helpers = require('test.functional.helpers') +local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect + +describe('argument_count', function() + setup(clear) + + it('is working', function() + execute('%argd') + execute('argadd a b c d') + execute('set hidden') + execute('let buffers = []') + execute('augroup TEST') + execute([[au BufEnter * call add(buffers, expand('%:t'))]]) + execute('augroup END') + execute('$argu') + execute('$-argu') + execute('-argu') + execute('1argu') + execute('+2argu') + execute('augroup TEST') + execute('au!') + execute('augroup END') + execute('let arglists = []') + execute('.argd') + execute('call add(arglists, argv())') + execute('-argd') + execute('call add(arglists, argv())') + execute('$argd') + execute('call add(arglists, argv())') + execute('1arga c') + execute('1arga b') + execute('$argu') + execute('$arga x') + execute('call add(arglists, argv())') + execute('0arga Y') + execute('call add(arglists, argv())') + execute('%argd') + execute('call add(arglists, argv())') + execute('arga a b c d e f') + execute('2,$-argd') + execute('call add(arglists, argv())') + execute('call append(0, buffers)') + execute([[let lnr = line('$')]]) + execute([[call append(lnr, map(copy(arglists), 'join(v:val, " ")'))]]) + -- Assert buffer contents. + expect([=[ + d + c + b + a + c + + a b d + a d + a + a b c x + Y a b c x + + a f]=]) + end) +end) -- cgit From c2065a183fe3b68a03401306591114f3046281db Mon Sep 17 00:00:00 2001 From: Lucas Hoffmann Date: Thu, 11 Jun 2015 01:45:01 +0200 Subject: tests: Modernize migrated argument_count test. --- test/functional/legacy/argument_count_spec.lua | 39 ++++++++------------------ 1 file changed, 11 insertions(+), 28 deletions(-) (limited to 'test') diff --git a/test/functional/legacy/argument_count_spec.lua b/test/functional/legacy/argument_count_spec.lua index ece875d235..182cce9475 100644 --- a/test/functional/legacy/argument_count_spec.lua +++ b/test/functional/legacy/argument_count_spec.lua @@ -1,8 +1,8 @@ -- Tests for :[count]argument! and :[count]argdelete local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, execute, eq, eval = + helpers.clear, helpers.execute, helpers.eq, helpers.eval describe('argument_count', function() setup(clear) @@ -10,6 +10,7 @@ describe('argument_count', function() it('is working', function() execute('%argd') execute('argadd a b c d') + eq({'a', 'b', 'c', 'd'}, eval('argv()')) execute('set hidden') execute('let buffers = []') execute('augroup TEST') @@ -23,42 +24,24 @@ describe('argument_count', function() execute('augroup TEST') execute('au!') execute('augroup END') - execute('let arglists = []') + eq({'d', 'c', 'b', 'a', 'c'}, eval('buffers')) execute('.argd') - execute('call add(arglists, argv())') + eq({'a', 'b', 'd'}, eval('argv()')) execute('-argd') - execute('call add(arglists, argv())') + eq({'a', 'd'}, eval('argv()')) execute('$argd') - execute('call add(arglists, argv())') + eq({'a'}, eval('argv()')) execute('1arga c') execute('1arga b') execute('$argu') execute('$arga x') - execute('call add(arglists, argv())') + eq({'a', 'b', 'c', 'x'}, eval('argv()')) execute('0arga Y') - execute('call add(arglists, argv())') + eq({'Y', 'a', 'b', 'c', 'x'}, eval('argv()')) execute('%argd') - execute('call add(arglists, argv())') + eq({}, eval('argv()')) execute('arga a b c d e f') execute('2,$-argd') - execute('call add(arglists, argv())') - execute('call append(0, buffers)') - execute([[let lnr = line('$')]]) - execute([[call append(lnr, map(copy(arglists), 'join(v:val, " ")'))]]) - -- Assert buffer contents. - expect([=[ - d - c - b - a - c - - a b d - a d - a - a b c x - Y a b c x - - a f]=]) + eq({'a', 'f'}, eval('argv()')) end) end) -- cgit