@@ -2494,9 +2494,10 @@ func LspTests(port)
24942494
24952495 " Wrong payload notification test
24962496 let g: lspNotif = []
2497- call ch_sendexpr (ch , #{method: ' wrong-payload' , params: {}})
2497+ let r = ch_sendexpr (ch , #{method: ' wrong-payload' , params: {}})
2498+ call assert_equal ({}, r )
24982499 " Send a ping to wait for all the notification messages to arrive
2499- call ch_evalexpr (ch , #{method: ' ping' })
2500+ call assert_equal ( ' alive ' , ch_evalexpr (ch , #{method: ' ping' }).result )
25002501 call assert_equal ([#{jsonrpc: ' 2.0' , result: ' wrong-payload' }], g: lspNotif )
25012502
25022503 " Test for receiving a response with incorrect 'id' and additional
@@ -2516,22 +2517,22 @@ func LspTests(port)
25162517 let g: lspNotif = []
25172518 call ch_sendexpr (ch , #{method: ' simple-notif' , params: [#{a: 10 , b: []}]})
25182519 " Send a ping to wait for all the notification messages to arrive
2519- call ch_evalexpr (ch , #{method: ' ping' })
2520+ call assert_equal ( ' alive ' , ch_evalexpr (ch , #{method: ' ping' }).result )
25202521 call assert_equal ([#{jsonrpc: ' 2.0' , result: ' simple-notif' }], g: lspNotif )
25212522
25222523 " multiple notifications test
25232524 let g: lspNotif = []
25242525 call ch_sendexpr (ch , #{method: ' multi-notif' , params: [#{a: {}, b: {}}]})
25252526 " Send a ping to wait for all the notification messages to arrive
2526- call ch_evalexpr (ch , #{method: ' ping' })
2527+ call assert_equal ( ' alive ' , ch_evalexpr (ch , #{method: ' ping' }).result )
25272528 call assert_equal ([#{jsonrpc: ' 2.0' , result: ' multi-notif1' },
25282529 \ #{jsonrpc: ' 2.0' , result: ' multi-notif2' }], g: lspNotif )
25292530
25302531 " Test for sending a message with an identifier.
25312532 let g: lspNotif = []
25322533 call ch_sendexpr (ch , #{method: ' msg-with-id' , id: 93 , params: #{s: ' str' }})
25332534 " Send a ping to wait for all the notification messages to arrive
2534- call ch_evalexpr (ch , #{method: ' ping' })
2535+ call assert_equal ( ' alive ' , ch_evalexpr (ch , #{method: ' ping' }).result )
25352536 call assert_equal ([#{jsonrpc: ' 2.0' , id: 93 , result: ' msg-with-id' }],
25362537 \ g: lspNotif )
25372538
@@ -2541,16 +2542,17 @@ func LspTests(port)
25412542
25422543 " Test for using a one time callback function to process a response
25432544 let g: lspOtMsgs = []
2544- call ch_sendexpr (ch , #{method: ' msg-specifc-cb' , params: {}},
2545+ let r = ch_sendexpr (ch , #{method: ' msg-specifc-cb' , params: {}},
25452546 \ #{callback: ' LspOtCb' })
2546- call ch_evalexpr (ch , #{method: ' ping' })
2547+ call assert_equal (9 , r .id)
2548+ call assert_equal (' alive' , ch_evalexpr (ch , #{method: ' ping' }).result)
25472549 call assert_equal ([#{id: 9 , jsonrpc: ' 2.0' , result: ' msg-specifc-cb' }],
25482550 \ g: lspOtMsgs )
25492551
25502552 " Test for generating a request message from the other end (server)
25512553 let g: lspNotif = []
25522554 call ch_sendexpr (ch , #{method: ' server-req' , params: #{}})
2553- call ch_evalexpr (ch , #{method: ' ping' })
2555+ call assert_equal ( ' alive ' , ch_evalexpr (ch , #{method: ' ping' }).result )
25542556 call assert_equal ([{' id' : 201 , ' jsonrpc' : ' 2.0' ,
25552557 \ ' result' : {' method' : ' checkhealth' , ' params' : {' a' : 20 }}}],
25562558 \ g: lspNotif )
@@ -2559,7 +2561,7 @@ func LspTests(port)
25592561 let g: lspNotif = []
25602562 call ch_sendexpr (ch , #{method: ' echo' , params: #{s: ' msg-without-id' }})
25612563 " Send a ping to wait for all the notification messages to arrive
2562- call ch_evalexpr (ch , #{method: ' ping' })
2564+ call assert_equal ( ' alive ' , ch_evalexpr (ch , #{method: ' ping' }).result )
25632565 call assert_equal ([#{jsonrpc: ' 2.0' , result:
25642566 \ #{method: ' echo' , jsonrpc: ' 2.0' , params: #{s: ' msg-without-id' }}}],
25652567 \ g: lspNotif )
@@ -2568,7 +2570,7 @@ func LspTests(port)
25682570 let g: lspNotif = []
25692571 call ch_sendexpr (ch , #{method: ' echo' , id: 110 , params: #{s: ' msg-with-id' }})
25702572 " Send a ping to wait for all the notification messages to arrive
2571- call ch_evalexpr (ch , #{method: ' ping' })
2573+ call assert_equal ( ' alive ' , ch_evalexpr (ch , #{method: ' ping' }).result )
25722574 call assert_equal ([#{jsonrpc: ' 2.0' , result:
25732575 \ #{method: ' echo' , jsonrpc: ' 2.0' , id: 110 ,
25742576 \ params: #{s: ' msg-with-id' }}}], g: lspNotif )
@@ -2581,61 +2583,56 @@ func LspTests(port)
25812583 " Test for processing a HTTP header without the Content-Length field
25822584 let resp = ch_evalexpr (ch , #{method: ' hdr-without-len' , params: {}},
25832585 \ #{timeout : 200 })
2584- call assert_equal (' ' , resp)
2586+ call assert_equal ({} , resp)
25852587 " send a ping to make sure communication still works
2586- let resp = ch_evalexpr (ch , #{method: ' ping' })
2587- call assert_equal ({' id' : 16 , ' jsonrpc' : ' 2.0' , ' result' : ' alive' }, resp)
2588+ call assert_equal (' alive' , ch_evalexpr (ch , #{method: ' ping' }).result)
25882589
25892590 " Test for processing a HTTP header with wrong length
25902591 let resp = ch_evalexpr (ch , #{method: ' hdr-with-wrong-len' , params: {}},
25912592 \ #{timeout : 200 })
2592- call assert_equal (' ' , resp)
2593+ call assert_equal ({} , resp)
25932594 " send a ping to make sure communication still works
2594- let resp = ch_evalexpr (ch , #{method: ' ping' })
2595- call assert_equal ({' id' : 18 , ' jsonrpc' : ' 2.0' , ' result' : ' alive' }, resp)
2595+ call assert_equal (' alive' , ch_evalexpr (ch , #{method: ' ping' }).result)
25962596
25972597 " Test for processing a HTTP header with negative length
25982598 let resp = ch_evalexpr (ch , #{method: ' hdr-with-negative-len' , params: {}},
25992599 \ #{timeout : 200 })
2600- call assert_equal (' ' , resp)
2600+ call assert_equal ({} , resp)
26012601 " send a ping to make sure communication still works
2602- let resp = ch_evalexpr (ch , #{method: ' ping' })
2603- call assert_equal ({' id' : 20 , ' jsonrpc' : ' 2.0' , ' result' : ' alive' }, resp)
2602+ call assert_equal (' alive' , ch_evalexpr (ch , #{method: ' ping' }).result)
26042603
26052604 " Test for an empty header
26062605 let resp = ch_evalexpr (ch , #{method: ' empty-header' , params: {}},
26072606 \ #{timeout : 200 })
2608- call assert_equal (' ' , resp)
2607+ call assert_equal ({} , resp)
26092608 " send a ping to make sure communication still works
2610- let resp = ch_evalexpr (ch , #{method: ' ping' })
2611- call assert_equal ({' id' : 22 , ' jsonrpc' : ' 2.0' , ' result' : ' alive' }, resp)
2609+ call assert_equal (' alive' , ch_evalexpr (ch , #{method: ' ping' }).result)
26122610
26132611 " Test for an empty payload
26142612 let resp = ch_evalexpr (ch , #{method: ' empty-payload' , params: {}},
26152613 \ #{timeout : 200 })
2616- call assert_equal (' ' , resp)
2614+ call assert_equal ({} , resp)
26172615 " send a ping to make sure communication still works
2618- let resp = ch_evalexpr (ch , #{method: ' ping' })
2619- call assert_equal ({' id' : 24 , ' jsonrpc' : ' 2.0' , ' result' : ' alive' }, resp)
2616+ call assert_equal (' alive' , ch_evalexpr (ch , #{method: ' ping' }).result)
26202617
26212618 " Test for invoking an unsupported method
26222619 let resp = ch_evalexpr (ch , #{method: ' xyz' , params: {}}, #{timeout : 200 })
2623- call assert_equal (' ' , resp)
2620+ call assert_equal ({} , resp)
26242621
26252622 " Test for sending a message without a callback function. Notification
26262623 " message should be dropped but RPC response should not be dropped.
26272624 call ch_setoptions (ch , #{callback: ' ' })
26282625 let g: lspNotif = []
26292626 call ch_sendexpr (ch , #{method: ' echo' , params: #{s: ' no-callback' }})
26302627 " Send a ping to wait for all the notification messages to arrive
2631- call ch_evalexpr (ch , #{method: ' ping' })
2628+ call assert_equal ( ' alive ' , ch_evalexpr (ch , #{method: ' ping' }).result )
26322629 call assert_equal ([], g: lspNotif )
26332630 " Restore the callback function
26342631 call ch_setoptions (ch , #{callback: ' LspCb' })
26352632 let g: lspNotif = []
26362633 call ch_sendexpr (ch , #{method: ' echo' , params: #{s: ' no-callback' }})
26372634 " Send a ping to wait for all the notification messages to arrive
2638- call ch_evalexpr (ch , #{method: ' ping' })
2635+ call assert_equal ( ' alive ' , ch_evalexpr (ch , #{method: ' ping' }).result )
26392636 call assert_equal ([#{jsonrpc: ' 2.0' , result:
26402637 \ #{method: ' echo' , jsonrpc: ' 2.0' , params: #{s: ' no-callback' }}}],
26412638 \ g: lspNotif )
0 commit comments