@@ -1321,7 +1321,7 @@ func Test_using_freed_memory()
13211321endfunc
13221322
13231323func Test_collapse_buffers ()
1324- if ! executable (' cat' )
1324+ if ! executable (' cat' ) || ! has ( ' job ' )
13251325 return
13261326 endif
13271327 sp test_channel.vim
@@ -1335,6 +1335,42 @@ func Test_collapse_buffers()
13351335 bwipe!
13361336endfunc
13371337
1338+ func Test_raw_passes_nul ()
1339+ if ! executable (' cat' ) || ! has (' job' )
1340+ return
1341+ endif
1342+
1343+ " Test lines from the job containing NUL are stored correctly in a buffer.
1344+ new
1345+ call setline (1 , [" asdf\n asdf" , " xxx\n " , " \n yyy" ])
1346+ w ! Xtestread
1347+ bwipe!
1348+ split testout
1349+ 1 ,$delete
1350+ call job_start (' cat Xtestread' , {' out_io' : ' buffer' , ' out_name' : ' testout' })
1351+ call WaitFor (' line("$") > 2' )
1352+ call assert_equal (" asdf\n asdf" , getline (2 ))
1353+ call assert_equal (" xxx\n " , getline (3 ))
1354+ call assert_equal (" \n yyy" , getline (4 ))
1355+
1356+ call delete (' Xtestread' )
1357+ bwipe!
1358+
1359+ " Test lines from a buffer with NUL bytes are written correctly to the job.
1360+ new mybuffer
1361+ call setline (1 , [" asdf\n asdf" , " xxx\n " , " \n yyy" ])
1362+ let g: Ch_job = job_start (' cat' , {' in_io' : ' buffer' , ' in_name' : ' mybuffer' , ' out_io' : ' file' , ' out_name' : ' Xtestwrite' })
1363+ call WaitFor (' "dead" == job_status(g:Ch_job)' )
1364+ bwipe!
1365+ split Xtestwrite
1366+ call assert_equal (" asdf\n asdf" , getline (1 ))
1367+ call assert_equal (" xxx\n " , getline (2 ))
1368+ call assert_equal (" \n yyy" , getline (3 ))
1369+
1370+ call delete (' Xtestwrite' )
1371+ bwipe!
1372+ endfunc
1373+
13381374function Ch_test_close_lambda (port)
13391375 let handle = ch_open (' localhost:' . a: port , s: chopt )
13401376 if ch_status (handle) == " fail"
0 commit comments