Bram Moolenaar | 85babd6 | 2016-06-21 22:59:28 +0200 | [diff] [blame] | 1 | " Tests for ruby interface |
| 2 | |
| 3 | if !has('ruby') |
| 4 | finish |
| 5 | end |
| 6 | |
| 7 | func Test_ruby_change_buffer() |
| 8 | call setline(line('$'), ['1 line 1']) |
| 9 | ruby Vim.command("normal /^1\n") |
| 10 | ruby $curbuf.line = "1 changed line 1" |
| 11 | call assert_equal('1 changed line 1', getline('$')) |
| 12 | endfunc |
| 13 | |
| 14 | func Test_ruby_evaluate_list() |
| 15 | call setline(line('$'), ['2 line 2']) |
| 16 | ruby Vim.command("normal /^2\n") |
| 17 | let l = ["abc", "def"] |
| 18 | ruby << EOF |
| 19 | curline = $curbuf.line_number |
| 20 | l = Vim.evaluate("l"); |
| 21 | $curbuf.append(curline, l.join("\n")) |
| 22 | EOF |
| 23 | normal j |
| 24 | .rubydo $_ = $_.gsub(/\n/, '/') |
| 25 | call assert_equal('abc/def', getline('$')) |
| 26 | endfunc |
| 27 | |
| 28 | func Test_ruby_evaluate_dict() |
| 29 | let d = {'a': 'foo', 'b': 123} |
| 30 | redir => l:out |
| 31 | ruby d = Vim.evaluate("d"); print d |
| 32 | redir END |
| 33 | call assert_equal(['{"a"=>"foo", "b"=>123}'], split(l:out, "\n")) |
| 34 | endfunc |