Mercurial > vim
annotate src/testdir/test_ruby.vim @ 9426:d606560082e6 v7.4.1994
commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jul 7 16:35:16 2016 +0200
patch 7.4.1994
Problem: True-false test fails.
Solution: Filter the dict to only keep the value that matters.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 07 Jul 2016 16:45:07 +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 |