diff options
author | Jacques Germishuys <jacquesg@striata.com> | 2020-08-29 22:12:10 +0100 |
---|---|---|
committer | Jacques Germishuys <jacquesg@striata.com> | 2020-08-30 17:19:05 +0100 |
commit | 9bef25314e47c6c624c129ab8e7c0c21ec68b2cf (patch) | |
tree | 20040c474d57b473795dc4c7e58ae5366711f7d6 /test/functional/provider/perl_spec.lua | |
parent | c6648fe8820003a92e034e7717a86c1e0616ffb0 (diff) | |
download | rneovim-9bef25314e47c6c624c129ab8e7c0c21ec68b2cf.tar.gz rneovim-9bef25314e47c6c624c129ab8e7c0c21ec68b2cf.tar.bz2 rneovim-9bef25314e47c6c624c129ab8e7c0c21ec68b2cf.zip |
support for :perl, :perlfile, :perldo and perleval()
Diffstat (limited to 'test/functional/provider/perl_spec.lua')
-rw-r--r-- | test/functional/provider/perl_spec.lua | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/test/functional/provider/perl_spec.lua b/test/functional/provider/perl_spec.lua index 7b446e4ab3..125674660b 100644 --- a/test/functional/provider/perl_spec.lua +++ b/test/functional/provider/perl_spec.lua @@ -5,6 +5,10 @@ local command = helpers.command local write_file = helpers.write_file local eval = helpers.eval local retry = helpers.retry +local curbufmeths = helpers.curbufmeths +local insert = helpers.insert +local expect = helpers.expect +local feed = helpers.feed do clear() @@ -19,7 +23,51 @@ before_each(function() clear() end) -describe('perl host', function() +describe('legacy perl provider', function() + if helpers.pending_win32(pending) then return end + + it('feature test', function() + eq(1, eval('has("perl")')) + end) + + it(':perl command', function() + command('perl $vim->vars->{set_by_perl} = [100, 0];') + eq({100, 0}, eval('g:set_by_perl')) + end) + + it(':perlfile command', function() + local fname = 'perlfile.pl' + write_file(fname, '$vim->command("let set_by_perlfile = 123")') + command('perlfile perlfile.pl') + eq(123, eval('g:set_by_perlfile')) + os.remove(fname) + end) + + it(':perldo command', function() + -- :perldo 1; doesn't change $_, + -- the buffer should not be changed + command('normal :perldo 1;') + eq(false, curbufmeths.get_option('modified')) + -- insert some text + insert('abc\ndef\nghi') + expect([[ + abc + def + ghi]]) + -- go to top and select and replace the first two lines + feed('ggvj:perldo $_ = reverse ($_)."$linenr"<CR>') + expect([[ + cba1 + fed2 + ghi]]) + end) + + it('perleval()', function() + eq({1, 2, {['key'] = 'val'}}, eval([[perleval('[1, 2, {"key" => "val"}]')]])) + end) +end) + +describe('perl provider', function() if helpers.pending_win32(pending) then return end teardown(function () os.remove('Xtest-perl-hello.pl') |