Mercurial > vim
annotate src/testdir/test_ruby.vim @ 14750:1e6666885bc0 v8.1.0387
patch 8.1.0387: no test for 'ambiwidth' detection
commit https://github.com/vim/vim/commit/24839edc54e985ed88d063513226922a6f5b7554
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 13 20:46:52 2018 +0200
patch 8.1.0387: no test for 'ambiwidth' detection
Problem: No test for 'ambiwidth' detection.
Solution: Add a test.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 13 Sep 2018 21:00:06 +0200 |
parents | e6ad77cf13e0 |
children | e5f82e8b3c06 |
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 |
14413
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
7 " Helper function as there is no builtin rubyeval() function similar |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
8 " to perleval, luaevel() or pyeval(). |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
9 func RubyEval(ruby_expr) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
10 let s = split(execute('ruby print ' . a:ruby_expr), "\n") |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
11 return (len(s) == 0) ? '' : s[-1] |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
12 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
13 |
9338
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 func Test_ruby_change_buffer() |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 call setline(line('$'), ['1 line 1']) |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 ruby Vim.command("normal /^1\n") |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 ruby $curbuf.line = "1 changed line 1" |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 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
|
19 endfunc |
f23feeba7549
commit https://github.com/vim/vim/commit/85babd6db65afb0eb06a7a9a0778d692248c5c2b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 |
10761
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
21 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
|
22 " 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
|
23 new |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
24 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
|
25 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
|
26 bwipe! |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
27 |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
28 " 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
|
29 new |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
9338
diff
changeset
|
30 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
|
31 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
|
32 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
|
33 call assert_equal(wincount + 1, winnr('$')) |
14413
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
34 %bwipe! |
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 endfunc |
13148
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
10761
diff
changeset
|
36 |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
10761
diff
changeset
|
37 func Test_rubyfile() |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
10761
diff
changeset
|
38 " Check :rubyfile does not SEGV with Ruby level exception but just fails |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
10761
diff
changeset
|
39 let tempfile = tempname() . '.rb' |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
10761
diff
changeset
|
40 call writefile(['raise "vim!"'], tempfile) |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
10761
diff
changeset
|
41 call assert_fails('rubyfile ' . tempfile) |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
10761
diff
changeset
|
42 call delete(tempfile) |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
10761
diff
changeset
|
43 endfunc |
14395
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
44 |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
45 func Test_set_cursor() |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
46 " Check that setting the cursor position works. |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
47 new |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
48 call setline(1, ['first line', 'second line']) |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
49 normal gg |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
50 rubydo $curwin.cursor = [1, 5] |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
51 call assert_equal([1, 6], [line('.'), col('.')]) |
14413
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
52 call assert_equal('[1, 5]', RubyEval('$curwin.cursor')) |
14395
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
53 |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
54 " Check that movement after setting cursor position keeps current column. |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
55 normal j |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
56 call assert_equal([2, 6], [line('.'), col('.')]) |
14413
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
57 call assert_equal('[2, 5]', RubyEval('$curwin.cursor')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
58 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
59 call assert_fails('ruby $curwin.cursor = [1]', |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
60 \ 'ArgumentError: array length must be 2') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
61 bwipe! |
14395
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
13148
diff
changeset
|
62 endfunc |
14413
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
63 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
64 " Test buffer.count and buffer.length (number of lines in buffer) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
65 func Test_buffer_count() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
66 new |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
67 call setline(1, ['one', 'two', 'three']) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
68 call assert_equal('3', RubyEval('$curbuf.count')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
69 call assert_equal('3', RubyEval('$curbuf.length')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
70 bwipe! |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
71 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
72 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
73 " Test buffer.name (buffer name) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
74 func Test_buffer_name() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
75 new Xfoo |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
76 call assert_equal(expand('%:p'), RubyEval('$curbuf.name')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
77 bwipe |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
78 call assert_equal('', RubyEval('$curbuf.name')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
79 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
80 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
81 " Test buffer.number (number of the buffer). |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
82 func Test_buffer_number() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
83 new |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
84 call assert_equal(string(bufnr('%')), RubyEval('$curbuf.number')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
85 new |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
86 call assert_equal(string(bufnr('%')), RubyEval('$curbuf.number')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
87 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
88 %bwipe |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
89 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
90 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
91 " Test buffer.delete({n}) (delete line {n}) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
92 func Test_buffer_delete() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
93 new |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
94 call setline(1, ['one', 'two', 'three']) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
95 ruby $curbuf.delete(2) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
96 call assert_equal(['one', 'three'], getline(1, '$')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
97 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
98 call assert_fails('ruby $curbuf.delete(0)', 'IndexError: line number 0 out of range') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
99 call assert_fails('ruby $curbuf.delete(3)', 'IndexError: line number 3 out of range') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
100 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
101 bwipe! |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
102 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
103 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
104 " Test buffer.append({str}, str) (append line {str} after line {n}) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
105 func Test_buffer_append() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
106 new |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
107 ruby $curbuf.append(0, 'one') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
108 ruby $curbuf.append(1, 'three') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
109 ruby $curbuf.append(1, 'two') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
110 ruby $curbuf.append(4, 'four') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
111 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
112 call assert_equal(['one', 'two', 'three', '', 'four'], getline(1, '$')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
113 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
114 call assert_fails('ruby $curbuf.append(-1, "x")', |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
115 \ 'IndexError: line number -1 out of range') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
116 call assert_fails('ruby $curbuf.append(6, "x")', |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
117 \ 'IndexError: line number 6 out of range') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
118 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
119 bwipe! |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
120 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
121 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
122 " Test buffer.line (get or set the current line) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
123 func Test_buffer_line() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
124 new |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
125 call setline(1, ['one', 'two', 'three']) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
126 2 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
127 call assert_equal('two', RubyEval('$curbuf.line')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
128 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
129 ruby $curbuf.line = 'TWO' |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
130 call assert_equal(['one', 'TWO', 'three'], getline(1, '$')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
131 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
132 bwipe! |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
133 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
134 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
135 " Test buffer.line_number (get current line number) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
136 func Test_buffer_line_number() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
137 new |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
138 call setline(1, ['one', 'two', 'three']) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
139 2 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
140 call assert_equal('2', RubyEval('$curbuf.line_number')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
141 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
142 bwipe! |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
143 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
144 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
145 func Test_buffer_get() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
146 new |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
147 call setline(1, ['one', 'two']) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
148 call assert_equal('one', RubyEval('$curbuf[1]')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
149 call assert_equal('two', RubyEval('$curbuf[2]')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
150 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
151 call assert_fails('ruby $curbuf[0]', |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
152 \ 'IndexError: line number 0 out of range') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
153 call assert_fails('ruby $curbuf[3]', |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
154 \ 'IndexError: line number 3 out of range') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
155 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
156 bwipe! |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
157 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
158 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
159 func Test_buffer_set() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
160 new |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
161 call setline(1, ['one', 'two']) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
162 ruby $curbuf[2] = 'TWO' |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
163 ruby $curbuf[1] = 'ONE' |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
164 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
165 call assert_fails('ruby $curbuf[0] = "ZERO"', |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
166 \ 'IndexError: line number 0 out of range') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
167 call assert_fails('ruby $curbuf[3] = "THREE"', |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
168 \ 'IndexError: line number 3 out of range') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
169 bwipe! |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
170 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
171 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
172 " Test window.width (get or set window height). |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
173 func Test_window_height() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
174 new |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
175 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
176 " Test setting window height |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
177 ruby $curwin.height = 2 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
178 call assert_equal(2, winheight(0)) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
179 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
180 " Test getting window height |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
181 call assert_equal('2', RubyEval('$curwin.height')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
182 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
183 bwipe |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
184 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
185 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
186 " Test window.width (get or set window width). |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
187 func Test_window_width() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
188 vnew |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
189 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
190 " Test setting window width |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
191 ruby $curwin.width = 2 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
192 call assert_equal(2, winwidth(0)) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
193 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
194 " Test getting window width |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
195 call assert_equal('2', RubyEval('$curwin.width')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
196 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
197 bwipe |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
198 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
199 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
200 " Test window.buffer (get buffer object of a window object). |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
201 func Test_window_buffer() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
202 new Xfoo1 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
203 new Xfoo2 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
204 ruby $b2 = $curwin.buffer |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
205 ruby $w2 = $curwin |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
206 wincmd j |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
207 ruby $b1 = $curwin.buffer |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
208 ruby $w1 = $curwin |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
209 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
210 call assert_equal(RubyEval('$b1'), RubyEval('$w1.buffer')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
211 call assert_equal(RubyEval('$b2'), RubyEval('$w2.buffer')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
212 call assert_equal(string(bufnr('Xfoo1')), RubyEval('$w1.buffer.number')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
213 call assert_equal(string(bufnr('Xfoo2')), RubyEval('$w2.buffer.number')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
214 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
215 ruby $b1, $w1, $b2, $w2 = nil |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
216 %bwipe |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
217 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
218 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
219 " Test Vim::Window.current (get current window object) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
220 func Test_Vim_window_current() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
221 let cw = RubyEval('$curwin') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
222 call assert_equal(cw, RubyEval('Vim::Window.current')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
223 call assert_match('^#<Vim::Window:0x\x\+>$', cw) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
224 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
225 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
226 " Test Vim::Window.count (number of windows) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
227 func Test_Vim_window_count() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
228 new Xfoo1 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
229 new Xfoo2 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
230 split |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
231 call assert_equal('4', RubyEval('Vim::Window.count')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
232 %bwipe |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
233 call assert_equal('1', RubyEval('Vim::Window.count')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
234 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
235 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
236 " Test Vim::Window[n] (get window object of window n) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
237 func Test_Vim_window_get() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
238 new Xfoo1 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
239 new Xfoo2 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
240 call assert_match('Xfoo2$', RubyEval('Vim::Window[0].buffer.name')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
241 wincmd j |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
242 call assert_match('Xfoo1$', RubyEval('Vim::Window[1].buffer.name')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
243 wincmd j |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
244 call assert_equal('', RubyEval('Vim::Window[2].buffer.name')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
245 %bwipe |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
246 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
247 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
248 " Test Vim::Buffer.current (return the buffer object of current buffer) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
249 func Test_Vim_buffer_current() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
250 let cb = RubyEval('$curbuf') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
251 call assert_equal(cb, RubyEval('Vim::Buffer.current')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
252 call assert_match('^#<Vim::Buffer:0x\x\+>$', cb) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
253 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
254 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
255 " Test Vim::Buffer:.count (return the number of buffers) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
256 func Test_Vim_buffer_count() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
257 new Xfoo1 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
258 new Xfoo2 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
259 call assert_equal('3', RubyEval('Vim::Buffer.count')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
260 %bwipe |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
261 call assert_equal('1', RubyEval('Vim::Buffer.count')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
262 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
263 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
264 " Test Vim::buffer[n] (return the buffer object of buffer number n) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
265 func Test_Vim_buffer_get() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
266 new Xfoo1 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
267 new Xfoo2 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
268 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
269 " Index of Vim::Buffer[n] goes from 0 to the number of buffers. |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
270 call assert_equal('', RubyEval('Vim::Buffer[0].name')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
271 call assert_match('Xfoo1$', RubyEval('Vim::Buffer[1].name')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
272 call assert_match('Xfoo2$', RubyEval('Vim::Buffer[2].name')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
273 call assert_fails('ruby print Vim::Buffer[3].name', |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
274 \ "NoMethodError: undefined method `name' for nil:NilClass") |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
275 %bwipe |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
276 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
277 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
278 " Test Vim::command({cmd}) (execute a Ex command)) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
279 " Test Vim::command({cmd}) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
280 func Test_Vim_command() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
281 new |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
282 call setline(1, ['one', 'two', 'three', 'four']) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
283 ruby Vim::command('2,3d') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
284 call assert_equal(['one', 'four'], getline(1, '$')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
285 bwipe! |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
286 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
287 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
288 " Test Vim::set_option (set a vim option) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
289 func Test_Vim_set_option() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
290 call assert_equal(0, &number) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
291 ruby Vim::set_option('number') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
292 call assert_equal(1, &number) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
293 ruby Vim::set_option('nonumber') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
294 call assert_equal(0, &number) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
295 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
296 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
297 func Test_Vim_evaluate() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
298 call assert_equal('123', RubyEval('Vim::evaluate("123")')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
299 " Vim::evaluate("123").class gives Integer or Fixnum depending |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
300 " on versions of Ruby. |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
301 call assert_match('^Integer\|Fixnum$', RubyEval('Vim::evaluate("123").class')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
302 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
303 call assert_equal('1.23', RubyEval('Vim::evaluate("1.23")')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
304 call assert_equal('Float', RubyEval('Vim::evaluate("1.23").class')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
305 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
306 call assert_equal('foo', RubyEval('Vim::evaluate("\"foo\"")')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
307 call assert_equal('String', RubyEval('Vim::evaluate("\"foo\"").class')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
308 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
309 call assert_equal('[1, 2]', RubyEval('Vim::evaluate("[1, 2]")')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
310 call assert_equal('Array', RubyEval('Vim::evaluate("[1, 2]").class')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
311 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
312 call assert_equal('{"1"=>2}', RubyEval('Vim::evaluate("{1:2}")')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
313 call assert_equal('Hash', RubyEval('Vim::evaluate("{1:2}").class')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
314 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
315 call assert_equal('', RubyEval('Vim::evaluate("v:null")')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
316 call assert_equal('NilClass', RubyEval('Vim::evaluate("v:null").class')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
317 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
318 call assert_equal('', RubyEval('Vim::evaluate("v:none")')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
319 call assert_equal('NilClass', RubyEval('Vim::evaluate("v:none").class')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
320 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
321 call assert_equal('true', RubyEval('Vim::evaluate("v:true")')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
322 call assert_equal('TrueClass', RubyEval('Vim::evaluate("v:true").class')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
323 call assert_equal('false', RubyEval('Vim::evaluate("v:false")')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
324 call assert_equal('FalseClass',RubyEval('Vim::evaluate("v:false").class')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
325 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
326 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
327 func Test_Vim_evaluate_list() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
328 call setline(line('$'), ['2 line 2']) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
329 ruby Vim.command("normal /^2\n") |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
330 let l = ["abc", "def"] |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
331 ruby << EOF |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
332 curline = $curbuf.line_number |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
333 l = Vim.evaluate("l"); |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
334 $curbuf.append(curline, l.join("\n")) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
335 EOF |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
336 normal j |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
337 .rubydo $_ = $_.gsub(/\n/, '/') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
338 call assert_equal('abc/def', getline('$')) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
339 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
340 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
341 func Test_Vim_evaluate_dict() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
342 let d = {'a': 'foo', 'b': 123} |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
343 redir => l:out |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
344 ruby d = Vim.evaluate("d"); print d |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
345 redir END |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
346 call assert_equal(['{"a"=>"foo", "b"=>123}'], split(l:out, "\n")) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
347 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
348 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
349 " Test Vim::message({msg}) (display message {msg}) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
350 func Test_Vim_message() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
351 ruby Vim::message('A message') |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
352 let messages = split(execute('message'), "\n") |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
353 call assert_equal('A message', messages[-1]) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
354 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
355 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
356 func Test_print() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
357 ruby print "Hello World!" |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
358 let messages = split(execute('message'), "\n") |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
359 call assert_equal('Hello World!', messages[-1]) |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
360 endfunc |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
361 |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
362 func Test_p() |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
363 ruby p 'Just a test' |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
364 let messages = split(execute('message'), "\n") |
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
365 call assert_equal('"Just a test"', messages[-1]) |
14511
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
366 |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
367 " Check return values of p method |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
368 |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
369 call assert_equal('123', RubyEval('p(123)')) |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
370 call assert_equal('[1, 2, 3]', RubyEval('p(1, 2, 3)')) |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
371 |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
372 " Avoid the "message maintainer" line. |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
373 let $LANG = '' |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
374 messages clear |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
375 call assert_equal('true', RubyEval('p() == nil')) |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
376 |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
377 let messages = split(execute('message'), "\n") |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14413
diff
changeset
|
378 call assert_equal(0, len(messages)) |
14413
c3b62844ee4e
patch 8.1.0221: not enough testing for the Ruby interface
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
379 endfunc |