Mercurial > vim
annotate src/testdir/test_ruby.vim @ 11434:b3815e491811 v8.0.0601
patch 8.0.0601: no test coverage for :spellrepall
commit https://github.com/vim/vim/commit/545cb79da586be3333a0a55616046f94b01f6b1a
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 23 11:31:22 2017 +0200
patch 8.0.0601: no test coverage for :spellrepall
Problem: No test coverage for :spellrepall.
Solution: Add a test. (Dominique Pelle, closes https://github.com/vim/vim/issues/1717)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 23 May 2017 11:45:03 +0200 |
parents | 721af7a9b4b4 |
children | f06a0a75d5b1 |
rev | line source |
---|---|
9338
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for ruby interface |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 if !has('ruby') |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 finish |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 end |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 func Test_ruby_change_buffer() |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 call setline(line('$'), ['1 line 1']) |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 ruby Vim.command("normal /^1\n") |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 ruby $curbuf.line = "1 changed line 1" |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 call assert_equal('1 changed line 1', getline('$')) |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 endfunc |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 func Test_ruby_evaluate_list() |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 call setline(line('$'), ['2 line 2']) |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 ruby Vim.command("normal /^2\n") |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 let l = ["abc", "def"] |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 ruby << EOF |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 curline = $curbuf.line_number |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 l = Vim.evaluate("l"); |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 $curbuf.append(curline, l.join("\n")) |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 EOF |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 normal j |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 .rubydo $_ = $_.gsub(/\n/, '/') |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 call assert_equal('abc/def', getline('$')) |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 endfunc |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 func Test_ruby_evaluate_dict() |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 let d = {'a': 'foo', 'b': 123} |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 redir => l:out |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 ruby d = Vim.evaluate("d"); print d |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 redir END |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 call assert_equal(['{"a"=>"foo", "b"=>123}'], split(l:out, "\n")) |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 endfunc |
10761
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
35 |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
36 func Test_rubydo() |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
37 " Check deleting lines does not trigger ml_get error. |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
38 new |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
39 call setline(1, ['one', 'two', 'three']) |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
40 rubydo Vim.command("%d_") |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
41 bwipe! |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
42 |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
43 " Check switching to another buffer does not trigger ml_get error. |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
44 new |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
45 let wincount = winnr('$') |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
46 call setline(1, ['one', 'two', 'three']) |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
47 rubydo Vim.command("new") |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
48 call assert_equal(wincount + 1, winnr('$')) |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
49 bwipe! |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
50 bwipe! |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
51 endfunc |