comparison src/testdir/test_channel.vim @ 8676:289765409225 v7.4.1627

commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 20 22:16:56 2016 +0100 patch 7.4.1627 Problem: Channel out_cb and err_cb are not tested. Solution: Add a test.
author Christian Brabandt <cb@256bit.org>
date Sun, 20 Mar 2016 22:30:05 +0100
parents 06848fe9c816
children 683b3702970a
comparison
equal deleted inserted replaced
8675:114f60aadff6 8676:289765409225
992 finally 992 finally
993 call job_stop(job) 993 call job_stop(job)
994 endtry 994 endtry
995 endfunc 995 endfunc
996 996
997 func Test_out_cb()
998 if !has('job')
999 return
1000 endif
1001 call ch_log('Test_out_cb()')
1002
1003 let dict = {'thisis': 'dict: '}
1004 func dict.outHandler(chan, msg) dict
1005 let s:outmsg = self.thisis . a:msg
1006 endfunc
1007 func dict.errHandler(chan, msg) dict
1008 let s:errmsg = self.thisis . a:msg
1009 endfunc
1010 let job = job_start(s:python . " test_channel_pipe.py",
1011 \ {'out_cb': dict.outHandler,
1012 \ 'out_mode': 'json',
1013 \ 'err_cb': dict.errHandler,
1014 \ 'err_mode': 'json'})
1015 call assert_equal("run", job_status(job))
1016 try
1017 let s:outmsg = ''
1018 let s:errmsg = ''
1019 call ch_sendraw(job, "echo [0, \"hello\"]\n")
1020 call ch_sendraw(job, "echoerr [0, \"there\"]\n")
1021 call s:waitFor('s:outmsg != ""')
1022 call assert_equal("dict: hello", s:outmsg)
1023 call s:waitFor('s:errmsg != ""')
1024 call assert_equal("dict: there", s:errmsg)
1025 finally
1026 call job_stop(job)
1027 endtry
1028 endfunc
1029
997 """""""""" 1030 """"""""""
998 1031
999 let s:unletResponse = '' 1032 let s:unletResponse = ''
1000 func s:UnletHandler(handle, msg) 1033 func s:UnletHandler(handle, msg)
1001 let s:unletResponse = a:msg 1034 let s:unletResponse = a:msg