From 56c1fad87f95b9d9a65b0283a069cf5d90a2b2bd Mon Sep 17 00:00:00 2001 From: Andreas Louv Date: Mon, 20 Mar 2023 15:00:58 +0100 Subject: [PATCH] Add test to confirm the correct diagnostic is found for "LspDiagCurrent" --- test/tsserver_tests.vim | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/test/tsserver_tests.vim b/test/tsserver_tests.vim index b5ea710..ad08489 100644 --- a/test/tsserver_tests.vim +++ b/test/tsserver_tests.vim @@ -18,11 +18,11 @@ def g:Test_LspDiag() # This tests that two diagnostics can be on the same line var lines: list = [ - 'export obj = {', - ' foo: 1,', - ' bar: 2,', - ' baz: 3', - '}' + ' export obj = {', + ' foo: 1,', + ' bar: 2,', + ' baz: 3', + ' }' ] setline(1, lines) @@ -34,26 +34,39 @@ def g:Test_LspDiag() assert_equal('quickfix', getwinvar(winnr('$'), '&buftype')) assert_equal(bnr, qfl[0].bufnr) assert_equal(2, qfl->len()) - assert_equal([1, 1, 'E'], [qfl[0].lnum, qfl[0].col, qfl[0].type]) - assert_equal([1, 8, 'E'], [qfl[1].lnum, qfl[1].col, qfl[1].type]) + assert_equal([1, 3, 'E'], [qfl[0].lnum, qfl[0].col, qfl[0].type]) + assert_equal([1, 10, 'E'], [qfl[1].lnum, qfl[1].col, qfl[1].type]) close :sleep 100m cursor(5, 1) assert_equal('', execute('LspDiagPrev')) - assert_equal([1, 8], [line('.'), col('.')]) + assert_equal([1, 10], [line('.'), col('.')]) assert_equal('', execute('LspDiagPrev')) - assert_equal([1, 1], [line('.'), col('.')]) + assert_equal([1, 3], [line('.'), col('.')]) var output = execute('LspDiagPrev')->split("\n") assert_equal('Error: No more diagnostics found', output[0]) cursor(5, 1) assert_equal('', execute('LspDiagFirst')) - assert_equal([1, 1], [line('.'), col('.')]) + assert_equal([1, 3], [line('.'), col('.')]) assert_equal('', execute('LspDiagNext')) - assert_equal([1, 8], [line('.'), col('.')]) + assert_equal([1, 10], [line('.'), col('.')]) + + g:LspOptionsSet({showDiagInPopup: false}) + for i in range(1, 3) + cursor(1, i) + output = execute('LspDiagCurrent')->split('\n') + assert_equal('Declaration or statement expected.', output[0]) + endfor + for i in range(4, 16) + cursor(1, i) + output = execute('LspDiagCurrent')->split('\n') + assert_equal('Cannot find name ''obj''.', output[0]) + endfor + g:LspOptionsSet({showDiagInPopup: true}) :%bw! enddef -- 2.48.1