diff options
Diffstat (limited to 'tests/drivers/lsp_vm.js')
| -rw-r--r-- | tests/drivers/lsp_vm.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/drivers/lsp_vm.js b/tests/drivers/lsp_vm.js index 24c1a5b..e1f5d7a 100644 --- a/tests/drivers/lsp_vm.js +++ b/tests/drivers/lsp_vm.js @@ -79,6 +79,20 @@ const diagsOf = (s, uri) => s.notes.filter(m => m.method === 'textDocument/publi const h2 = s2.replies[6]; check(h2 && h2.result && /packed documentation/.test(h2.result.contents.value), 'hover shows the docs of a compiler name', h2); } +// definition navigation returns the embedded runtime source through the same vm host. +{ + const src = 'include rt; fn main() { return rt.s_to_n(b"42"); }\n'; + const s = session([['file:///nav.zc', src]]); + const at = src.indexOf('s_to_n'), before = src.slice(0, at); + s.send({ jsonrpc: '2.0', id: 7, method: 'textDocument/definition', params: { textDocument: { uri: 'file:///nav.zc' }, position: { line: before.split('\n').length - 1, character: before.length - before.lastIndexOf('\n') - 1 } } }); + s.send({ jsonrpc: '2.0', id: 8, method: 'zc/source', params: { path: '/rt.zc' } }); + s.send({ jsonrpc: '2.0', method: 'exit' }); + const loc = s.replies[7] && s.replies[7].result && s.replies[7].result[0]; + check(loc && loc.uri === 'tinyvm:/rt.zc', 's_to_n opens the embedded runtime source', loc); + const source = s.replies[8] && s.replies[8].result; + const line = source && loc && source.split('\n')[loc.range.start.line]; + check(line && line.slice(loc.range.start.character, loc.range.end.character) === 's_to_n' && source === fs.readFileSync(path.join(__dirname, '..', '..', 'src', 'runtime', 'rt.zc'), 'utf8'), 'the virtual runtime source matches its declaration'); +} // a document that is bigger than one feed: the input is split and comes out whole { let big = 'int main() {\n'; |
