meld-spec
Version:
Specification for the Meld scripting language
39 lines (38 loc) • 997 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MockParser = void 0;
/**
* Mock parser implementation for testing
* Returns a predefined set of nodes or throws errors based on test requirements
*/
class MockParser {
constructor() {
this.expectedNodes = [];
this.shouldThrow = false;
this.errorMessage = '';
}
/**
* Configure the mock parser to return specific nodes
*/
setExpectedNodes(nodes) {
this.expectedNodes = nodes;
this.shouldThrow = false;
}
/**
* Configure the mock parser to throw an error
*/
setError(message) {
this.shouldThrow = true;
this.errorMessage = message;
}
/**
* Parse implementation that returns configured nodes or throws
*/
parse(input) {
if (this.shouldThrow) {
throw new Error(this.errorMessage);
}
return this.expectedNodes;
}
}
exports.MockParser = MockParser;