Skip to content

Commit

Permalink
Add test for regexes without capture
Browse files Browse the repository at this point in the history
  • Loading branch information
mwilliamson committed Aug 31, 2013
1 parent c0219ac commit 87160e1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/regex-tokeniser.test.js
Expand Up @@ -52,6 +52,23 @@ exports.tokenValueIsFirstCaptureOfRegex = stringIsTokenisedTo('"a"', [
endToken('"a"')
]);

exports.tokenWithNoCaptureHasUndefinedValue = function(test) {
var expectedTokens = [
new Token("bang", undefined, stringSourceRange("!", 0, 1)),
endToken("!")
];

var rules = [
{
name: "bang",
regex: /!/
}
];
var tokeniser = new RegexTokeniser(rules);
test.deepEqual(expectedTokens, tokeniser.tokenise("!"));
test.done();
};

function endToken(input) {
var source = stringSourceRange(input, input.length, input.length);
return new Token("end", null, source);
Expand Down

0 comments on commit 87160e1

Please sign in to comment.