@@ -144,26 +144,71 @@ def g:Test_python_basic()
144
144
enddef
145
145
146
146
def g: Test_unsupported_filetypes ()
147
+ # Test switching buffers of supported and unsupprted filetypes
147
148
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
150
152
This is nothing, but just a simple text file used
151
153
for the purpose of testing this plugin .
152
154
153
155
Nothing more than that.
154
156
Bye.
155
157
END
156
158
157
- Generate_testfile (lines , src_name )
158
- exe $ " edit {src_name }"
159
+ Generate_testfile (text_file_lines, text_filename )
160
+ exe $ " edit {text_filename }"
159
161
160
162
# Start console and fail, since ' text' filetype is not supported
161
163
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
162
176
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:' )
163
195
# 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"
166
210
167
211
:% bw !
168
- Cleanup_testfile (src_name)
212
+ Cleanup_testfile (python_filename)
213
+ Cleanup_testfile (text_filename)
169
214
enddef
0 commit comments