diff options
Diffstat (limited to 'tests/drivers')
| -rw-r--r-- | tests/drivers/cli_help_test.py | 2 | ||||
| -rw-r--r-- | tests/drivers/lsp_test.js | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/tests/drivers/cli_help_test.py b/tests/drivers/cli_help_test.py index 97eebea..1231f74 100644 --- a/tests/drivers/cli_help_test.py +++ b/tests/drivers/cli_help_test.py @@ -14,7 +14,7 @@ commands = [] if args.group in ('binaries', 'all'): commands += [[str(Path(args.bin_dir) / name)] for name in ['zy', 'zym', 'zclsp', 'zc0', 'mkgenome', 'genmap']] if args.group in ('scripts', 'all'): - commands += [['bash', name] for name in ['tinyvm.sh', 'src/tools/zcc', 'src/tools/automap.sh', 'src/tools/findcc.sh', 'src/tools/bootstrap-check.sh', 'src/tools/mklsp.sh', 'src/tools/mklspwasm.sh', 'src/tools/mkvsix.sh', 'src/web/build.sh', 'src/baremetal/run.sh']] + commands += [['bash', name] for name in ['tinyvm.sh', 'src/tools/zcc', 'src/tools/automap.sh', 'src/tools/findcc.sh', 'src/tools/bootstrap-check.sh', 'src/tools/parity.sh', 'src/tools/mklsp.sh', 'src/tools/mklspwasm.sh', 'src/tools/mkvsix.sh', 'src/web/build.sh', 'src/baremetal/run.sh']] if args.group in ('js', 'all'): commands += [['node', name] for name in [str(Path(args.js_dir) / 'tinyvm.js'), 'src/js/mklayout.js', 'src/js/extract_lsp.js']] 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); |
