Skip to content

Commit 9ff9c7b

Browse files
dpellebrammool
authored andcommitted
patch 8.2.3181: Vim9: builtin function test fails without channel feature
Problem: Vim9: builtin function test fails without channel feature. Solution: Add feature checks. (Dominique Pellé, closes #8586) Make feature checks more consistent.
1 parent f648854 commit 9ff9c7b

File tree

2 files changed

+37
-15
lines changed

2 files changed

+37
-15
lines changed

src/testdir/test_vim9_builtin.vim

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,13 @@ def Test_ch_close_in()
398398
enddef
399399

400400
def Test_ch_getjob()
401-
CheckDefAndScriptFailure2(['ch_getjob(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument:')
402-
CheckDefAndScriptFailure2(['ch_getjob({"a": 10})'], 'E1013: Argument 1: type mismatch, expected channel but got dict<number>', 'E731: Using a Dictionary as a String')
403-
assert_equal(0, ch_getjob(test_null_channel()))
401+
if !has('channel')
402+
CheckFeature channel
403+
else
404+
CheckDefAndScriptFailure2(['ch_getjob(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument:')
405+
CheckDefAndScriptFailure2(['ch_getjob({"a": 10})'], 'E1013: Argument 1: type mismatch, expected channel but got dict<number>', 'E731: Using a Dictionary as a String')
406+
assert_equal(0, ch_getjob(test_null_channel()))
407+
endif
404408
enddef
405409

406410
def Test_ch_info()
@@ -1425,17 +1429,27 @@ def Test_items()
14251429
enddef
14261430

14271431
def Test_job_getchannel()
1428-
CheckDefAndScriptFailure2(['job_getchannel("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument')
1429-
assert_fails('job_getchannel(test_null_job())', 'E916: not a valid job')
1432+
if !has('job')
1433+
CheckFeature job
1434+
else
1435+
CheckDefAndScriptFailure2(['job_getchannel("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument')
1436+
assert_fails('job_getchannel(test_null_job())', 'E916: not a valid job')
1437+
endif
14301438
enddef
14311439

14321440
def Test_job_info()
1433-
CheckDefAndScriptFailure2(['job_info("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument')
1434-
assert_fails('job_info(test_null_job())', 'E916: not a valid job')
1441+
if !has('job')
1442+
CheckFeature job
1443+
else
1444+
CheckDefAndScriptFailure2(['job_info("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument')
1445+
assert_fails('job_info(test_null_job())', 'E916: not a valid job')
1446+
endif
14351447
enddef
14361448

14371449
def Test_job_info_return_type()
1438-
if has('job')
1450+
if !has('job')
1451+
CheckFeature job
1452+
else
14391453
job_start(&shell)
14401454
var jobs = job_info()
14411455
assert_equal('list<job>', typename(jobs))
@@ -1445,8 +1459,12 @@ def Test_job_info_return_type()
14451459
enddef
14461460

14471461
def Test_job_status()
1448-
CheckDefAndScriptFailure2(['job_status("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument')
1449-
assert_equal('fail', job_status(test_null_job()))
1462+
if !has('job')
1463+
CheckFeature job
1464+
else
1465+
CheckDefAndScriptFailure2(['job_status("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument')
1466+
assert_equal('fail', job_status(test_null_job()))
1467+
endif
14501468
enddef
14511469

14521470
def Test_js_decode()
@@ -1877,7 +1895,9 @@ def Test_prevnonblank()
18771895
enddef
18781896

18791897
def Test_prompt_getprompt()
1880-
if has('channel')
1898+
if !has('channel')
1899+
CheckFeature channel
1900+
else
18811901
CheckDefFailure(['prompt_getprompt([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>')
18821902
assert_equal('', prompt_getprompt('NonExistingBuf'))
18831903
endif
@@ -2439,7 +2459,7 @@ enddef
24392459

24402460
def Test_spellsuggest()
24412461
if !has('spell')
2442-
MissingFeature 'spell'
2462+
CheckFeature spell
24432463
else
24442464
spellsuggest('marrch', 1, true)->assert_equal(['March'])
24452465
endif
@@ -2496,7 +2516,7 @@ enddef
24962516

24972517
def Run_str2float()
24982518
if !has('float')
2499-
MissingFeature 'float'
2519+
CheckFeature float
25002520
endif
25012521
str2float("1.00")->assert_equal(1.00)
25022522
str2float("2e-2")->assert_equal(0.02)
@@ -2721,7 +2741,7 @@ enddef
27212741

27222742
def Test_term_gettty()
27232743
if !has('terminal')
2724-
MissingFeature 'terminal'
2744+
CheckFeature terminal
27252745
else
27262746
var buf = Run_shell_in_terminal({})
27272747
term_gettty(buf, true)->assert_notequal('')
@@ -2754,7 +2774,7 @@ def Test_term_setrestore()
27542774
enddef
27552775
def Test_term_start()
27562776
if !has('terminal')
2757-
MissingFeature 'terminal'
2777+
CheckFeature terminal
27582778
else
27592779
botright new
27602780
var winnr = winnr()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3181,
758760
/**/
759761
3180,
760762
/**/

0 commit comments

Comments
 (0)