Jasmine: Convert choice matching tests

This commit is contained in:
David Majda 2012-04-22 16:33:12 +02:00
parent 1b0789fbae
commit f5f40f68d2
2 changed files with 13 additions and 10 deletions

View file

@ -91,6 +91,19 @@ describe("generated parser", function() {
});
});
describe("choice matching", function() {
varyAll(function(options) {
it("matches correctly", function() {
var parser = PEG.buildParser('start = "a" / "b" / "c"', options);
expect(parser).toParse("a", "a");
expect(parser).toParse("b", "b");
expect(parser).toParse("c", "c");
expect(parser).toFailToParse("d");
});
});
});
describe("sequence matching", function() {
varyAll(function(options) {
it("matches empty sequence correctly", function() {

View file

@ -13,16 +13,6 @@ function testWithVaryingTrackLineAndColumn(name, callback) {
);
}
testWithVaryingTrackLineAndColumn("choices", function(options) {
var parser = PEG.buildParser('start = "a" / "b" / "c"', options);
parses(parser, "a", "a");
parses(parser, "b", "b");
parses(parser, "c", "c");
doesNotParse(parser, "");
doesNotParse(parser, "ab");
doesNotParse(parser, "d");
});
testWithVaryingTrackLineAndColumn("initializer", function(options) {
var variableInActionParser = PEG.buildParser(
'{ a = 42; }; start = "a" { return a; }',