Specs cleanup: Small description cleanups/fixes
This commit is contained in:
parent
cc8edd8892
commit
84473db3ce
|
@ -26,7 +26,7 @@ describe("generated parser API", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when |startRule| is set to an allowed rule", function() {
|
describe("when |startRule| is set to an allowed rule", function() {
|
||||||
it("starts parsing from the specified rule", function() {
|
it("starts parsing from specified rule", function() {
|
||||||
expect(parser.parse("x", { startRule: "b" })).toBe("b");
|
expect(parser.parse("x", { startRule: "b" })).toBe("b");
|
||||||
expect(parser.parse("x", { startRule: "c" })).toBe("c");
|
expect(parser.parse("x", { startRule: "c" })).toBe("c");
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
describe("PEG.js API", function() {
|
describe("PEG.js API", function() {
|
||||||
describe("buildParser", function() {
|
describe("buildParser", function() {
|
||||||
it("builds parsers", function() {
|
it("builds a parser", function() {
|
||||||
var parser = PEG.buildParser('start = "a"');
|
var parser = PEG.buildParser('start = "a"');
|
||||||
|
|
||||||
expect(typeof parser).toBe("object");
|
expect(typeof parser).toBe("object");
|
||||||
|
@ -29,7 +29,7 @@ describe("PEG.js API", function() {
|
||||||
|
|
||||||
describe("when optimizing for parsing speed", function() {
|
describe("when optimizing for parsing speed", function() {
|
||||||
describe("when |allowedStartRules| is not set", function() {
|
describe("when |allowedStartRules| is not set", function() {
|
||||||
it("the generated parser can start only from the first rule", function() {
|
it("generated parser can start only from the first rule", function() {
|
||||||
var parser = PEG.buildParser(grammar, { optimize: "speed" });
|
var parser = PEG.buildParser(grammar, { optimize: "speed" });
|
||||||
|
|
||||||
expect(parser.parse("x", { startRule: "a" })).toBe("x");
|
expect(parser.parse("x", { startRule: "a" })).toBe("x");
|
||||||
|
@ -43,7 +43,7 @@ describe("PEG.js API", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when |allowedStartRules| is set", function() {
|
describe("when |allowedStartRules| is set", function() {
|
||||||
it("the generated parser can start only from specified rules", function() {
|
it("generated parser can start only from specified rules", function() {
|
||||||
var parser = PEG.buildParser(grammar, {
|
var parser = PEG.buildParser(grammar, {
|
||||||
optimize: "speed",
|
optimize: "speed",
|
||||||
allowedStartRules: ["b", "c"]
|
allowedStartRules: ["b", "c"]
|
||||||
|
@ -60,7 +60,7 @@ describe("PEG.js API", function() {
|
||||||
|
|
||||||
describe("when optimizing for code size", function() {
|
describe("when optimizing for code size", function() {
|
||||||
describe("when |allowedStartRules| is not set", function() {
|
describe("when |allowedStartRules| is not set", function() {
|
||||||
it("the generated parser can start only from the first rule", function() {
|
it("generated parser can start only from the first rule", function() {
|
||||||
var parser = PEG.buildParser(grammar, { optimize: "size" });
|
var parser = PEG.buildParser(grammar, { optimize: "size" });
|
||||||
|
|
||||||
expect(parser.parse("x", { startRule: "a" })).toBe("x");
|
expect(parser.parse("x", { startRule: "a" })).toBe("x");
|
||||||
|
@ -74,7 +74,7 @@ describe("PEG.js API", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when |allowedStartRules| is set", function() {
|
describe("when |allowedStartRules| is set", function() {
|
||||||
it("the generated parser can start only from specified rules", function() {
|
it("generated parser can start only from specified rules", function() {
|
||||||
var parser = PEG.buildParser(grammar, {
|
var parser = PEG.buildParser(grammar, {
|
||||||
optimize: "size",
|
optimize: "size",
|
||||||
allowedStartRules: ["b", "c"]
|
allowedStartRules: ["b", "c"]
|
||||||
|
@ -98,7 +98,7 @@ describe("PEG.js API", function() {
|
||||||
].join("\n");
|
].join("\n");
|
||||||
|
|
||||||
describe("when |cache| is not set", function() {
|
describe("when |cache| is not set", function() {
|
||||||
it("the generated parser doesn't cache intermediate parse results", function() {
|
it("generated parser doesn't cache intermediate parse results", function() {
|
||||||
var parser = PEG.buildParser(grammar);
|
var parser = PEG.buildParser(grammar);
|
||||||
|
|
||||||
expect(parser.parse("ac")).toBe(2);
|
expect(parser.parse("ac")).toBe(2);
|
||||||
|
@ -106,7 +106,7 @@ describe("PEG.js API", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when |cache| is set to |false|", function() {
|
describe("when |cache| is set to |false|", function() {
|
||||||
it("the generated parser doesn't cache intermediate parse results", function() {
|
it("generated parser doesn't cache intermediate parse results", function() {
|
||||||
var parser = PEG.buildParser(grammar, { cache: false });
|
var parser = PEG.buildParser(grammar, { cache: false });
|
||||||
|
|
||||||
expect(parser.parse("ac")).toBe(2);
|
expect(parser.parse("ac")).toBe(2);
|
||||||
|
@ -114,7 +114,7 @@ describe("PEG.js API", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when |cache| is set to |true|", function() {
|
describe("when |cache| is set to |true|", function() {
|
||||||
it("the generated parser caches intermediate parse results", function() {
|
it("generated parser caches intermediate parse results", function() {
|
||||||
var parser = PEG.buildParser(grammar, { cache: true });
|
var parser = PEG.buildParser(grammar, { cache: true });
|
||||||
|
|
||||||
expect(parser.parse("ac")).toBe(1);
|
expect(parser.parse("ac")).toBe(1);
|
||||||
|
@ -131,7 +131,7 @@ describe("PEG.js API", function() {
|
||||||
var grammar = 'start = "a"';
|
var grammar = 'start = "a"';
|
||||||
|
|
||||||
describe("when |output| is not set", function() {
|
describe("when |output| is not set", function() {
|
||||||
it("defaults to \"parser\"", function() {
|
it("returns generated parser object", function() {
|
||||||
var parser = PEG.buildParser(grammar);
|
var parser = PEG.buildParser(grammar);
|
||||||
|
|
||||||
expect(typeof parser).toBe("object");
|
expect(typeof parser).toBe("object");
|
||||||
|
|
|
@ -49,7 +49,7 @@ describe("plugin API", function() {
|
||||||
expect(pluginsUsed).toEqual([true, true, true]);
|
expect(pluginsUsed).toEqual([true, true, true]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("receives the configuration", function() {
|
it("receives configuration", function() {
|
||||||
var plugin = {
|
var plugin = {
|
||||||
use: function(config, options) {
|
use: function(config, options) {
|
||||||
var i;
|
var i;
|
||||||
|
@ -81,7 +81,7 @@ describe("plugin API", function() {
|
||||||
PEG.buildParser(grammar, { plugins: [plugin] });
|
PEG.buildParser(grammar, { plugins: [plugin] });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("receives the options", function() {
|
it("receives options", function() {
|
||||||
var buildParserOptions = { foo: 42 },
|
var buildParserOptions = { foo: 42 },
|
||||||
plugin = {
|
plugin = {
|
||||||
use: function(config, options) {
|
use: function(config, options) {
|
||||||
|
@ -92,7 +92,7 @@ describe("plugin API", function() {
|
||||||
PEG.buildParser(grammar, buildParserOptions);
|
PEG.buildParser(grammar, buildParserOptions);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can replace the parser", function() {
|
it("can replace parser", function() {
|
||||||
var plugin = {
|
var plugin = {
|
||||||
use: function(config, options) {
|
use: function(config, options) {
|
||||||
var parser = PEG.buildParser([
|
var parser = PEG.buildParser([
|
||||||
|
@ -132,7 +132,7 @@ describe("plugin API", function() {
|
||||||
expect(parser.parse("a")).toBe(42);
|
expect(parser.parse("a")).toBe(42);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can change the options", function() {
|
it("can change options", function() {
|
||||||
var grammar = [
|
var grammar = [
|
||||||
'a = "x"',
|
'a = "x"',
|
||||||
'b = "x"',
|
'b = "x"',
|
||||||
|
|
Loading…
Reference in a new issue