comparison src/testdir/test_channel.py @ 8159:d0958e22d9ff v7.4.1373

commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 20 21:39:05 2016 +0100 patch 7.4.1373 Problem: Calling a Vim function over a channel requires turning the arguments into a string. Solution: Add the "call" command. (Damien) Also merge "expr" and "eval" into one.
author Christian Brabandt <cb@256bit.org>
date Sat, 20 Feb 2016 21:45:04 +0100
parents 240deebfadde
children b717dae2f26d
comparison
equal deleted inserted replaced
8158:75ab0b5bb16e 8159:d0958e22d9ff
76 print("sending: {}".format(cmd)) 76 print("sending: {}".format(cmd))
77 self.request.sendall(cmd.encode('utf-8')) 77 self.request.sendall(cmd.encode('utf-8'))
78 response = "ok" 78 response = "ok"
79 elif decoded[1] == 'eval-works': 79 elif decoded[1] == 'eval-works':
80 # Send an eval request. We ignore the response. 80 # Send an eval request. We ignore the response.
81 cmd = '["eval","\\"foo\\" . 123", -1]' 81 cmd = '["expr","\\"foo\\" . 123", -1]'
82 print("sending: {}".format(cmd)) 82 print("sending: {}".format(cmd))
83 self.request.sendall(cmd.encode('utf-8')) 83 self.request.sendall(cmd.encode('utf-8'))
84 response = "ok" 84 response = "ok"
85 elif decoded[1] == 'eval-fails': 85 elif decoded[1] == 'eval-fails':
86 # Send an eval request that will fail. 86 # Send an eval request that will fail.
87 cmd = '["eval","xxx", -2]' 87 cmd = '["expr","xxx", -2]'
88 print("sending: {}".format(cmd)) 88 print("sending: {}".format(cmd))
89 self.request.sendall(cmd.encode('utf-8')) 89 self.request.sendall(cmd.encode('utf-8'))
90 response = "ok" 90 response = "ok"
91 elif decoded[1] == 'eval-error': 91 elif decoded[1] == 'eval-error':
92 # Send an eval request that works but the result can't 92 # Send an eval request that works but the result can't
93 # be encoded. 93 # be encoded.
94 cmd = '["eval","function(\\"tr\\")", -3]' 94 cmd = '["expr","function(\\"tr\\")", -3]'
95 print("sending: {}".format(cmd)) 95 print("sending: {}".format(cmd))
96 self.request.sendall(cmd.encode('utf-8')) 96 self.request.sendall(cmd.encode('utf-8'))
97 response = "ok" 97 response = "ok"
98 elif decoded[1] == 'eval-bad': 98 elif decoded[1] == 'eval-bad':
99 # Send an eval request missing the third argument. 99 # Send an eval request missing the third argument.
100 cmd = '["eval","xxx"]' 100 cmd = '["expr","xxx"]'
101 print("sending: {}".format(cmd)) 101 print("sending: {}".format(cmd))
102 self.request.sendall(cmd.encode('utf-8')) 102 self.request.sendall(cmd.encode('utf-8'))
103 response = "ok" 103 response = "ok"
104 elif decoded[1] == 'an expr': 104 elif decoded[1] == 'an expr':
105 # Send an expr request. 105 # Send an expr request.
106 cmd = '["expr","setline(\\"$\\", [\\"one\\",\\"two\\",\\"three\\"])"]' 106 cmd = '["expr","setline(\\"$\\", [\\"one\\",\\"two\\",\\"three\\"])"]'
107 print("sending: {}".format(cmd))
108 self.request.sendall(cmd.encode('utf-8'))
109 response = "ok"
110 elif decoded[1] == 'call-func':
111 cmd = '["call","MyFunction",[1,2,3], 0]'
107 print("sending: {}".format(cmd)) 112 print("sending: {}".format(cmd))
108 self.request.sendall(cmd.encode('utf-8')) 113 self.request.sendall(cmd.encode('utf-8'))
109 response = "ok" 114 response = "ok"
110 elif decoded[1] == 'redraw': 115 elif decoded[1] == 'redraw':
111 cmd = '["redraw",""]' 116 cmd = '["redraw",""]'
133 elif decoded[1] == 'call me again': 138 elif decoded[1] == 'call me again':
134 cmd = '[0,"we did call you"]' 139 cmd = '[0,"we did call you"]'
135 print("sending: {}".format(cmd)) 140 print("sending: {}".format(cmd))
136 self.request.sendall(cmd.encode('utf-8')) 141 self.request.sendall(cmd.encode('utf-8'))
137 response = "" 142 response = ""
143 elif decoded[1] == 'wait a bit':
144 time.sleep(0.2)
145 response = "waited"
138 elif decoded[1] == '!quit!': 146 elif decoded[1] == '!quit!':
139 # we're done 147 # we're done
140 self.server.shutdown() 148 self.server.shutdown()
141 return 149 return
142 elif decoded[1] == '!crash!': 150 elif decoded[1] == '!crash!':