diff options
Diffstat (limited to 'tests/drivers')
| -rw-r--r-- | tests/drivers/lsp_test.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/drivers/lsp_test.js b/tests/drivers/lsp_test.js index 18d8bf7..0f4abe1 100644 --- a/tests/drivers/lsp_test.js +++ b/tests/drivers/lsp_test.js @@ -250,5 +250,23 @@ check(hcv && hcv.includes('parameter'), 'hover on a use of a parameter named lik hcv = hover(scp, 4, at(scp, 4, 'len')); check(hcv && hcv.includes('the number of items'), 'hover on the built-in still shows its text where no local shadows it', hcv); +// typedefs: the name shows its declaration, at the declaration, at a use in a declaration, and in a block +const tdsrc = 'struct node { int v; node* next; };\n// another name for node*\ntypedef node* link;\ntypedef int(int, int) binop;\nlink head(link n) { return n; }\nint use(string s) {\n\ttypedef int cell;\n\tcell c = 1;\n\tbinop f = 0;\n\treturn c;\n}\n'; +hv = hover(tdsrc, 2, at(tdsrc, 2, 'link')); +check(hv && hv.includes('typedef node* link;') && hv.includes('another name for node*'), 'hover on the name in a typedef shows the typedef and its doc', hv); +hv = hover(tdsrc, 4, at(tdsrc, 4, 'link')); +check(hv && hv.includes('typedef node* link;') && hv.includes('a pointer to `node`'), 'hover on a typedef name used as a type shows the typedef and the type', hv); +hv = hover(tdsrc, 4, at(tdsrc, 4, 'link', 1)); +check(hv && hv.includes('typedef node* link;'), 'hover on a typedef name used as a parameter type shows the typedef', hv); +hv = hover(tdsrc, 3, at(tdsrc, 3, 'binop')); +check(hv && hv.includes('typedef int(int, int) binop;'), 'hover on a function type typedef shows the whole typedef', hv); +hv = hover(tdsrc, 7, at(tdsrc, 7, 'cell')); +check(hv && hv.includes('typedef int cell;'), 'hover on a typedef made in a block shows the typedef', hv); +hv = hover(tdsrc, 5, at(tdsrc, 5, 'string')); +check(hv && hv.includes('char*') && hv.includes('built-in alias'), 'hover on string shows char* and what string is', hv); +hv = hover(tdsrc, 2, 3); +check(hv && hv.includes('typedef T name;') && hv.includes('type name = T;'), 'hover on the typedef keyword explains it', hv); +check(tokens(tdsrc).includes('typedef:keyword'), 'typedef is highlighted as a keyword', tokens(tdsrc)); + console.log(ok + ' lsp checks passed, ' + bad + ' failed'); process.exit(bad ? 1 : 0); |
