This commit adds validation logic in compiler to check for max allowed characters per line for scripts. This allows preventing bugs caused by limitation of terminal emulators. Other supporting changes: - Rename/refactor related code for clarity and better maintainability. - Drop `I` prefix from interfaces to align with latest convention. - Refactor CodeValidator to be functional rather than object-oriented for simplicity. - Refactor syntax definition construction to be functional and be part of rule for better separation of concerns. - Refactored validation logic to use an enum-based factory pattern for improved maintainability and scalability.
14 lines
484 B
TypeScript
14 lines
484 B
TypeScript
import { expect } from 'vitest';
|
|
import type { InvalidCodeLine } from '@/application/Parser/Executable/Script/Validation/Analyzers/CodeValidationAnalyzer';
|
|
|
|
export function expectSameInvalidCodeLines(
|
|
expected: readonly InvalidCodeLine[],
|
|
actual: readonly InvalidCodeLine[],
|
|
) {
|
|
expect(sort(expected)).to.deep.equal(sort(actual));
|
|
}
|
|
|
|
function sort(lines: readonly InvalidCodeLine[]) { // To ignore order
|
|
return Array.from(lines).sort((a, b) => a.lineNumber - b.lineNumber);
|
|
}
|