win: fix incomplete VSCEIP, location scripts
This commit improves the validation logic in parser, corrects Windows collection files to adhere to expected structure. This validation helps catch errors that previously led to incomplete generated code in scripts for disabling VSCEIP and location settings. Changes: - Add type validation for function call structures in the parser/compiler. This helps prevent runtime errors by ensuring that only correctly structured data is processed. - Fix scripts in the Windows collection that previoulsy had incomplete `code` or `revertCode` values. These corrections ensure that the scripts function as intended. - Refactor related logic within the compiler/parser to improve testability and maintainability.
This commit is contained in:
30
tests/unit/shared/Stubs/FunctionCallsParserStub.ts
Normal file
30
tests/unit/shared/Stubs/FunctionCallsParserStub.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import type { FunctionCall } from '@/application/Parser/Executable/Script/Compiler/Function/Call/FunctionCall';
|
||||
import type { FunctionCallsParser } from '@/application/Parser/Executable/Script/Compiler/Function/Call/FunctionCallsParser';
|
||||
import type { FunctionCallsData } from '@/application/collections/';
|
||||
import { FunctionCallStub } from './FunctionCallStub';
|
||||
|
||||
export function createFunctionCallsParserStub() {
|
||||
const setupResults = new Map<FunctionCallsData, FunctionCall[]>();
|
||||
const parser: FunctionCallsParser = (rawData) => {
|
||||
if (setupResults.size === 0) {
|
||||
return [
|
||||
new FunctionCallStub().withFunctionName('function created by parser stub'),
|
||||
];
|
||||
}
|
||||
const setupResult = setupResults.get(rawData);
|
||||
if (setupResult === undefined) {
|
||||
throw new Error(`Stub error: Expected pre-configured input data was not found.\n
|
||||
Received input: ${JSON.stringify(rawData, null, 2)}\n
|
||||
Number of configurations available: ${setupResults.size}\n
|
||||
Available configurations: ${JSON.stringify([...setupResults.keys()].map((key) => JSON.stringify(key, null, 2)), null, 2)}`);
|
||||
}
|
||||
return setupResult;
|
||||
};
|
||||
const setup = (rawData: FunctionCallsData, parsedData: FunctionCall[]) => {
|
||||
setupResults.set(rawData, parsedData);
|
||||
};
|
||||
return {
|
||||
parser,
|
||||
setup,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user