Mercurial > vim
annotate src/testdir/test_ruby.vim @ 10260:2fff06882079
Added tag v8.0.0027 for changeset a09db7a4afe0bfa4c35b7eab033441d9867001a0
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 09 Oct 2016 17:30:05 +0200 |
parents | f23feeba7549 |
children | 721af7a9b4b4 |
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 |