forked from aniani/vim
		
	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.
This commit is contained in:
		
				
					committed by
					
						 Bram Moolenaar
						Bram Moolenaar
					
				
			
			
				
	
			
			
			
						parent
						
							f6488547e3
						
					
				
				
					commit
					9ff9c7b974
				
			| @@ -398,9 +398,13 @@ def Test_ch_close_in() | |||||||
| enddef | enddef | ||||||
|  |  | ||||||
| def Test_ch_getjob() | def Test_ch_getjob() | ||||||
|  |   if !has('channel') | ||||||
|  |     CheckFeature channel | ||||||
|  |   else | ||||||
|     CheckDefAndScriptFailure2(['ch_getjob(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument:') |     CheckDefAndScriptFailure2(['ch_getjob(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument:') | ||||||
|     CheckDefAndScriptFailure2(['ch_getjob({"a": 10})'], 'E1013: Argument 1: type mismatch, expected channel but got dict<number>', 'E731: Using a Dictionary as a String') |     CheckDefAndScriptFailure2(['ch_getjob({"a": 10})'], 'E1013: Argument 1: type mismatch, expected channel but got dict<number>', 'E731: Using a Dictionary as a String') | ||||||
|     assert_equal(0, ch_getjob(test_null_channel())) |     assert_equal(0, ch_getjob(test_null_channel())) | ||||||
|  |   endif | ||||||
| enddef | enddef | ||||||
|  |  | ||||||
| def Test_ch_info() | def Test_ch_info() | ||||||
| @@ -1425,17 +1429,27 @@ def Test_items() | |||||||
| enddef | enddef | ||||||
|  |  | ||||||
| def Test_job_getchannel() | def Test_job_getchannel() | ||||||
|  |   if !has('job') | ||||||
|  |     CheckFeature job | ||||||
|  |   else | ||||||
|     CheckDefAndScriptFailure2(['job_getchannel("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument') |     CheckDefAndScriptFailure2(['job_getchannel("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument') | ||||||
|     assert_fails('job_getchannel(test_null_job())', 'E916: not a valid job') |     assert_fails('job_getchannel(test_null_job())', 'E916: not a valid job') | ||||||
|  |   endif | ||||||
| enddef | enddef | ||||||
|  |  | ||||||
| def Test_job_info() | def Test_job_info() | ||||||
|  |   if !has('job') | ||||||
|  |     CheckFeature job | ||||||
|  |   else | ||||||
|     CheckDefAndScriptFailure2(['job_info("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument') |     CheckDefAndScriptFailure2(['job_info("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument') | ||||||
|     assert_fails('job_info(test_null_job())', 'E916: not a valid job') |     assert_fails('job_info(test_null_job())', 'E916: not a valid job') | ||||||
|  |   endif | ||||||
| enddef | enddef | ||||||
|  |  | ||||||
| def Test_job_info_return_type() | def Test_job_info_return_type() | ||||||
|   if has('job') |   if !has('job') | ||||||
|  |     CheckFeature job | ||||||
|  |   else | ||||||
|     job_start(&shell) |     job_start(&shell) | ||||||
|     var jobs = job_info() |     var jobs = job_info() | ||||||
|     assert_equal('list<job>', typename(jobs)) |     assert_equal('list<job>', typename(jobs)) | ||||||
| @@ -1445,8 +1459,12 @@ def Test_job_info_return_type() | |||||||
| enddef | enddef | ||||||
|  |  | ||||||
| def Test_job_status() | def Test_job_status() | ||||||
|  |   if !has('job') | ||||||
|  |     CheckFeature job | ||||||
|  |   else | ||||||
|     CheckDefAndScriptFailure2(['job_status("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument') |     CheckDefAndScriptFailure2(['job_status("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument') | ||||||
|     assert_equal('fail', job_status(test_null_job())) |     assert_equal('fail', job_status(test_null_job())) | ||||||
|  |   endif | ||||||
| enddef | enddef | ||||||
|  |  | ||||||
| def Test_js_decode() | def Test_js_decode() | ||||||
| @@ -1877,7 +1895,9 @@ def Test_prevnonblank() | |||||||
| enddef | enddef | ||||||
|  |  | ||||||
| def Test_prompt_getprompt() | def Test_prompt_getprompt() | ||||||
|   if has('channel') |   if !has('channel') | ||||||
|  |     CheckFeature channel | ||||||
|  |   else | ||||||
|     CheckDefFailure(['prompt_getprompt([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>') |     CheckDefFailure(['prompt_getprompt([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>') | ||||||
|     assert_equal('', prompt_getprompt('NonExistingBuf')) |     assert_equal('', prompt_getprompt('NonExistingBuf')) | ||||||
|   endif |   endif | ||||||
| @@ -2439,7 +2459,7 @@ enddef | |||||||
|  |  | ||||||
| def Test_spellsuggest() | def Test_spellsuggest() | ||||||
|   if !has('spell') |   if !has('spell') | ||||||
|     MissingFeature 'spell' |     CheckFeature spell | ||||||
|   else |   else | ||||||
|     spellsuggest('marrch', 1, true)->assert_equal(['March']) |     spellsuggest('marrch', 1, true)->assert_equal(['March']) | ||||||
|   endif |   endif | ||||||
| @@ -2496,7 +2516,7 @@ enddef | |||||||
|  |  | ||||||
| def Run_str2float() | def Run_str2float() | ||||||
|   if !has('float') |   if !has('float') | ||||||
|     MissingFeature 'float' |     CheckFeature float | ||||||
|   endif |   endif | ||||||
|     str2float("1.00")->assert_equal(1.00) |     str2float("1.00")->assert_equal(1.00) | ||||||
|     str2float("2e-2")->assert_equal(0.02) |     str2float("2e-2")->assert_equal(0.02) | ||||||
| @@ -2721,7 +2741,7 @@ enddef | |||||||
|  |  | ||||||
| def Test_term_gettty() | def Test_term_gettty() | ||||||
|   if !has('terminal') |   if !has('terminal') | ||||||
|     MissingFeature 'terminal' |     CheckFeature terminal | ||||||
|   else |   else | ||||||
|     var buf = Run_shell_in_terminal({}) |     var buf = Run_shell_in_terminal({}) | ||||||
|     term_gettty(buf, true)->assert_notequal('') |     term_gettty(buf, true)->assert_notequal('') | ||||||
| @@ -2754,7 +2774,7 @@ def Test_term_setrestore() | |||||||
| enddef | enddef | ||||||
| def Test_term_start() | def Test_term_start() | ||||||
|   if !has('terminal') |   if !has('terminal') | ||||||
|     MissingFeature 'terminal' |     CheckFeature terminal | ||||||
|   else |   else | ||||||
|     botright new |     botright new | ||||||
|     var winnr = winnr() |     var winnr = winnr() | ||||||
|   | |||||||
| @@ -755,6 +755,8 @@ static char *(features[]) = | |||||||
|  |  | ||||||
| static int included_patches[] = | static int included_patches[] = | ||||||
| {   /* Add new patch number below this line */ | {   /* Add new patch number below this line */ | ||||||
|  | /**/ | ||||||
|  |     3181, | ||||||
| /**/ | /**/ | ||||||
|     3180, |     3180, | ||||||
| /**/ | /**/ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user