Skip to content

Commit 572d8af

Browse files
committed
Added even more tests
1 parent 0c32b4b commit 572d8af

File tree

1 file changed

+52
-7
lines changed

1 file changed

+52
-7
lines changed

test/test_replica.vim

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,26 +144,71 @@ def g:Test_python_basic()
144144
enddef
145145

146146
def g:Test_unsupported_filetypes()
147+
# Test switching buffers of supported and unsupprted filetypes
147148

148-
const src_name = 'testfile.txt'
149-
const lines =<< trim END
149+
# Generate text file
150+
const text_filename = 'text_testfile.txt'
151+
const text_file_lines =<< trim END
150152
This is nothing, but just a simple text file used
151153
for the purpose of testing this plugin.
152154

153155
Nothing more than that.
154156
Bye.
155157
END
156158

157-
Generate_testfile(lines, src_name)
158-
exe $"edit {src_name}"
159+
Generate_testfile(text_file_lines, text_filename)
160+
exe $"edit {text_filename}"
159161

160162
# Start console and fail, since 'text' filetype is not supported
161163
assert_fails('ReplicaConsoleToggle', 'E492:')
164+
# Check that the buffer variables are not set
165+
WaitForAssert(() => assert_true(empty(getbufvar(bufnr(), "kernel_name"))))
166+
WaitForAssert(() => assert_true(empty(getbufvar(bufnr(), "console_name"))))
167+
168+
# Generate python file
169+
const python_filename = 'python_testfile.py'
170+
const python_file_lines =<< trim END
171+
a = 2
172+
b = 3
173+
174+
c = a + b
175+
END
162176

177+
Generate_testfile(python_file_lines, python_filename)
178+
179+
# Edit python file
180+
exe $"edit {python_filename}"
181+
182+
# Check that the buffer variables are set
183+
WaitForAssert(() => assert_false(empty(getbufvar(bufnr(), "kernel_name"))))
184+
WaitForAssert(() => assert_false(empty(getbufvar(bufnr(), "console_name"))))
185+
# Start console
186+
exe "ReplicaConsoleToggle"
187+
WaitForAssert(() => assert_equal(2, winnr('$')))
188+
WaitPrompt('[1]')
189+
190+
# switch buffer: python -> text
191+
exe "bnext"
192+
193+
# Start console and fail, since 'text' filetype is not supported
194+
assert_fails('ReplicaConsoleToggle', 'E492:')
163195
# Check that the buffer variables are not set
164-
assert_true(empty(getbufvar(bufnr(), "kernel_name")))
165-
assert_true(empty(getbufvar(bufnr(), "console_name")))
196+
WaitForAssert(() => assert_true(empty(getbufvar(bufnr(), "kernel_name"))))
197+
WaitForAssert(() => assert_true(empty(getbufvar(bufnr(), "console_name"))))
198+
199+
# switch buffer: text -> python
200+
exe "bnext"
201+
202+
# Check that the buffer variables are set
203+
WaitForAssert(() => assert_false(empty(getbufvar(bufnr(), "kernel_name"))))
204+
WaitForAssert(() => assert_false(empty(getbufvar(bufnr(), "console_name"))))
205+
# Close console
206+
exe "ReplicaConsoleToggle"
207+
WaitForAssert(() => assert_equal(1, winnr('$')))
208+
209+
exe "ReplicaConsoleShutoff"
166210

167211
:%bw!
168-
Cleanup_testfile(src_name)
212+
Cleanup_testfile(python_filename)
213+
Cleanup_testfile(text_filename)
169214
enddef

0 commit comments

Comments
 (0)