You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.0 KiB
JavaScript

(function(global) {
global.parses = function(parser, input, expected) {
deepEqual(parser.parse(input), expected);
};
global.doesNotParse = function(parser, input) {
raises(function() { parser.parse(input); }, parser.SyntaxError);
};
global.doesNotParseWithMessage = function(parser, input, message) {
raises(
function() { parser.parse(input); },
function(e) {
return e instanceof parser.SyntaxError && e.message === message;
}
);
};
global.doesNotParseWithPos = function(parser, input, line, column) {
raises(
function() { parser.parse(input); },
function(e) {
return e instanceof parser.SyntaxError
&& e.line === line
&& e.column === column;
}
);
};
global.parserParses = function(input, expected) {
global.parses(PEG.parser, input, expected);
};
global.parserDoesNotParse = function(input) {
global.doesNotParse(PEG.parser, input);
}
global.parserDoesNotParseWithMessage = function(input, message) {
global.doesNotParseWithMessage(PEG.parser, input, message);
}
})(this);