Mercurial > vim
comparison src/testdir/test_vim9_cmd.vim @ 27457:4c16acb2525f v8.2.4257
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Commit: https://github.com/vim/vim/commit/62aec93bfdb9e1b40d03a6d2e8e9511f8b1bdb2d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 29 21:45:34 2022 +0000
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Problem: Vim9: finding global function without g: prefix but not finding
global variable is inconsistent.
Solution: Require using g: for a global function. Change the vim9.vim
script into a Vim9 script with exports. Fix that import in legacy
script does not work.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 29 Jan 2022 23:00:05 +0100 |
parents | 472bb63632bd |
children | a14c4d3e3260 |
comparison
equal
deleted
inserted
replaced
27456:a8e2d91995ce | 27457:4c16acb2525f |
---|---|
1 " Test commands that are not compiled in a :def function | 1 " Test commands that are not compiled in a :def function |
2 | 2 |
3 source check.vim | 3 source check.vim |
4 source vim9.vim | 4 import './vim9.vim' as v9 |
5 source term_util.vim | 5 source term_util.vim |
6 source view_util.vim | 6 source view_util.vim |
7 | 7 |
8 def Test_vim9cmd() | 8 def Test_vim9cmd() |
9 var lines =<< trim END | 9 var lines =<< trim END |
10 vim9cmd var x = 123 | 10 vim9cmd var x = 123 |
11 let s:y = 'yes' | 11 let s:y = 'yes' |
12 vim9c assert_equal(123, x) | 12 vim9c assert_equal(123, x) |
13 vim9cm assert_equal('yes', y) | 13 vim9cm assert_equal('yes', y) |
14 END | 14 END |
15 CheckScriptSuccess(lines) | 15 v9.CheckScriptSuccess(lines) |
16 | 16 |
17 assert_fails('vim9cmd', 'E1164:') | 17 assert_fails('vim9cmd', 'E1164:') |
18 assert_fails('legacy', 'E1234:') | 18 assert_fails('legacy', 'E1234:') |
19 assert_fails('vim9cmd echo "con" . "cat"', 'E15:') | 19 assert_fails('vim9cmd echo "con" . "cat"', 'E15:') |
20 | 20 |
21 lines =<< trim END | 21 lines =<< trim END |
22 let str = 'con' | 22 let str = 'con' |
23 vim9cmd str .= 'cat' | 23 vim9cmd str .= 'cat' |
24 END | 24 END |
25 CheckScriptFailure(lines, 'E492:') | 25 v9.CheckScriptFailure(lines, 'E492:') |
26 | 26 |
27 lines =<< trim END | 27 lines =<< trim END |
28 vim9script | 28 vim9script |
29 legacy echo "con" . "cat" | 29 legacy echo "con" . "cat" |
30 legacy let str = 'con' | 30 legacy let str = 'con' |
31 legacy let str .= 'cat' | 31 legacy let str .= 'cat' |
32 END | 32 END |
33 CheckScriptSuccess(lines) | 33 v9.CheckScriptSuccess(lines) |
34 | 34 |
35 lines =<< trim END | 35 lines =<< trim END |
36 vim9script | 36 vim9script |
37 def Foo() | 37 def Foo() |
38 g:found_bar = "bar" | 38 g:found_bar = "bar" |
39 enddef | 39 enddef |
40 nmap ,; :vim9cmd <SID>Foo()<CR> | 40 nmap ,; :vim9cmd <SID>Foo()<CR> |
41 END | 41 END |
42 CheckScriptSuccess(lines) | 42 v9.CheckScriptSuccess(lines) |
43 | 43 |
44 feedkeys(',;', 'xt') | 44 feedkeys(',;', 'xt') |
45 assert_equal("bar", g:found_bar) | 45 assert_equal("bar", g:found_bar) |
46 nunmap ,; | 46 nunmap ,; |
47 unlet g:found_bar | 47 unlet g:found_bar |
48 | 48 |
49 lines =<< trim END | 49 lines =<< trim END |
50 vim9script | 50 vim9script |
51 legacy echo 1'000 | 51 legacy echo 1'000 |
52 END | 52 END |
53 CheckScriptFailure(lines, 'E115:') | 53 v9.CheckScriptFailure(lines, 'E115:') |
54 | 54 |
55 if has('float') | 55 if has('float') |
56 lines =<< trim END | 56 lines =<< trim END |
57 vim9script | 57 vim9script |
58 echo .10 | 58 echo .10 |
59 END | 59 END |
60 CheckScriptSuccess(lines) | 60 v9.CheckScriptSuccess(lines) |
61 lines =<< trim END | 61 lines =<< trim END |
62 vim9cmd echo .10 | 62 vim9cmd echo .10 |
63 END | 63 END |
64 CheckScriptSuccess(lines) | 64 v9.CheckScriptSuccess(lines) |
65 lines =<< trim END | 65 lines =<< trim END |
66 vim9script | 66 vim9script |
67 legacy echo .10 | 67 legacy echo .10 |
68 END | 68 END |
69 CheckScriptFailure(lines, 'E15:') | 69 v9.CheckScriptFailure(lines, 'E15:') |
70 endif | 70 endif |
71 | 71 |
72 echo v:version | 72 echo v:version |
73 assert_fails('vim9cmd echo version', 'E121:') | 73 assert_fails('vim9cmd echo version', 'E121:') |
74 lines =<< trim END | 74 lines =<< trim END |
75 vim9script | 75 vim9script |
76 echo version | 76 echo version |
77 END | 77 END |
78 CheckScriptFailure(lines, 'E121:') | 78 v9.CheckScriptFailure(lines, 'E121:') |
79 lines =<< trim END | 79 lines =<< trim END |
80 vim9script | 80 vim9script |
81 legacy echo version | 81 legacy echo version |
82 END | 82 END |
83 CheckScriptSuccess(lines) | 83 v9.CheckScriptSuccess(lines) |
84 enddef | 84 enddef |
85 | 85 |
86 def Test_edit_wildcards() | 86 def Test_edit_wildcards() |
87 var filename = 'Xtest' | 87 var filename = 'Xtest' |
88 edit `=filename` | 88 edit `=filename` |
97 assert_equal('Xtest77', bufname()) | 97 assert_equal('Xtest77', bufname()) |
98 | 98 |
99 edit X`=filename`xx`=filenr`yy | 99 edit X`=filename`xx`=filenr`yy |
100 assert_equal('XXtestxx77yy', bufname()) | 100 assert_equal('XXtestxx77yy', bufname()) |
101 | 101 |
102 CheckDefFailure(['edit `=xxx`'], 'E1001:') | 102 v9.CheckDefFailure(['edit `=xxx`'], 'E1001:') |
103 CheckDefFailure(['edit `="foo"'], 'E1083:') | 103 v9.CheckDefFailure(['edit `="foo"'], 'E1083:') |
104 | 104 |
105 var files = ['file 1', 'file%2', 'file# 3'] | 105 var files = ['file 1', 'file%2', 'file# 3'] |
106 args `=files` | 106 args `=files` |
107 assert_equal(files, argv()) | 107 assert_equal(files, argv()) |
108 | 108 |
177 assert_true(bufexists('altfoo')) | 177 assert_true(bufexists('altfoo')) |
178 assert_false(buflisted('altfoo')) | 178 assert_false(buflisted('altfoo')) |
179 bwipe! altfoo | 179 bwipe! altfoo |
180 bwipe! bar | 180 bwipe! bar |
181 END | 181 END |
182 CheckDefAndScriptSuccess(lines) | 182 v9.CheckDefAndScriptSuccess(lines) |
183 enddef | 183 enddef |
184 | 184 |
185 def Test_global_backtick_expansion() | 185 def Test_global_backtick_expansion() |
186 var name = 'xxx' | 186 var name = 'xxx' |
187 new | 187 new |
219 def Test() | 219 def Test() |
220 folddoopen echo `=g:val` | 220 folddoopen echo `=g:val` |
221 enddef | 221 enddef |
222 call Test() | 222 call Test() |
223 END | 223 END |
224 CheckScriptFailure(lines, 'E15: Invalid expression: "`=g:val`"') | 224 v9.CheckScriptFailure(lines, 'E15: Invalid expression: "`=g:val`"') |
225 enddef | 225 enddef |
226 | 226 |
227 def Test_hardcopy_wildcards() | 227 def Test_hardcopy_wildcards() |
228 CheckUnix | 228 CheckUnix |
229 CheckFeature postscript | 229 CheckFeature postscript |
255 echo 'one' | 255 echo 'one' |
256 .. 'two' | 256 .. 'two' |
257 redir END | 257 redir END |
258 assert_equal("\nonetwo", @a) | 258 assert_equal("\nonetwo", @a) |
259 END | 259 END |
260 CheckScriptSuccess(lines) | 260 v9.CheckScriptSuccess(lines) |
261 | 261 |
262 lines =<< trim END | 262 lines =<< trim END |
263 vim9script | 263 vim9script |
264 redir @a | 264 redir @a |
265 echo 11 + | 265 echo 11 + |
266 77 | 266 77 |
267 - 22 | 267 - 22 |
268 redir END | 268 redir END |
269 assert_equal("\n66", @a) | 269 assert_equal("\n66", @a) |
270 END | 270 END |
271 CheckScriptSuccess(lines) | 271 v9.CheckScriptSuccess(lines) |
272 enddef | 272 enddef |
273 | 273 |
274 def Test_condition_types() | 274 def Test_condition_types() |
275 var lines =<< trim END | 275 var lines =<< trim END |
276 if 'text' | 276 if 'text' |
277 endif | 277 endif |
278 END | 278 END |
279 CheckDefAndScriptFailure(lines, 'E1135:', 1) | 279 v9.CheckDefAndScriptFailure(lines, 'E1135:', 1) |
280 | 280 |
281 lines =<< trim END | 281 lines =<< trim END |
282 if [1] | 282 if [1] |
283 endif | 283 endif |
284 END | 284 END |
285 CheckDefFailure(lines, 'E1012:', 1) | 285 v9.CheckDefFailure(lines, 'E1012:', 1) |
286 CheckScriptFailure(['vim9script'] + lines, 'E745:', 2) | 286 v9.CheckScriptFailure(['vim9script'] + lines, 'E745:', 2) |
287 | 287 |
288 lines =<< trim END | 288 lines =<< trim END |
289 g:cond = 'text' | 289 g:cond = 'text' |
290 if g:cond | 290 if g:cond |
291 endif | 291 endif |
292 END | 292 END |
293 CheckDefExecAndScriptFailure(lines, 'E1135:', 2) | 293 v9.CheckDefExecAndScriptFailure(lines, 'E1135:', 2) |
294 | 294 |
295 lines =<< trim END | 295 lines =<< trim END |
296 g:cond = 0 | 296 g:cond = 0 |
297 if g:cond | 297 if g:cond |
298 elseif 'text' | 298 elseif 'text' |
299 endif | 299 endif |
300 END | 300 END |
301 CheckDefAndScriptFailure(lines, 'E1135:', 3) | 301 v9.CheckDefAndScriptFailure(lines, 'E1135:', 3) |
302 | 302 |
303 lines =<< trim END | 303 lines =<< trim END |
304 g:cond = 0 | 304 g:cond = 0 |
305 if g:cond | 305 if g:cond |
306 elseif 'text' garbage | 306 elseif 'text' garbage |
307 endif | 307 endif |
308 END | 308 END |
309 CheckDefAndScriptFailure(lines, 'E488:', 3) | 309 v9.CheckDefAndScriptFailure(lines, 'E488:', 3) |
310 | 310 |
311 lines =<< trim END | 311 lines =<< trim END |
312 g:cond = 0 | 312 g:cond = 0 |
313 if g:cond | 313 if g:cond |
314 elseif [1] | 314 elseif [1] |
315 endif | 315 endif |
316 END | 316 END |
317 CheckDefFailure(lines, 'E1012:', 3) | 317 v9.CheckDefFailure(lines, 'E1012:', 3) |
318 CheckScriptFailure(['vim9script'] + lines, 'E745:', 4) | 318 v9.CheckScriptFailure(['vim9script'] + lines, 'E745:', 4) |
319 | 319 |
320 lines =<< trim END | 320 lines =<< trim END |
321 g:cond = 'text' | 321 g:cond = 'text' |
322 if 0 | 322 if 0 |
323 elseif g:cond | 323 elseif g:cond |
324 endif | 324 endif |
325 END | 325 END |
326 CheckDefExecAndScriptFailure(lines, 'E1135:', 3) | 326 v9.CheckDefExecAndScriptFailure(lines, 'E1135:', 3) |
327 | 327 |
328 lines =<< trim END | 328 lines =<< trim END |
329 while 'text' | 329 while 'text' |
330 endwhile | 330 endwhile |
331 END | 331 END |
332 CheckDefFailure(lines, 'E1012:', 1) | 332 v9.CheckDefFailure(lines, 'E1012:', 1) |
333 CheckScriptFailure(['vim9script'] + lines, 'E1135:', 2) | 333 v9.CheckScriptFailure(['vim9script'] + lines, 'E1135:', 2) |
334 | 334 |
335 lines =<< trim END | 335 lines =<< trim END |
336 while [1] | 336 while [1] |
337 endwhile | 337 endwhile |
338 END | 338 END |
339 CheckDefFailure(lines, 'E1012:', 1) | 339 v9.CheckDefFailure(lines, 'E1012:', 1) |
340 CheckScriptFailure(['vim9script'] + lines, 'E745:', 2) | 340 v9.CheckScriptFailure(['vim9script'] + lines, 'E745:', 2) |
341 | 341 |
342 lines =<< trim END | 342 lines =<< trim END |
343 g:cond = 'text' | 343 g:cond = 'text' |
344 while g:cond | 344 while g:cond |
345 endwhile | 345 endwhile |
346 END | 346 END |
347 CheckDefExecAndScriptFailure(lines, 'E1135:', 2) | 347 v9.CheckDefExecAndScriptFailure(lines, 'E1135:', 2) |
348 enddef | 348 enddef |
349 | 349 |
350 def Test_if_linebreak() | 350 def Test_if_linebreak() |
351 var lines =<< trim END | 351 var lines =<< trim END |
352 vim9script | 352 vim9script |
355 || 1 | 355 || 1 |
356 g:res = 42 | 356 g:res = 42 |
357 endif | 357 endif |
358 assert_equal(42, g:res) | 358 assert_equal(42, g:res) |
359 END | 359 END |
360 CheckScriptSuccess(lines) | 360 v9.CheckScriptSuccess(lines) |
361 unlet g:res | 361 unlet g:res |
362 | 362 |
363 lines =<< trim END | 363 lines =<< trim END |
364 vim9script | 364 vim9script |
365 if 1 && | 365 if 1 && |
370 || 1 | 370 || 1 |
371 g:res = 12 | 371 g:res = 12 |
372 endif | 372 endif |
373 assert_equal(12, g:res) | 373 assert_equal(12, g:res) |
374 END | 374 END |
375 CheckScriptSuccess(lines) | 375 v9.CheckScriptSuccess(lines) |
376 unlet g:res | 376 unlet g:res |
377 enddef | 377 enddef |
378 | 378 |
379 def Test_while_linebreak() | 379 def Test_while_linebreak() |
380 var lines =<< trim END | 380 var lines =<< trim END |
385 nr = nr | 385 nr = nr |
386 + 4 | 386 + 4 |
387 endwhile | 387 endwhile |
388 assert_equal(16, nr) | 388 assert_equal(16, nr) |
389 END | 389 END |
390 CheckScriptSuccess(lines) | 390 v9.CheckScriptSuccess(lines) |
391 | 391 |
392 lines =<< trim END | 392 lines =<< trim END |
393 vim9script | 393 vim9script |
394 var nr = 0 | 394 var nr = 0 |
395 while nr | 395 while nr |
401 + | 401 + |
402 4 | 402 4 |
403 endwhile | 403 endwhile |
404 assert_equal(16, nr) | 404 assert_equal(16, nr) |
405 END | 405 END |
406 CheckScriptSuccess(lines) | 406 v9.CheckScriptSuccess(lines) |
407 enddef | 407 enddef |
408 | 408 |
409 def Test_for_linebreak() | 409 def Test_for_linebreak() |
410 var lines =<< trim END | 410 var lines =<< trim END |
411 vim9script | 411 vim9script |
415 [1, 2, 3, 4] | 415 [1, 2, 3, 4] |
416 nr = nr + x | 416 nr = nr + x |
417 endfor | 417 endfor |
418 assert_equal(10, nr) | 418 assert_equal(10, nr) |
419 END | 419 END |
420 CheckScriptSuccess(lines) | 420 v9.CheckScriptSuccess(lines) |
421 | 421 |
422 lines =<< trim END | 422 lines =<< trim END |
423 vim9script | 423 vim9script |
424 var nr = 0 | 424 var nr = 0 |
425 for x | 425 for x |
431 + | 431 + |
432 x | 432 x |
433 endfor | 433 endfor |
434 assert_equal(10, nr) | 434 assert_equal(10, nr) |
435 END | 435 END |
436 CheckScriptSuccess(lines) | 436 v9.CheckScriptSuccess(lines) |
437 enddef | 437 enddef |
438 | 438 |
439 def MethodAfterLinebreak(arg: string) | 439 def s:MethodAfterLinebreak(arg: string) |
440 arg | 440 arg |
441 ->setline(1) | 441 ->setline(1) |
442 enddef | 442 enddef |
443 | 443 |
444 def Test_method_call_linebreak() | 444 def Test_method_call_linebreak() |
453 [1, | 453 [1, |
454 2, | 454 2, |
455 3]->RetArg() | 455 3]->RetArg() |
456 assert_equal([1, 2, 3], res) | 456 assert_equal([1, 2, 3], res) |
457 END | 457 END |
458 CheckScriptSuccess(lines) | 458 v9.CheckScriptSuccess(lines) |
459 | 459 |
460 lines =<< trim END | 460 lines =<< trim END |
461 new | 461 new |
462 var name = [1, 2] | 462 var name = [1, 2] |
463 name | 463 name |
464 ->copy() | 464 ->copy() |
465 ->setline(1) | 465 ->setline(1) |
466 assert_equal(['1', '2'], getline(1, 2)) | 466 assert_equal(['1', '2'], getline(1, 2)) |
467 bwipe! | 467 bwipe! |
468 END | 468 END |
469 CheckDefAndScriptSuccess(lines) | 469 v9.CheckDefAndScriptSuccess(lines) |
470 | 470 |
471 lines =<< trim END | 471 lines =<< trim END |
472 new | 472 new |
473 def Foo(): string | 473 def Foo(): string |
474 return 'the text' | 474 return 'the text' |
482 enddef | 482 enddef |
483 Test() | 483 Test() |
484 assert_equal('the text', getline(1)) | 484 assert_equal('the text', getline(1)) |
485 bwipe! | 485 bwipe! |
486 END | 486 END |
487 CheckDefAndScriptSuccess(lines) | 487 v9.CheckDefAndScriptSuccess(lines) |
488 | 488 |
489 lines =<< trim END | 489 lines =<< trim END |
490 new | 490 new |
491 g:shortlist | 491 g:shortlist |
492 ->copy() | 492 ->copy() |
493 ->setline(1) | 493 ->setline(1) |
494 assert_equal(['1', '2'], getline(1, 2)) | 494 assert_equal(['1', '2'], getline(1, 2)) |
495 bwipe! | 495 bwipe! |
496 END | 496 END |
497 g:shortlist = [1, 2] | 497 g:shortlist = [1, 2] |
498 CheckDefAndScriptSuccess(lines) | 498 v9.CheckDefAndScriptSuccess(lines) |
499 unlet g:shortlist | 499 unlet g:shortlist |
500 | 500 |
501 new | 501 new |
502 MethodAfterLinebreak('foobar') | 502 MethodAfterLinebreak('foobar') |
503 assert_equal('foobar', getline(1)) | 503 assert_equal('foobar', getline(1)) |
514 enddef | 514 enddef |
515 | 515 |
516 Foo->Bar() | 516 Foo->Bar() |
517 ->setline(1) | 517 ->setline(1) |
518 END | 518 END |
519 CheckScriptSuccess(lines) | 519 v9.CheckScriptSuccess(lines) |
520 assert_equal('# some text', getline(1)) | 520 assert_equal('# some text', getline(1)) |
521 bwipe! | 521 bwipe! |
522 enddef | 522 enddef |
523 | 523 |
524 def Test_method_call_whitespace() | 524 def Test_method_call_whitespace() |
530 yank-> setline(3) | 530 yank-> setline(3) |
531 yank -> setline(4) | 531 yank -> setline(4) |
532 assert_equal(['text', 'text', 'text', 'text'], getline(1, 4)) | 532 assert_equal(['text', 'text', 'text', 'text'], getline(1, 4)) |
533 bwipe! | 533 bwipe! |
534 END | 534 END |
535 CheckDefAndScriptSuccess(lines) | 535 v9.CheckDefAndScriptSuccess(lines) |
536 enddef | 536 enddef |
537 | 537 |
538 def Test_method_and_user_command() | 538 def Test_method_and_user_command() |
539 var lines =<< trim END | 539 var lines =<< trim END |
540 vim9script | 540 vim9script |
557 unlet g:didFunc | 557 unlet g:didFunc |
558 unlet g:didCmd | 558 unlet g:didCmd |
559 enddef | 559 enddef |
560 InDefFunc() | 560 InDefFunc() |
561 END | 561 END |
562 CheckScriptSuccess(lines) | 562 v9.CheckScriptSuccess(lines) |
563 enddef | 563 enddef |
564 | 564 |
565 def Test_option_use_linebreak() | 565 def Test_option_use_linebreak() |
566 var lines =<< trim END | 566 var lines =<< trim END |
567 new | 567 new |
573 &matchpairs | 573 &matchpairs |
574 ->setline(3) | 574 ->setline(3) |
575 assert_equal(['(:)', '[:]', '{:}'], getline(1, '$')) | 575 assert_equal(['(:)', '[:]', '{:}'], getline(1, '$')) |
576 bwipe! | 576 bwipe! |
577 END | 577 END |
578 CheckDefAndScriptSuccess(lines) | 578 v9.CheckDefAndScriptSuccess(lines) |
579 enddef | 579 enddef |
580 | 580 |
581 def Test_use_register() | 581 def Test_use_register() |
582 var lines =<< trim END | 582 var lines =<< trim END |
583 new | 583 new |
589 @c | 589 @c |
590 ->setline(3) | 590 ->setline(3) |
591 assert_equal(['one', 'two', 'three'], getline(1, '$')) | 591 assert_equal(['one', 'two', 'three'], getline(1, '$')) |
592 bwipe! | 592 bwipe! |
593 END | 593 END |
594 CheckDefAndScriptSuccess(lines) | 594 v9.CheckDefAndScriptSuccess(lines) |
595 | 595 |
596 lines =<< trim END | 596 lines =<< trim END |
597 @a = 'echo "text"' | 597 @a = 'echo "text"' |
598 @a | 598 @a |
599 END | 599 END |
600 CheckDefAndScriptFailure(lines, 'E1207:', 2) | 600 v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) |
601 | 601 |
602 lines =<< trim END | 602 lines =<< trim END |
603 @/ = 'pattern' | 603 @/ = 'pattern' |
604 @/ | 604 @/ |
605 END | 605 END |
606 CheckDefAndScriptFailure(lines, 'E1207:', 2) | 606 v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) |
607 | 607 |
608 lines =<< trim END | 608 lines =<< trim END |
609 &opfunc = 'nothing' | 609 &opfunc = 'nothing' |
610 &opfunc | 610 &opfunc |
611 END | 611 END |
612 CheckDefAndScriptFailure(lines, 'E1207:', 2) | 612 v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) |
613 &opfunc = '' | 613 &opfunc = '' |
614 | 614 |
615 lines =<< trim END | 615 lines =<< trim END |
616 &l:showbreak = 'nothing' | 616 &l:showbreak = 'nothing' |
617 &l:showbreak | 617 &l:showbreak |
618 END | 618 END |
619 CheckDefAndScriptFailure(lines, 'E1207:', 2) | 619 v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) |
620 &l:showbreak = '' | 620 &l:showbreak = '' |
621 | 621 |
622 lines =<< trim END | 622 lines =<< trim END |
623 &g:showbreak = 'nothing' | 623 &g:showbreak = 'nothing' |
624 &g:showbreak | 624 &g:showbreak |
625 END | 625 END |
626 CheckDefAndScriptFailure(lines, 'E1207:', 2) | 626 v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) |
627 &g:showbreak = '' | 627 &g:showbreak = '' |
628 | 628 |
629 lines =<< trim END | 629 lines =<< trim END |
630 $SomeEnv = 'value' | 630 $SomeEnv = 'value' |
631 $SomeEnv | 631 $SomeEnv |
632 END | 632 END |
633 CheckDefAndScriptFailure(lines, 'E1207:', 2) | 633 v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) |
634 $SomeEnv = '' | 634 $SomeEnv = '' |
635 enddef | 635 enddef |
636 | 636 |
637 def Test_environment_use_linebreak() | 637 def Test_environment_use_linebreak() |
638 var lines =<< trim END | 638 var lines =<< trim END |
645 $TESTENV | 645 $TESTENV |
646 ->setline(3) | 646 ->setline(3) |
647 assert_equal(['one', 'two', 'three'], getline(1, '$')) | 647 assert_equal(['one', 'two', 'three'], getline(1, '$')) |
648 bwipe! | 648 bwipe! |
649 END | 649 END |
650 CheckDefAndScriptSuccess(lines) | 650 v9.CheckDefAndScriptSuccess(lines) |
651 enddef | 651 enddef |
652 | 652 |
653 def Test_skipped_expr_linebreak() | 653 def Test_skipped_expr_linebreak() |
654 if 0 | 654 if 0 |
655 var x = [] | 655 var x = [] |
669 vim9script | 669 vim9script |
670 var test: dict<list<number>> = {data: [3, 1, 2]} | 670 var test: dict<list<number>> = {data: [3, 1, 2]} |
671 test.data->sort() | 671 test.data->sort() |
672 assert_equal({data: [1, 2, 3]}, test) | 672 assert_equal({data: [1, 2, 3]}, test) |
673 END | 673 END |
674 CheckScriptSuccess(lines) | 674 v9.CheckScriptSuccess(lines) |
675 enddef | 675 enddef |
676 | 676 |
677 def Test_bar_after_command() | 677 def Test_bar_after_command() |
678 def RedrawAndEcho() | 678 def RedrawAndEcho() |
679 var x = 'did redraw' | 679 var x = 'did redraw' |
680 redraw | echo x | 680 redraw | echo x |
681 enddef | 681 enddef |
682 RedrawAndEcho() | 682 RedrawAndEcho() |
683 assert_match('did redraw', Screenline(&lines)) | 683 assert_match('did redraw', g:Screenline(&lines)) |
684 | 684 |
685 def CallAndEcho() | 685 def CallAndEcho() |
686 var x = 'did redraw' | 686 var x = 'did redraw' |
687 reg_executing() | echo x | 687 reg_executing() | echo x |
688 enddef | 688 enddef |
689 CallAndEcho() | 689 CallAndEcho() |
690 assert_match('did redraw', Screenline(&lines)) | 690 assert_match('did redraw', g:Screenline(&lines)) |
691 | 691 |
692 if has('unix') | 692 if has('unix') |
693 # bar in filter write command does not start new command | 693 # bar in filter write command does not start new command |
694 def WriteToShell() | 694 def WriteToShell() |
695 new | 695 new |
727 @b = 'fuga' | 727 @b = 'fuga' |
728 @c = 'piyo' | 728 @c = 'piyo' |
729 | 729 |
730 assert_equal(execute('filter /piyo/ registers abc'), expected) | 730 assert_equal(execute('filter /piyo/ registers abc'), expected) |
731 END | 731 END |
732 CheckDefAndScriptSuccess(lines) | 732 v9.CheckDefAndScriptSuccess(lines) |
733 | 733 |
734 # also do this compiled | 734 # also do this compiled |
735 lines =<< trim END | 735 lines =<< trim END |
736 @a = 'very specific z3d37dh234 string' | 736 @a = 'very specific z3d37dh234 string' |
737 filter z3d37dh234 registers | 737 filter z3d37dh234 registers |
738 assert_match('very specific z3d37dh234 string', Screenline(&lines)) | 738 assert_match('very specific z3d37dh234 string', g:Screenline(&lines)) |
739 END | 739 END |
740 CheckDefAndScriptSuccess(lines) | 740 v9.CheckDefAndScriptSuccess(lines) |
741 | 741 |
742 lines =<< trim END | 742 lines =<< trim END |
743 edit foobar | 743 edit foobar |
744 redir => g:filter_out | 744 redir => g:filter_out |
745 filter #foobar# ls | 745 filter #foobar# ls |
746 redir END | 746 redir END |
747 assert_match('"foobar"', g:filter_out) | 747 assert_match('"foobar"', g:filter_out) |
748 unlet g:filter_out | 748 unlet g:filter_out |
749 END | 749 END |
750 CheckDefAndScriptSuccess(lines) | 750 v9.CheckDefAndScriptSuccess(lines) |
751 enddef | 751 enddef |
752 | 752 |
753 def Test_win_command_modifiers() | 753 def Test_win_command_modifiers() |
754 assert_equal(1, winnr('$')) | 754 assert_equal(1, winnr('$')) |
755 | 755 |
928 au! BufNewFile | 928 au! BufNewFile |
929 unlet g:readFile | 929 unlet g:readFile |
930 unlet g:readExtra | 930 unlet g:readExtra |
931 unlet g:readMore | 931 unlet g:readMore |
932 END | 932 END |
933 CheckDefAndScriptSuccess(lines) | 933 v9.CheckDefAndScriptSuccess(lines) |
934 enddef | 934 enddef |
935 | 935 |
936 def Test_command_modifier_other() | 936 def Test_command_modifier_other() |
937 new Xsomefile | 937 new Xsomefile |
938 setline(1, 'changed') | 938 setline(1, 'changed') |
970 :8verbose g:verbose_now = &verbose | 970 :8verbose g:verbose_now = &verbose |
971 assert_equal(8, g:verbose_now) | 971 assert_equal(8, g:verbose_now) |
972 unlet g:verbose_now | 972 unlet g:verbose_now |
973 enddef | 973 enddef |
974 | 974 |
975 def EchoHere() | 975 def s:EchoHere() |
976 echomsg 'here' | 976 echomsg 'here' |
977 enddef | 977 enddef |
978 def EchoThere() | 978 def s:EchoThere() |
979 unsilent echomsg 'there' | 979 unsilent echomsg 'there' |
980 enddef | 980 enddef |
981 | 981 |
982 def Test_modifier_silent_unsilent() | 982 def Test_modifier_silent_unsilent() |
983 echomsg 'last one' | 983 echomsg 'last one' |
1007 set history=22 | 1007 set history=22 |
1008 silent! endwhile | 1008 silent! endwhile |
1009 assert_equal(11, &history) | 1009 assert_equal(11, &history) |
1010 set history& | 1010 set history& |
1011 END | 1011 END |
1012 CheckScriptSuccess(lines) | 1012 v9.CheckScriptSuccess(lines) |
1013 enddef | 1013 enddef |
1014 | 1014 |
1015 def Test_range_after_command_modifier() | 1015 def Test_range_after_command_modifier() |
1016 CheckScriptFailure(['vim9script', 'silent keepjump 1d _'], 'E1050: Colon required before a range: 1d _', 2) | 1016 v9.CheckScriptFailure(['vim9script', 'silent keepjump 1d _'], 'E1050: Colon required before a range: 1d _', 2) |
1017 new | 1017 new |
1018 setline(1, 'xxx') | 1018 setline(1, 'xxx') |
1019 CheckScriptSuccess(['vim9script', 'silent keepjump :1d _']) | 1019 v9.CheckScriptSuccess(['vim9script', 'silent keepjump :1d _']) |
1020 assert_equal('', getline(1)) | 1020 assert_equal('', getline(1)) |
1021 bwipe! | 1021 bwipe! |
1022 | 1022 |
1023 var lines =<< trim END | 1023 var lines =<< trim END |
1024 legacy /pat/ | 1024 legacy /pat/ |
1025 END | 1025 END |
1026 CheckDefExecAndScriptFailure(lines, 'E486: Pattern not found: pat') | 1026 v9.CheckDefExecAndScriptFailure(lines, 'E486: Pattern not found: pat') |
1027 enddef | 1027 enddef |
1028 | 1028 |
1029 def Test_silent_pattern() | 1029 def Test_silent_pattern() |
1030 new | 1030 new |
1031 silent! :/pat/put _ | 1031 silent! :/pat/put _ |
1036 g:maybe = true | 1036 g:maybe = true |
1037 var lines =<< trim END | 1037 var lines =<< trim END |
1038 if g:maybe | 1038 if g:maybe |
1039 silent endif | 1039 silent endif |
1040 END | 1040 END |
1041 CheckDefAndScriptFailure(lines, 'E1176:', 2) | 1041 v9.CheckDefAndScriptFailure(lines, 'E1176:', 2) |
1042 | 1042 |
1043 lines =<< trim END | 1043 lines =<< trim END |
1044 for i in [0] | 1044 for i in [0] |
1045 silent endfor | 1045 silent endfor |
1046 END | 1046 END |
1047 CheckDefFailure(lines, 'E1176:', 2) | 1047 v9.CheckDefFailure(lines, 'E1176:', 2) |
1048 CheckScriptSuccess(['vim9script'] + lines) | 1048 v9.CheckScriptSuccess(['vim9script'] + lines) |
1049 | 1049 |
1050 lines =<< trim END | 1050 lines =<< trim END |
1051 while g:maybe | 1051 while g:maybe |
1052 silent endwhile | 1052 silent endwhile |
1053 END | 1053 END |
1054 CheckDefFailure(lines, 'E1176:', 2) | 1054 v9.CheckDefFailure(lines, 'E1176:', 2) |
1055 g:maybe = false | 1055 g:maybe = false |
1056 CheckScriptSuccess(['vim9script'] + lines) | 1056 v9.CheckScriptSuccess(['vim9script'] + lines) |
1057 | 1057 |
1058 lines =<< trim END | 1058 lines =<< trim END |
1059 silent try | 1059 silent try |
1060 finally | 1060 finally |
1061 endtry | 1061 endtry |
1062 END | 1062 END |
1063 CheckDefAndScriptFailure(lines, 'E1176:', 1) | 1063 v9.CheckDefAndScriptFailure(lines, 'E1176:', 1) |
1064 | 1064 |
1065 lines =<< trim END | 1065 lines =<< trim END |
1066 try | 1066 try |
1067 silent catch | 1067 silent catch |
1068 endtry | 1068 endtry |
1069 END | 1069 END |
1070 CheckDefAndScriptFailure(lines, 'E1176:', 2) | 1070 v9.CheckDefAndScriptFailure(lines, 'E1176:', 2) |
1071 | 1071 |
1072 lines =<< trim END | 1072 lines =<< trim END |
1073 try | 1073 try |
1074 silent finally | 1074 silent finally |
1075 endtry | 1075 endtry |
1076 END | 1076 END |
1077 CheckDefAndScriptFailure(lines, 'E1176:', 2) | 1077 v9.CheckDefAndScriptFailure(lines, 'E1176:', 2) |
1078 | 1078 |
1079 lines =<< trim END | 1079 lines =<< trim END |
1080 try | 1080 try |
1081 finally | 1081 finally |
1082 silent endtry | 1082 silent endtry |
1083 END | 1083 END |
1084 CheckDefAndScriptFailure(lines, 'E1176:', 3) | 1084 v9.CheckDefAndScriptFailure(lines, 'E1176:', 3) |
1085 enddef | 1085 enddef |
1086 | 1086 |
1087 def Test_eval_command() | 1087 def Test_eval_command() |
1088 var from = 3 | 1088 var from = 3 |
1089 var to = 5 | 1089 var to = 5 |
1107 g:caught = 'yes' | 1107 g:caught = 'yes' |
1108 endtry | 1108 endtry |
1109 assert_equal('yes', g:caught) | 1109 assert_equal('yes', g:caught) |
1110 unlet g:caught | 1110 unlet g:caught |
1111 END | 1111 END |
1112 CheckScriptSuccess(lines) | 1112 v9.CheckScriptSuccess(lines) |
1113 enddef | 1113 enddef |
1114 | 1114 |
1115 def Test_map_command() | 1115 def Test_map_command() |
1116 var lines =<< trim END | 1116 var lines =<< trim END |
1117 nnoremap <F3> :echo 'hit F3 #'<CR> | 1117 nnoremap <F3> :echo 'hit F3 #'<CR> |
1118 assert_equal(":echo 'hit F3 #'<CR>", maparg("<F3>", "n")) | 1118 assert_equal(":echo 'hit F3 #'<CR>", maparg("<F3>", "n")) |
1119 END | 1119 END |
1120 CheckDefSuccess(lines) | 1120 v9.CheckDefSuccess(lines) |
1121 CheckScriptSuccess(['vim9script'] + lines) | 1121 v9.CheckScriptSuccess(['vim9script'] + lines) |
1122 enddef | 1122 enddef |
1123 | 1123 |
1124 def Test_normal_command() | 1124 def Test_normal_command() |
1125 new | 1125 new |
1126 setline(1, 'doesnotexist') | 1126 setline(1, 'doesnotexist') |
1171 :$put ='end' | 1171 :$put ='end' |
1172 assert_equal('end', getline('$')) | 1172 assert_equal('end', getline('$')) |
1173 | 1173 |
1174 bwipe! | 1174 bwipe! |
1175 | 1175 |
1176 CheckDefFailure(['put =xxx'], 'E1001:') | 1176 v9.CheckDefFailure(['put =xxx'], 'E1001:') |
1177 enddef | 1177 enddef |
1178 | 1178 |
1179 def Test_put_with_linebreak() | 1179 def Test_put_with_linebreak() |
1180 new | 1180 new |
1181 var lines =<< trim END | 1181 var lines =<< trim END |
1182 vim9script | 1182 vim9script |
1183 pu =split('abc', '\zs') | 1183 pu =split('abc', '\zs') |
1184 ->join() | 1184 ->join() |
1185 END | 1185 END |
1186 CheckScriptSuccess(lines) | 1186 v9.CheckScriptSuccess(lines) |
1187 getline(2)->assert_equal('a b c') | 1187 getline(2)->assert_equal('a b c') |
1188 bwipe! | 1188 bwipe! |
1189 enddef | 1189 enddef |
1190 | 1190 |
1191 def Test_command_star_range() | 1191 def Test_command_star_range() |
1213 assert_equal([], g:args) | 1213 assert_equal([], g:args) |
1214 | 1214 |
1215 TestFArgs one two three | 1215 TestFArgs one two three |
1216 assert_equal(['one', 'two', 'three'], g:args) | 1216 assert_equal(['one', 'two', 'three'], g:args) |
1217 END | 1217 END |
1218 CheckScriptSuccess(lines) | 1218 v9.CheckScriptSuccess(lines) |
1219 enddef | 1219 enddef |
1220 | 1220 |
1221 def Test_user_command_comment() | 1221 def Test_user_command_comment() |
1222 command -nargs=1 Comd echom <q-args> | 1222 command -nargs=1 Comd echom <q-args> |
1223 | 1223 |
1224 var lines =<< trim END | 1224 var lines =<< trim END |
1225 vim9script | 1225 vim9script |
1226 Comd # comment | 1226 Comd # comment |
1227 END | 1227 END |
1228 CheckScriptSuccess(lines) | 1228 v9.CheckScriptSuccess(lines) |
1229 | 1229 |
1230 lines =<< trim END | 1230 lines =<< trim END |
1231 vim9script | 1231 vim9script |
1232 Comd# comment | 1232 Comd# comment |
1233 END | 1233 END |
1234 CheckScriptFailure(lines, 'E1144:') | 1234 v9.CheckScriptFailure(lines, 'E1144:') |
1235 delcommand Comd | 1235 delcommand Comd |
1236 | 1236 |
1237 lines =<< trim END | 1237 lines =<< trim END |
1238 vim9script | 1238 vim9script |
1239 command Foo echo 'Foo' | 1239 command Foo echo 'Foo' |
1240 Foo3Bar | 1240 Foo3Bar |
1241 END | 1241 END |
1242 CheckScriptFailure(lines, 'E1144: Command "Foo" is not followed by white space: Foo3Bar') | 1242 v9.CheckScriptFailure(lines, 'E1144: Command "Foo" is not followed by white space: Foo3Bar') |
1243 | 1243 |
1244 delcommand Foo | 1244 delcommand Foo |
1245 enddef | 1245 enddef |
1246 | 1246 |
1247 def Test_star_command() | 1247 def Test_star_command() |
1253 assert_equal(8, g:success) | 1253 assert_equal(8, g:success) |
1254 unlet g:success | 1254 unlet g:success |
1255 set cpo-=* | 1255 set cpo-=* |
1256 assert_fails("exe '*s'", 'E1050:') | 1256 assert_fails("exe '*s'", 'E1050:') |
1257 END | 1257 END |
1258 CheckScriptSuccess(lines) | 1258 v9.CheckScriptSuccess(lines) |
1259 enddef | 1259 enddef |
1260 | 1260 |
1261 def Test_cmd_argument_without_colon() | 1261 def Test_cmd_argument_without_colon() |
1262 new Xfile | 1262 new Xfile |
1263 setline(1, ['a', 'b', 'c', 'd']) | 1263 setline(1, ['a', 'b', 'c', 'd']) |
1274 command Cmd1 eval 0 | 1274 command Cmd1 eval 0 |
1275 command Cmd2 eval 0 | 1275 command Cmd2 eval 0 |
1276 var lines =<< trim END | 1276 var lines =<< trim END |
1277 Cmd | 1277 Cmd |
1278 END | 1278 END |
1279 CheckDefAndScriptFailure(lines, 'E464:', 1) | 1279 v9.CheckDefAndScriptFailure(lines, 'E464:', 1) |
1280 delcommand Cmd1 | 1280 delcommand Cmd1 |
1281 delcommand Cmd2 | 1281 delcommand Cmd2 |
1282 enddef | 1282 enddef |
1283 | 1283 |
1284 def Test_command_not_recognized() | 1284 def Test_command_not_recognized() |
1285 var lines =<< trim END | 1285 var lines =<< trim END |
1286 d.key = 'asdf' | 1286 d.key = 'asdf' |
1287 END | 1287 END |
1288 CheckDefFailure(lines, 'E1146:', 1) | 1288 v9.CheckDefFailure(lines, 'E1146:', 1) |
1289 | 1289 |
1290 lines =<< trim END | 1290 lines =<< trim END |
1291 d['key'] = 'asdf' | 1291 d['key'] = 'asdf' |
1292 END | 1292 END |
1293 CheckDefFailure(lines, 'E1146:', 1) | 1293 v9.CheckDefFailure(lines, 'E1146:', 1) |
1294 enddef | 1294 enddef |
1295 | 1295 |
1296 def Test_magic_not_used() | 1296 def Test_magic_not_used() |
1297 new | 1297 new |
1298 for cmd in ['set magic', 'set nomagic'] | 1298 for cmd in ['set magic', 'set nomagic'] |
1376 | 1376 |
1377 def Test_windo_missing_endif() | 1377 def Test_windo_missing_endif() |
1378 var lines =<< trim END | 1378 var lines =<< trim END |
1379 windo if 1 | 1379 windo if 1 |
1380 END | 1380 END |
1381 CheckDefExecFailure(lines, 'E171:', 1) | 1381 v9.CheckDefExecFailure(lines, 'E171:', 1) |
1382 enddef | 1382 enddef |
1383 | 1383 |
1384 let s:theList = [1, 2, 3] | 1384 let s:theList = [1, 2, 3] |
1385 | 1385 |
1386 def Test_lockvar() | 1386 def Test_lockvar() |
1462 lockvar theList | 1462 lockvar theList |
1463 theList[1] = 77 | 1463 theList[1] = 77 |
1464 enddef | 1464 enddef |
1465 SetList() | 1465 SetList() |
1466 END | 1466 END |
1467 CheckScriptFailure(lines, 'E1119', 4) | 1467 v9.CheckScriptFailure(lines, 'E1119', 4) |
1468 | 1468 |
1469 lines =<< trim END | 1469 lines =<< trim END |
1470 var theList = [1, 2, 3] | 1470 var theList = [1, 2, 3] |
1471 lockvar theList | 1471 lockvar theList |
1472 END | 1472 END |
1473 CheckDefFailure(lines, 'E1178', 2) | 1473 v9.CheckDefFailure(lines, 'E1178', 2) |
1474 | 1474 |
1475 lines =<< trim END | 1475 lines =<< trim END |
1476 var theList = [1, 2, 3] | 1476 var theList = [1, 2, 3] |
1477 unlockvar theList | 1477 unlockvar theList |
1478 END | 1478 END |
1479 CheckDefFailure(lines, 'E1178', 2) | 1479 v9.CheckDefFailure(lines, 'E1178', 2) |
1480 | 1480 |
1481 lines =<< trim END | 1481 lines =<< trim END |
1482 vim9script | 1482 vim9script |
1483 var name = 'john' | 1483 var name = 'john' |
1484 lockvar nameX | 1484 lockvar nameX |
1485 END | 1485 END |
1486 CheckScriptFailure(lines, 'E1246', 3) | 1486 v9.CheckScriptFailure(lines, 'E1246', 3) |
1487 | 1487 |
1488 lines =<< trim END | 1488 lines =<< trim END |
1489 vim9script | 1489 vim9script |
1490 var name = 'john' | 1490 var name = 'john' |
1491 def LockIt() | 1491 def LockIt() |
1492 lockvar nameX | 1492 lockvar nameX |
1493 enddef | 1493 enddef |
1494 LockIt() | 1494 LockIt() |
1495 END | 1495 END |
1496 CheckScriptFailure(lines, 'E1246', 1) | 1496 v9.CheckScriptFailure(lines, 'E1246', 1) |
1497 enddef | 1497 enddef |
1498 | 1498 |
1499 def Test_substitute_expr() | 1499 def Test_substitute_expr() |
1500 var to = 'repl' | 1500 var to = 'repl' |
1501 new | 1501 new |
1518 endfor | 1518 endfor |
1519 assert_equal('yes no abc', getline(1)) | 1519 assert_equal('yes no abc', getline(1)) |
1520 | 1520 |
1521 bwipe! | 1521 bwipe! |
1522 | 1522 |
1523 CheckDefFailure(['s/from/\="x")/'], 'E488:') | 1523 v9.CheckDefFailure(['s/from/\="x")/'], 'E488:') |
1524 CheckDefFailure(['s/from/\="x"/9'], 'E488:') | 1524 v9.CheckDefFailure(['s/from/\="x"/9'], 'E488:') |
1525 | 1525 |
1526 # When calling a function the right instruction list needs to be restored. | 1526 # When calling a function the right instruction list needs to be restored. |
1527 g:cond = true | 1527 g:cond = true |
1528 var lines =<< trim END | 1528 var lines =<< trim END |
1529 vim9script | 1529 vim9script |
1543 new | 1543 new |
1544 Foo() | 1544 Foo() |
1545 assert_equal('rep', getline(1)) | 1545 assert_equal('rep', getline(1)) |
1546 bwipe! | 1546 bwipe! |
1547 END | 1547 END |
1548 CheckScriptSuccess(lines) | 1548 v9.CheckScriptSuccess(lines) |
1549 unlet g:cond | 1549 unlet g:cond |
1550 | 1550 |
1551 # List results in multiple lines | 1551 # List results in multiple lines |
1552 new | 1552 new |
1553 setline(1, 'some text here') | 1553 setline(1, 'some text here') |
1592 assert_equal({redir: "\ndict\nmore"}, d) | 1592 assert_equal({redir: "\ndict\nmore"}, d) |
1593 | 1593 |
1594 var lines =<< trim END | 1594 var lines =<< trim END |
1595 redir => notexist | 1595 redir => notexist |
1596 END | 1596 END |
1597 CheckDefFailure(lines, 'E1089:') | 1597 v9.CheckDefFailure(lines, 'E1089:') |
1598 | 1598 |
1599 lines =<< trim END | 1599 lines =<< trim END |
1600 var ls = 'asdf' | 1600 var ls = 'asdf' |
1601 redir => ls[1] | 1601 redir => ls[1] |
1602 redir END | 1602 redir END |
1603 END | 1603 END |
1604 CheckDefFailure(lines, 'E1141:') | 1604 v9.CheckDefFailure(lines, 'E1141:') |
1605 | 1605 |
1606 lines =<< trim END | 1606 lines =<< trim END |
1607 var text: string | 1607 var text: string |
1608 redir => text | 1608 redir => text |
1609 echo 'hello' | 1609 echo 'hello' |
1610 redir > Xfile | 1610 redir > Xfile |
1611 redir END | 1611 redir END |
1612 END | 1612 END |
1613 CheckDefFailure(lines, 'E1185:') | 1613 v9.CheckDefFailure(lines, 'E1185:') |
1614 | 1614 |
1615 lines =<< trim END | 1615 lines =<< trim END |
1616 var text: number | 1616 var text: number |
1617 redir => text | 1617 redir => text |
1618 echo 'hello' | 1618 echo 'hello' |
1619 redir END | 1619 redir END |
1620 END | 1620 END |
1621 CheckDefFailure(lines, 'E1012:') | 1621 v9.CheckDefFailure(lines, 'E1012:') |
1622 enddef | 1622 enddef |
1623 | 1623 |
1624 def Test_echo_void() | 1624 def Test_echo_void() |
1625 var lines =<< trim END | 1625 var lines =<< trim END |
1626 vim9script | 1626 vim9script |
1627 def NoReturn() | 1627 def NoReturn() |
1628 echo 'nothing' | 1628 echo 'nothing' |
1629 enddef | 1629 enddef |
1630 echo NoReturn() | 1630 echo NoReturn() |
1631 END | 1631 END |
1632 CheckScriptFailure(lines, 'E1186:', 5) | 1632 v9.CheckScriptFailure(lines, 'E1186:', 5) |
1633 | 1633 |
1634 lines =<< trim END | 1634 lines =<< trim END |
1635 vim9script | 1635 vim9script |
1636 def NoReturn() | 1636 def NoReturn() |
1637 echo 'nothing' | 1637 echo 'nothing' |
1639 def Try() | 1639 def Try() |
1640 echo NoReturn() | 1640 echo NoReturn() |
1641 enddef | 1641 enddef |
1642 defcompile | 1642 defcompile |
1643 END | 1643 END |
1644 CheckScriptFailure(lines, 'E1186:', 1) | 1644 v9.CheckScriptFailure(lines, 'E1186:', 1) |
1645 enddef | 1645 enddef |
1646 | 1646 |
1647 def Test_cmdwin_block() | 1647 def Test_cmdwin_block() |
1648 augroup justTesting | 1648 augroup justTesting |
1649 autocmd BufEnter * { | 1649 autocmd BufEnter * { |
1659 | 1659 |
1660 def Test_var_not_cmd() | 1660 def Test_var_not_cmd() |
1661 var lines =<< trim END | 1661 var lines =<< trim END |
1662 g:notexist:cmd | 1662 g:notexist:cmd |
1663 END | 1663 END |
1664 CheckDefAndScriptFailure(lines, ['E488: Trailing characters: :cmd', 'E121: Undefined variable: g:notexist'], 1) | 1664 v9.CheckDefAndScriptFailure(lines, ['E488: Trailing characters: :cmd', 'E121: Undefined variable: g:notexist'], 1) |
1665 | 1665 |
1666 lines =<< trim END | 1666 lines =<< trim END |
1667 g-pat-cmd | 1667 g-pat-cmd |
1668 END | 1668 END |
1669 CheckDefAndScriptFailure(lines, 'E1241:', 1) | 1669 v9.CheckDefAndScriptFailure(lines, 'E1241:', 1) |
1670 lines =<< trim END | 1670 lines =<< trim END |
1671 g.pat.cmd | 1671 g.pat.cmd |
1672 END | 1672 END |
1673 CheckDefAndScriptFailure(lines, ['E1001: Variable not found: g', 'E121: Undefined variable: g'], 1) | 1673 v9.CheckDefAndScriptFailure(lines, ['E1001: Variable not found: g', 'E121: Undefined variable: g'], 1) |
1674 | 1674 |
1675 lines =<< trim END | 1675 lines =<< trim END |
1676 s:notexist:repl | 1676 s:notexist:repl |
1677 END | 1677 END |
1678 CheckDefAndScriptFailure(lines, ['E488: Trailing characters: :repl', 'E121: Undefined variable: s:notexist'], 1) | 1678 v9.CheckDefAndScriptFailure(lines, ['E488: Trailing characters: :repl', 'E121: Undefined variable: s:notexist'], 1) |
1679 | 1679 |
1680 lines =<< trim END | 1680 lines =<< trim END |
1681 s-pat-repl | 1681 s-pat-repl |
1682 END | 1682 END |
1683 CheckDefAndScriptFailure(lines, 'E1241:', 1) | 1683 v9.CheckDefAndScriptFailure(lines, 'E1241:', 1) |
1684 lines =<< trim END | 1684 lines =<< trim END |
1685 s.pat.repl | 1685 s.pat.repl |
1686 END | 1686 END |
1687 CheckDefAndScriptFailure(lines, ['E1001: Variable not found: s', 'E121: Undefined variable: s'], 1) | 1687 v9.CheckDefAndScriptFailure(lines, ['E1001: Variable not found: s', 'E121: Undefined variable: s'], 1) |
1688 | 1688 |
1689 lines =<< trim END | 1689 lines =<< trim END |
1690 w:notexist->len() | 1690 w:notexist->len() |
1691 END | 1691 END |
1692 CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: w:notexist', 1) | 1692 v9.CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: w:notexist', 1) |
1693 | 1693 |
1694 lines =<< trim END | 1694 lines =<< trim END |
1695 b:notexist->len() | 1695 b:notexist->len() |
1696 END | 1696 END |
1697 CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: b:notexist', 1) | 1697 v9.CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: b:notexist', 1) |
1698 | 1698 |
1699 lines =<< trim END | 1699 lines =<< trim END |
1700 t:notexist->len() | 1700 t:notexist->len() |
1701 END | 1701 END |
1702 CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: t:notexist', 1) | 1702 v9.CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: t:notexist', 1) |
1703 enddef | 1703 enddef |
1704 | 1704 |
1705 def Test_no_space_after_command() | 1705 def Test_no_space_after_command() |
1706 var lines =<< trim END | 1706 var lines =<< trim END |
1707 g /pat/cmd | 1707 g /pat/cmd |
1708 END | 1708 END |
1709 CheckDefAndScriptFailure(lines, 'E1242:', 1) | 1709 v9.CheckDefAndScriptFailure(lines, 'E1242:', 1) |
1710 lines =<< trim END | 1710 lines =<< trim END |
1711 g #pat#cmd | 1711 g #pat#cmd |
1712 END | 1712 END |
1713 CheckDefAndScriptFailure(lines, 'E1242:', 1) | 1713 v9.CheckDefAndScriptFailure(lines, 'E1242:', 1) |
1714 lines =<< trim END | 1714 lines =<< trim END |
1715 g#pat#cmd | 1715 g#pat#cmd |
1716 END | 1716 END |
1717 CheckDefAndScriptSuccess(lines) | 1717 v9.CheckDefAndScriptSuccess(lines) |
1718 lines =<< trim END | 1718 lines =<< trim END |
1719 g# pat#cmd | 1719 g# pat#cmd |
1720 END | 1720 END |
1721 CheckDefAndScriptSuccess(lines) | 1721 v9.CheckDefAndScriptSuccess(lines) |
1722 | 1722 |
1723 lines =<< trim END | 1723 lines =<< trim END |
1724 s /pat/repl | 1724 s /pat/repl |
1725 END | 1725 END |
1726 CheckDefAndScriptFailure(lines, 'E1242:', 1) | 1726 v9.CheckDefAndScriptFailure(lines, 'E1242:', 1) |
1727 lines =<< trim END | 1727 lines =<< trim END |
1728 s #pat#repl | 1728 s #pat#repl |
1729 END | 1729 END |
1730 CheckDefAndScriptFailure(lines, 'E1242:', 1) | 1730 v9.CheckDefAndScriptFailure(lines, 'E1242:', 1) |
1731 lines =<< trim END | 1731 lines =<< trim END |
1732 s#pat#repl | 1732 s#pat#repl |
1733 END | 1733 END |
1734 CheckDefExecAndScriptFailure(lines, 'E486:', 1) | 1734 v9.CheckDefExecAndScriptFailure(lines, 'E486:', 1) |
1735 lines =<< trim END | 1735 lines =<< trim END |
1736 s# pat#repl | 1736 s# pat#repl |
1737 END | 1737 END |
1738 CheckDefExecAndScriptFailure(lines, 'E486:', 1) | 1738 v9.CheckDefExecAndScriptFailure(lines, 'E486:', 1) |
1739 enddef | 1739 enddef |
1740 | 1740 |
1741 " Test for the 'previewpopup' option | 1741 " Test for the 'previewpopup' option |
1742 def Test_previewpopup() | 1742 def Test_previewpopup() |
1743 set previewpopup=height:10,width:60 | 1743 set previewpopup=height:10,width:60 |