-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
test_vim9_script.vim
4208 lines (3706 loc) · 90.9 KB
/
test_vim9_script.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" Test various aspects of the Vim9 script language.
source check.vim
source term_util.vim
source view_util.vim
source vim9.vim
source shared.vim
source screendump.vim
def Test_range_only()
new
setline(1, ['blah', 'Blah'])
:/Blah/
assert_equal(2, getcurpos()[1])
bwipe!
# without range commands use current line
new
setline(1, ['one', 'two', 'three'])
:2
print
assert_equal('two', Screenline(&lines))
:3
list
assert_equal('three$', Screenline(&lines))
# missing command does not print the line
var lines =<< trim END
vim9script
:1|
assert_equal('three$', Screenline(&lines))
:|
assert_equal('three$', Screenline(&lines))
END
CheckScriptSuccess(lines)
bwipe!
# won't generate anything
if false
:123
endif
enddef
let g:alist = [7]
let g:astring = 'text'
let g:anumber = 123
def Test_delfunction()
# Check function is defined in script namespace
CheckScriptSuccess([
'vim9script',
'func CheckMe()',
' return 123',
'endfunc',
'assert_equal(123, s:CheckMe())',
])
# Check function in script namespace cannot be deleted
CheckScriptFailure([
'vim9script',
'func DeleteMe1()',
'endfunc',
'delfunction DeleteMe1',
], 'E1084:')
CheckScriptFailure([
'vim9script',
'func DeleteMe2()',
'endfunc',
'def DoThat()',
' delfunction DeleteMe2',
'enddef',
'DoThat()',
], 'E1084:')
CheckScriptFailure([
'vim9script',
'def DeleteMe3()',
'enddef',
'delfunction DeleteMe3',
], 'E1084:')
CheckScriptFailure([
'vim9script',
'def DeleteMe4()',
'enddef',
'def DoThat()',
' delfunction DeleteMe4',
'enddef',
'DoThat()',
], 'E1084:')
# Check that global :def function can be replaced and deleted
var lines =<< trim END
vim9script
def g:Global(): string
return "yes"
enddef
assert_equal("yes", g:Global())
def! g:Global(): string
return "no"
enddef
assert_equal("no", g:Global())
delfunc g:Global
assert_false(exists('*g:Global'))
END
CheckScriptSuccess(lines)
# Check that global function can be replaced by a :def function and deleted
lines =<< trim END
vim9script
func g:Global()
return "yes"
endfunc
assert_equal("yes", g:Global())
def! g:Global(): string
return "no"
enddef
assert_equal("no", g:Global())
delfunc g:Global
assert_false(exists('*g:Global'))
END
CheckScriptSuccess(lines)
# Check that global :def function can be replaced by a function and deleted
lines =<< trim END
vim9script
def g:Global(): string
return "yes"
enddef
assert_equal("yes", g:Global())
func! g:Global()
return "no"
endfunc
assert_equal("no", g:Global())
delfunc g:Global
assert_false(exists('*g:Global'))
END
CheckScriptSuccess(lines)
enddef
def Test_wrong_type()
CheckDefFailure(['var name: list<nothing>'], 'E1010:')
CheckDefFailure(['var name: list<list<nothing>>'], 'E1010:')
CheckDefFailure(['var name: dict<nothing>'], 'E1010:')
CheckDefFailure(['var name: dict<dict<nothing>>'], 'E1010:')
CheckDefFailure(['var name: dict<number'], 'E1009:')
CheckDefFailure(['var name: dict<list<number>'], 'E1009:')
CheckDefFailure(['var name: ally'], 'E1010:')
CheckDefFailure(['var name: bram'], 'E1010:')
CheckDefFailure(['var name: cathy'], 'E1010:')
CheckDefFailure(['var name: dom'], 'E1010:')
CheckDefFailure(['var name: freddy'], 'E1010:')
CheckDefFailure(['var name: john'], 'E1010:')
CheckDefFailure(['var name: larry'], 'E1010:')
CheckDefFailure(['var name: ned'], 'E1010:')
CheckDefFailure(['var name: pam'], 'E1010:')
CheckDefFailure(['var name: sam'], 'E1010:')
CheckDefFailure(['var name: vim'], 'E1010:')
CheckDefFailure(['var Ref: number', 'Ref()'], 'E1085:')
CheckDefFailure(['var Ref: string', 'var res = Ref()'], 'E1085:')
enddef
def Test_script_wrong_type()
var lines =<< trim END
vim9script
var s:dict: dict<string>
s:dict['a'] = ['x']
END
CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got list<string>', 3)
enddef
def Test_const()
CheckDefFailure(['final name = 234', 'name = 99'], 'E1018:')
CheckDefFailure(['final one = 234', 'var one = 99'], 'E1017:')
CheckDefFailure(['final list = [1, 2]', 'var list = [3, 4]'], 'E1017:')
CheckDefFailure(['final two'], 'E1125:')
CheckDefFailure(['final &option'], 'E996:')
var lines =<< trim END
final list = [1, 2, 3]
list[0] = 4
list->assert_equal([4, 2, 3])
const other = [5, 6, 7]
other->assert_equal([5, 6, 7])
var varlist = [7, 8]
const constlist = [1, varlist, 3]
varlist[0] = 77
# TODO: does not work yet
# constlist[1][1] = 88
var cl = constlist[1]
cl[1] = 88
constlist->assert_equal([1, [77, 88], 3])
var vardict = {five: 5, six: 6}
const constdict = {one: 1, two: vardict, three: 3}
vardict['five'] = 55
# TODO: does not work yet
# constdict['two']['six'] = 66
var cd = constdict['two']
cd['six'] = 66
constdict->assert_equal({one: 1, two: {five: 55, six: 66}, three: 3})
END
CheckDefAndScriptSuccess(lines)
enddef
def Test_const_bang()
var lines =<< trim END
const var = 234
var = 99
END
CheckDefExecFailure(lines, 'E1018:', 2)
CheckScriptFailure(['vim9script'] + lines, 'E46:', 3)
lines =<< trim END
const ll = [2, 3, 4]
ll[0] = 99
END
CheckDefExecFailure(lines, 'E1119:', 2)
CheckScriptFailure(['vim9script'] + lines, 'E741:', 3)
lines =<< trim END
const ll = [2, 3, 4]
ll[3] = 99
END
CheckDefExecFailure(lines, 'E1118:', 2)
CheckScriptFailure(['vim9script'] + lines, 'E684:', 3)
lines =<< trim END
const dd = {one: 1, two: 2}
dd["one"] = 99
END
CheckDefExecFailure(lines, 'E1121:', 2)
CheckScriptFailure(['vim9script'] + lines, 'E741:', 3)
lines =<< trim END
const dd = {one: 1, two: 2}
dd["three"] = 99
END
CheckDefExecFailure(lines, 'E1120:')
CheckScriptFailure(['vim9script'] + lines, 'E741:', 3)
enddef
def Test_range_no_colon()
CheckDefFailure(['%s/a/b/'], 'E1050:')
CheckDefFailure(['+ s/a/b/'], 'E1050:')
CheckDefFailure(['- s/a/b/'], 'E1050:')
CheckDefFailure(['. s/a/b/'], 'E1050:')
enddef
def Test_block()
var outer = 1
{
var inner = 2
assert_equal(1, outer)
assert_equal(2, inner)
}
assert_equal(1, outer)
{|echo 'yes'|}
enddef
def Test_block_failure()
CheckDefFailure(['{', 'var inner = 1', '}', 'echo inner'], 'E1001:')
CheckDefFailure(['}'], 'E1025:')
CheckDefFailure(['{', 'echo 1'], 'E1026:')
enddef
def Test_block_local_vars()
var lines =<< trim END
vim9script
v:testing = 1
if true
var text = ['hello']
def SayHello(): list<string>
return text
enddef
def SetText(v: string)
text = [v]
enddef
endif
if true
var text = ['again']
def SayAgain(): list<string>
return text
enddef
endif
# test that the "text" variables are not cleaned up
test_garbagecollect_now()
defcompile
assert_equal(['hello'], SayHello())
assert_equal(['again'], SayAgain())
SetText('foobar')
assert_equal(['foobar'], SayHello())
call writefile(['ok'], 'Xdidit')
qall!
END
# need to execute this with a separate Vim instance to avoid the current
# context gets garbage collected.
writefile(lines, 'Xscript')
RunVim([], [], '-S Xscript')
assert_equal(['ok'], readfile('Xdidit'))
delete('Xscript')
delete('Xdidit')
enddef
def Test_block_local_vars_with_func()
var lines =<< trim END
vim9script
if true
var foo = 'foo'
if true
var bar = 'bar'
def Func(): list<string>
return [foo, bar]
enddef
endif
endif
# function is compiled here, after blocks have finished, can still access
# "foo" and "bar"
assert_equal(['foo', 'bar'], Func())
END
CheckScriptSuccess(lines)
enddef
func g:NoSuchFunc()
echo 'none'
endfunc
def Test_try_catch_throw()
var l = []
try # comment
add(l, '1')
throw 'wrong'
add(l, '2')
catch # comment
add(l, v:exception)
finally # comment
add(l, '3')
endtry # comment
assert_equal(['1', 'wrong', '3'], l)
l = []
try
try
add(l, '1')
throw 'wrong'
add(l, '2')
catch /right/
add(l, v:exception)
endtry
catch /wrong/
add(l, 'caught')
fina
add(l, 'finally')
endtry
assert_equal(['1', 'caught', 'finally'], l)
var n: number
try
n = l[3]
catch /E684:/
n = 99
endtry
assert_equal(99, n)
var done = 'no'
if 0
try | catch | endtry
else
done = 'yes'
endif
assert_equal('yes', done)
done = 'no'
if 1
done = 'yes'
else
try | catch | endtry
done = 'never'
endif
assert_equal('yes', done)
if 1
else
try | catch /pat/ | endtry
try | catch /pat/
endtry
try
catch /pat/ | endtry
try
catch /pat/
endtry
endif
try
# string slice returns a string, not a number
n = g:astring[3]
catch /E1012:/
n = 77
endtry
assert_equal(77, n)
try
n = l[g:astring]
catch /E1012:/
n = 88
endtry
assert_equal(88, n)
try
n = s:does_not_exist
catch /E121:/
n = 111
endtry
assert_equal(111, n)
try
n = g:does_not_exist
catch /E121:/
n = 121
endtry
assert_equal(121, n)
var d = {one: 1}
try
n = d[g:astring]
catch /E716:/
n = 222
endtry
assert_equal(222, n)
try
n = -g:astring
catch /E39:/
n = 233
endtry
assert_equal(233, n)
try
n = +g:astring
catch /E1030:/
n = 244
endtry
assert_equal(244, n)
try
n = +g:alist
catch /E745:/
n = 255
endtry
assert_equal(255, n)
var nd: dict<any>
try
nd = {[g:alist]: 1}
catch /E1105:/
n = 266
endtry
assert_equal(266, n)
try
[n] = [1, 2, 3]
catch /E1093:/
n = 277
endtry
assert_equal(277, n)
try
&ts = g:astring
catch /E1012:/
n = 288
endtry
assert_equal(288, n)
try
&backspace = 'asdf'
catch /E474:/
n = 299
endtry
assert_equal(299, n)
l = [1]
try
l[3] = 3
catch /E684:/
n = 300
endtry
assert_equal(300, n)
try
unlet g:does_not_exist
catch /E108:/
n = 322
endtry
assert_equal(322, n)
try
d = {text: 1, [g:astring]: 2}
catch /E721:/
n = 333
endtry
assert_equal(333, n)
try
l = DeletedFunc()
catch /E933:/
n = 344
endtry
assert_equal(344, n)
try
echo len(v:true)
catch /E701:/
n = 355
endtry
assert_equal(355, n)
var P = function('g:NoSuchFunc')
delfunc g:NoSuchFunc
try
echo P()
catch /E117:/
n = 366
endtry
assert_equal(366, n)
try
echo g:NoSuchFunc()
catch /E117:/
n = 377
endtry
assert_equal(377, n)
try
echo g:alist + 4
catch /E745:/
n = 388
endtry
assert_equal(388, n)
try
echo 4 + g:alist
catch /E745:/
n = 399
endtry
assert_equal(399, n)
try
echo g:alist.member
catch /E715:/
n = 400
endtry
assert_equal(400, n)
try
echo d.member
catch /E716:/
n = 411
endtry
assert_equal(411, n)
var counter = 0
for i in range(4)
try
eval [][0]
catch
endtry
counter += 1
endfor
assert_equal(4, counter)
# return in finally after empty catch
def ReturnInFinally(): number
try
finally
return 4
endtry
return 2
enddef
assert_equal(4, ReturnInFinally())
var lines =<< trim END
vim9script
try
acos('0.5')
->setline(1)
catch
g:caught = v:exception
endtry
END
CheckScriptSuccess(lines)
assert_match('E808: Number or Float required', g:caught)
unlet g:caught
# missing catch and/or finally
lines =<< trim END
vim9script
try
echo 'something'
endtry
END
CheckScriptFailure(lines, 'E1032:')
enddef
def Test_try_in_catch()
var lines =<< trim END
vim9script
var seq = []
def DoIt()
try
seq->add('throw 1')
eval [][0]
seq->add('notreached')
catch
seq->add('catch')
try
seq->add('throw 2')
eval [][0]
seq->add('notreached')
catch /nothing/
seq->add('notreached')
endtry
seq->add('done')
endtry
enddef
DoIt()
assert_equal(['throw 1', 'catch', 'throw 2', 'done'], seq)
END
enddef
def Test_error_in_catch()
var lines =<< trim END
try
eval [][0]
catch /E684:/
eval [][0]
endtry
END
CheckDefExecFailure(lines, 'E684:', 4)
enddef
" :while at the very start of a function that :continue jumps to
def TryContinueFunc()
while g:Count < 2
g:sequence ..= 't'
try
echoerr 'Test'
catch
g:Count += 1
g:sequence ..= 'c'
continue
endtry
g:sequence ..= 'e'
g:Count += 1
endwhile
enddef
def Test_continue_in_try_in_while()
g:Count = 0
g:sequence = ''
TryContinueFunc()
assert_equal('tctc', g:sequence)
unlet g:Count
unlet g:sequence
enddef
def Test_nocatch_return_in_try()
# return in try block returns normally
def ReturnInTry(): string
try
return '"some message"'
catch
endtry
return 'not reached'
enddef
exe 'echoerr ' .. ReturnInTry()
enddef
def Test_cnext_works_in_catch()
var lines =<< trim END
vim9script
au BufEnter * eval 1 + 2
writefile(['text'], 'Xfile1')
writefile(['text'], 'Xfile2')
var items = [
{lnum: 1, filename: 'Xfile1', valid: true},
{lnum: 1, filename: 'Xfile2', valid: true}
]
setqflist([], ' ', {items: items})
cwindow
def CnextOrCfirst()
# if cnext fails, cfirst is used
try
cnext
catch
cfirst
endtry
enddef
CnextOrCfirst()
CnextOrCfirst()
writefile([getqflist({idx: 0}).idx], 'Xresult')
qall
END
writefile(lines, 'XCatchCnext')
RunVim([], [], '--clean -S XCatchCnext')
assert_equal(['1'], readfile('Xresult'))
delete('Xfile1')
delete('Xfile2')
delete('XCatchCnext')
delete('Xresult')
enddef
def Test_throw_skipped()
if 0
throw dontgethere
endif
enddef
def Test_nocatch_throw_silenced()
var lines =<< trim END
vim9script
def Func()
throw 'error'
enddef
silent! Func()
END
writefile(lines, 'XthrowSilenced')
source XthrowSilenced
delete('XthrowSilenced')
enddef
def DeletedFunc(): list<any>
return ['delete me']
enddef
defcompile
delfunc DeletedFunc
def ThrowFromDef()
throw "getout" # comment
enddef
func CatchInFunc()
try
call ThrowFromDef()
catch
let g:thrown_func = v:exception
endtry
endfunc
def CatchInDef()
try
ThrowFromDef()
catch
g:thrown_def = v:exception
endtry
enddef
def ReturnFinally(): string
try
return 'intry'
finall
g:in_finally = 'finally'
endtry
return 'end'
enddef
def Test_try_catch_nested()
CatchInFunc()
assert_equal('getout', g:thrown_func)
CatchInDef()
assert_equal('getout', g:thrown_def)
assert_equal('intry', ReturnFinally())
assert_equal('finally', g:in_finally)
var l = []
try
l->add('1')
throw 'bad'
l->add('x')
catch /bad/
l->add('2')
try
l->add('3')
throw 'one'
l->add('x')
catch /one/
l->add('4')
try
l->add('5')
throw 'more'
l->add('x')
catch /more/
l->add('6')
endtry
endtry
endtry
assert_equal(['1', '2', '3', '4', '5', '6'], l)
l = []
try
try
l->add('1')
throw 'foo'
l->add('x')
catch
l->add('2')
throw 'bar'
l->add('x')
finally
l->add('3')
endtry
l->add('x')
catch /bar/
l->add('4')
endtry
assert_equal(['1', '2', '3', '4'], l)
enddef
def TryOne(): number
try
return 0
catch
endtry
return 0
enddef
def TryTwo(n: number): string
try
var x = {}
catch
endtry
return 'text'
enddef
def Test_try_catch_twice()
assert_equal('text', TryOne()->TryTwo())
enddef
def Test_try_catch_match()
var seq = 'a'
try
throw 'something'
catch /nothing/
seq ..= 'x'
catch /some/
seq ..= 'b'
catch /asdf/
seq ..= 'x'
catch ?a\?sdf?
seq ..= 'y'
finally
seq ..= 'c'
endtry
assert_equal('abc', seq)
enddef
def Test_try_catch_fails()
CheckDefFailure(['catch'], 'E603:')
CheckDefFailure(['try', 'echo 0', 'catch', 'catch'], 'E1033:')
CheckDefFailure(['try', 'echo 0', 'catch /pat'], 'E1067:')
CheckDefFailure(['finally'], 'E606:')
CheckDefFailure(['try', 'echo 0', 'finally', 'echo 1', 'finally'], 'E607:')
CheckDefFailure(['endtry'], 'E602:')
CheckDefFailure(['while 1', 'endtry'], 'E170:')
CheckDefFailure(['for i in range(5)', 'endtry'], 'E170:')
CheckDefFailure(['if 1', 'endtry'], 'E171:')
CheckDefFailure(['try', 'echo 1', 'endtry'], 'E1032:')
CheckDefFailure(['throw'], 'E1143:')
CheckDefFailure(['throw xxx'], 'E1001:')
enddef
def Try_catch_skipped()
var l = []
try
finally
endtry
if 1
else
try
endtry
endif
enddef
" The skipped try/endtry was updating the wrong instruction.
def Test_try_catch_skipped()
var instr = execute('disassemble Try_catch_skipped')
assert_match("NEWLIST size 0\n", instr)
enddef
def Test_throw_vimscript()
# only checks line continuation
var lines =<< trim END
vim9script
try
throw 'one'
.. 'two'
catch
assert_equal('onetwo', v:exception)
endtry
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
@r = ''
def Func()
throw @r
enddef
var result = ''
try
Func()
catch /E1129:/
result = 'caught'
endtry
assert_equal('caught', result)
END
CheckScriptSuccess(lines)
enddef
def Test_error_in_nested_function()
# an error in a nested :function aborts executing in the calling :def function
var lines =<< trim END
vim9script
def Func()
Error()
g:test_var = 1
enddef
func Error() abort
eval [][0]
endfunc
Func()
END
g:test_var = 0
CheckScriptFailure(lines, 'E684:')
assert_equal(0, g:test_var)
enddef
def Test_abort_after_error()
var lines =<< trim END
vim9script
while true
echo notfound
endwhile
g:gotthere = true
END
g:gotthere = false
CheckScriptFailure(lines, 'E121:')
assert_false(g:gotthere)
unlet g:gotthere
enddef
def Test_cexpr_vimscript()
# only checks line continuation
set errorformat=File\ %f\ line\ %l
var lines =<< trim END
vim9script
cexpr 'File'
.. ' someFile' ..
' line 19'
assert_equal(19, getqflist()[0].lnum)
END
CheckScriptSuccess(lines)
set errorformat&
enddef
def Test_statusline_syntax()
# legacy syntax is used for 'statusline'
var lines =<< trim END
vim9script
func g:Status()
return '%{"x" is# "x"}'
endfunc
set laststatus=2 statusline=%!Status()
redrawstatus
set laststatus statusline=
END
CheckScriptSuccess(lines)
enddef