Add LSP diagnostic test files for multiple languages
Includes test files for Lua, JavaScript, PHP to verify the Paper Tonic Modern colorscheme's diagnostic virtual text colors across different LSPs and their expected diagnostics.
This commit is contained in:
parent
db8d67a6b7
commit
dd8cc0eaf2
4 changed files with 320 additions and 0 deletions
70
test-diagnostics.php
Normal file
70
test-diagnostics.php
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test file for PHP LSP diagnostics
|
||||
* Tests error, warning, info, and hint virtual text colors
|
||||
*
|
||||
* Note: Configure Intelephense to show different diagnostic levels:
|
||||
* - diagnostics.undefinedSymbols = true (errors)
|
||||
* - diagnostics.undefinedVariables = true (warnings)
|
||||
* - diagnostics.unusedSymbols = "hint" (hints)
|
||||
*/
|
||||
|
||||
// Define some valid functions and variables first to avoid cascading errors
|
||||
function validFunction(): void {
|
||||
echo "This is valid\n";
|
||||
}
|
||||
|
||||
$definedVariable = "I exist";
|
||||
|
||||
// ERROR: Undefined function
|
||||
someUndefinedFunction();
|
||||
|
||||
// ERROR: Undefined variable
|
||||
echo $completelyUndefined;
|
||||
|
||||
// WARNING/HINT: Unused variable (depends on Intelephense config)
|
||||
$unused = "Never used anywhere";
|
||||
|
||||
// Valid code to separate errors
|
||||
validFunction();
|
||||
|
||||
// ERROR: Wrong number of arguments
|
||||
function requiresTwoArgs(string $a, string $b): void {
|
||||
echo "$a $b\n";
|
||||
}
|
||||
requiresTwoArgs("only one"); // Missing second argument
|
||||
|
||||
// ERROR: Type mismatch
|
||||
function expectsString(string $param): void {
|
||||
echo $param;
|
||||
}
|
||||
expectsString(123); // Passing int to string parameter
|
||||
|
||||
// WARNING: Variable might not be defined in all code paths
|
||||
if (rand(0, 1)) {
|
||||
$maybeUndefined = "sometimes defined";
|
||||
}
|
||||
// Commenting out to reduce errors: echo $maybeUndefined;
|
||||
|
||||
// Valid usage
|
||||
echo $definedVariable . "\n";
|
||||
|
||||
// ERROR: Calling method on non-object
|
||||
$notAnObject = "string";
|
||||
$notAnObject->someMethod();
|
||||
|
||||
// ERROR: Invalid array access (multiple levels)
|
||||
$emptyArray = [];
|
||||
echo $emptyArray['key']['nested']['deep'];
|
||||
|
||||
// Valid function call
|
||||
requiresTwoArgs("hello", "world");
|
||||
|
||||
// HINT/WARNING: Unreachable code (some configs)
|
||||
function hasDeadCode(): string {
|
||||
return "done";
|
||||
echo "This is unreachable"; // Dead code
|
||||
}
|
||||
|
||||
echo "Test complete!\n";
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue