Skip to content

nvs lsp-test

nvs lsp-test runs tests of what the language server returns to an editor.

Each test is a case file with the extension .lspt. A case has a document, one request such as completion or hover, and the expected result as text. <|> in the document is the position of the cursor. The command takes case files or directories, and it reads every *.lspt file in a directory. It prints N passed, M failed. The exit status is not zero when a case failed.

The result must be the same as the expected text, byte for byte. Line and column numbers in a result start at 1, and an empty result is written as none.

--coverage prints a table in place of the summary line. The table shows which kinds of syntax each request was tested on.

Good to know: the document in a case often has a syntax error. This is intended, because the code in an editor is unfinished while you type. nvs test is a separate command and has its own count.

Examples

The document a case freezes

<?nvs
// `nvs lsp-test` checks what the language server returns for a document.
// This program is the document part of such a test. You can also run it.
final class Cart
{
public int $items = 0;
public int $cents = 0;
public function summary(): string
{
return Core\Str::format('%d items, %d cents', $this->items, $this->cents);
}
}
var $cart = new Cart();
$cart->items = 3;
$cart->cents = 1250;
// A `completion` test with the cursor after `$cart->` expects `cents`, `items` and `summary`.
// The result has one line for each, sorted by name, with its kind and its type.
echo $cart->summary(), "\n";
Output
3 items, 1250 cents