Mercurial > vim
view src/testdir/test_perl.vim @ 8806:8fff73f17ff1 v7.4.1691
commit https://github.com/vim/vim/commit/b681be175b6991cdc2b8ddd49b0e97e3fe2b201e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Mar 31 23:02:16 2016 +0200
patch 7.4.1691
Problem: When switching to a new buffer and an autocommand applies syntax
highlighting an ml_get error may occur.
Solution: Check "syn_buf" against the buffer in the window. (Alexander von
Buddenbrock, closes #676)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 31 Mar 2016 23:15:05 +0200 |
parents | 94f34dc2f254 |
children | 54a380c74547 |
line wrap: on
line source
" Tests for Perl interface if !has('perl') finish end func Test_change_buffer() call setline(line('$'), ['1 line 1']) perl VIM::DoCommand("normal /^1\n") perl $curline = VIM::Eval("line('.')") perl $curbuf->Set($curline, "1 changed line 1") call assert_equal('1 changed line 1', getline('$')) endfunc func Test_evaluate_list() call setline(line('$'), ['2 line 2']) perl VIM::DoCommand("normal /^2\n") perl $curline = VIM::Eval("line('.')") let l = ["abc", "def"] perl << EOF $l = VIM::Eval("l"); $curbuf->Append($curline, $l); EOF normal j .perldo s|\n|/|g call assert_equal('abc/def/', getline('$')) endfunc fu <SID>catch_peval(expr) try call perleval(a:expr) catch return v:exception endtry call assert_true(0, 'no exception for `perleval("'.a:expr.'")`') return '' endf function Test_perleval() call assert_false(perleval('undef')) " scalar call assert_equal(0, perleval('0')) call assert_equal(2, perleval('2')) call assert_equal(-2, perleval('-2')) if has('float') call assert_equal(2.5, perleval('2.5')) else call assert_equal(2, perleval('2.5')) end sandbox call assert_equal(2, perleval('2')) call assert_equal('abc', perleval('"abc"')) call assert_equal("abc\ndef", perleval('"abc\0def"')) " ref call assert_equal([], perleval('[]')) call assert_equal(['word', 42, [42],{}], perleval('["word", 42, [42], {}]')) call assert_equal({}, perleval('{}')) call assert_equal({'foo': 'bar'}, perleval('{foo => "bar"}')) perl our %h; our @a; let a = perleval('[\(%h, %h, @a, @a)]') call assert_true((a[0] is a[1])) call assert_true((a[2] is a[3])) perl undef %h; undef @a; call assert_true(<SID>catch_peval('{"" , 0}') =~ 'Malformed key Dictionary') call assert_true(<SID>catch_peval('{"\0" , 0}') =~ 'Malformed key Dictionary') call assert_true(<SID>catch_peval('{"foo\0bar" , 0}') =~ 'Malformed key Dictionary') call assert_equal('*VIM', perleval('"*VIM"')) call assert_true(perleval('\\0') =~ 'SCALAR(0x\x\+)') endf function Test_perldo() sp __TEST__ exe 'read ' g:testname perldo s/perl/vieux_chameau/g 1 call assert_false(search('\Cperl')) bw! endf function Test_VIM_package() perl VIM::DoCommand('let l:var = "foo"') call assert_equal(l:var, 'foo') set noet perl VIM::SetOption('et') call assert_true(&et) endf