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
73
test-diagnostics.js
Normal file
73
test-diagnostics.js
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* Test file for JavaScript/TypeScript LSP diagnostics
|
||||
* Tests error, warning, info, and hint virtual text colors
|
||||
*/
|
||||
|
||||
// ERROR: Undefined variable
|
||||
console.log(undefinedVariable);
|
||||
|
||||
// ERROR: Undefined function
|
||||
nonexistentFunction();
|
||||
|
||||
// WARNING: Unused variable
|
||||
const unusedVariable = "I'm never used";
|
||||
|
||||
// ERROR: Type error (if using TypeScript or JSDoc)
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {number} age
|
||||
*/
|
||||
function greet(name, age) {
|
||||
console.log(`Hello ${name}, you are ${age}`);
|
||||
}
|
||||
greet("Alice", "not a number"); // Type mismatch
|
||||
|
||||
// WARNING: Unreachable code
|
||||
function earlyReturn() {
|
||||
return "done";
|
||||
console.log("Never executed"); // Unreachable
|
||||
}
|
||||
|
||||
// ERROR: Invalid property access
|
||||
const obj = {};
|
||||
console.log(obj.nonexistent.nested.property);
|
||||
|
||||
// WARNING: Comparison with different types
|
||||
if ("5" == 5) { // Should use ===
|
||||
console.log("loose equality");
|
||||
}
|
||||
|
||||
// ERROR: Missing parameter
|
||||
greet("Bob"); // Missing age parameter
|
||||
|
||||
// INFO: Unnecessary type assertion (TypeScript)
|
||||
const num = 123;
|
||||
const str = String(num); // Could be simplified
|
||||
|
||||
// HINT: Variable can be const instead of let
|
||||
let neverReassigned = "should be const";
|
||||
console.log(neverReassigned);
|
||||
|
||||
// ERROR: Division by zero (some linters catch this)
|
||||
const result = 10 / 0;
|
||||
|
||||
// WARNING: Duplicate case label
|
||||
const value = 1;
|
||||
switch (value) {
|
||||
case 1:
|
||||
console.log("one");
|
||||
break;
|
||||
case 1: // Duplicate case
|
||||
console.log("one again");
|
||||
break;
|
||||
}
|
||||
|
||||
// ERROR: Invalid this context
|
||||
const obj2 = {
|
||||
name: "test",
|
||||
greet: () => {
|
||||
console.log(this.name); // Arrow function doesn't bind this
|
||||
}
|
||||
};
|
||||
|
||||
console.log("JavaScript diagnostic test complete!");
|
||||
Loading…
Add table
Add a link
Reference in a new issue