diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2020-09-05 13:55:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-05 13:55:06 -0700 |
commit | 858c056133ed50af8dc31fdeee1638cb69ea2c69 (patch) | |
tree | 14bdb76032804152df438f5ffb4a5d77d369c8e0 /test/functional/provider/perl_spec.lua | |
parent | 8b5c6a1b73206185e2451a92a5f8ca0036ca2212 (diff) | |
parent | 8705fbf77c067a907caf1920a0852fdb8619c649 (diff) | |
download | rneovim-858c056133ed50af8dc31fdeee1638cb69ea2c69.tar.gz rneovim-858c056133ed50af8dc31fdeee1638cb69ea2c69.tar.bz2 rneovim-858c056133ed50af8dc31fdeee1638cb69ea2c69.zip |
Support for :perl, :perlfile, :perldo and perleval() (#12809)
* support for :perl, :perlfile, :perldo and perleval()
* document that the perl provider doesn't currently work on Windows
* document that the perl legacy interface is now also supported
* added perleval() documentation
* import legacy perl interface tests
* only perl 5.22+ is supported
* healtcheck: use g:perl_host_prog if its set instead
using just 'perl' isn't correct as it may not be the version requested.
ditto for 'cpanm', rather go through 'App::cpanminus' to find the latest
perl version
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') |