Expectation refactoring 1/7: Restructure "literal" expectations

Changes:

  * Rename the "value" property to "text" (because it doesn't contain
    the whole value, which also includes the case sensitivity flag).

  * Add the "ignoreCase" property (which was missing).
redux
David Majda 8 years ago
parent d48983dd6a
commit eda2a34c7f

@ -573,7 +573,8 @@ function generateBytecode(ast) {
expectedIndex = addConst([ expectedIndex = addConst([
'{', '{',
'type: "literal",', 'type: "literal",',
'value: "' + js.stringEscape(node.value) + '",', 'text: "' + js.stringEscape(node.value) + '",',
'ignoreCase: ' + node.ignoreCase + ',',
'description: "' 'description: "'
+ js.stringEscape('"' + literalDescriptionEscape(node.value) + '"') + js.stringEscape('"' + literalDescriptionEscape(node.value) + '"')
+ '"', + '"',

@ -190,7 +190,7 @@ describe("generated parser behavior", function() {
var parser = peg.generate('start = "a"'); var parser = peg.generate('start = "a"');
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [{ type: "literal", value: "a", description: '"a"' }] expected: [{ type: "literal", text: "a", ignoreCase: false, description: '"a"' }]
}); });
}); });
}); });
@ -271,7 +271,7 @@ describe("generated parser behavior", function() {
var parser = peg.generate('start = "a"', options); var parser = peg.generate('start = "a"', options);
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [{ type: "literal", value: "a", description: '"a"' }] expected: [{ type: "literal", text: "a", ignoreCase: false, description: '"a"' }]
}); });
}); });
}); });
@ -932,8 +932,8 @@ describe("generated parser behavior", function() {
expect(parser).toFailToParse("d", { expect(parser).toFailToParse("d", {
expected: [ expected: [
{ type: "literal", value: "a", description: '"a"' }, { type: "literal", text: "a", ignoreCase: false, description: '"a"' },
{ type: "literal", value: "c", description: '"c"' } { type: "literal", text: "c", ignoreCase: false, description: '"c"' }
] ]
}); });
}); });
@ -967,8 +967,8 @@ describe("generated parser behavior", function() {
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [ expected: [
{ type: "literal", value: "a", description: '"a"' }, { type: "literal", text: "a", ignoreCase: false, description: '"a"' },
{ type: "literal", value: "c", description: '"c"' } { type: "literal", text: "c", ignoreCase: false, description: '"c"' }
] ]
}); });
}); });
@ -1331,7 +1331,7 @@ describe("generated parser behavior", function() {
var parser = peg.generate('start = "a" "b" / "a" "c" "d"', options); var parser = peg.generate('start = "a" "b" / "a" "c" "d"', options);
expect(parser).toFailToParse("ace", { expect(parser).toFailToParse("ace", {
expected: [{ type: "literal", value: "d", description: '"d"' }] expected: [{ type: "literal", text: "d", ignoreCase: false, description: '"d"' }]
}); });
}); });
}); });
@ -1349,7 +1349,7 @@ describe("generated parser behavior", function() {
var parser = peg.generate('start = "a"', options); var parser = peg.generate('start = "a"', options);
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [{ type: "literal", value: "a", description: '"a"' }] expected: [{ type: "literal", text: "a", ignoreCase: false, description: '"a"' }]
}); });
}); });
@ -1358,9 +1358,9 @@ describe("generated parser behavior", function() {
expect(parser).toFailToParse("d", { expect(parser).toFailToParse("d", {
expected: [ expected: [
{ type: "literal", value: "a", description: '"a"' }, { type: "literal", text: "a", ignoreCase: false, description: '"a"' },
{ type: "literal", value: "b", description: '"b"' }, { type: "literal", text: "b", ignoreCase: false, description: '"b"' },
{ type: "literal", value: "c", description: '"c"' } { type: "literal", text: "c", ignoreCase: false, description: '"c"' }
] ]
}); });
}); });
@ -1376,7 +1376,7 @@ describe("generated parser behavior", function() {
var parser = peg.generate('start = "a" / "a" / "a"', options); var parser = peg.generate('start = "a" / "a" / "a"', options);
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [{ type: "literal", value: "a", description: '"a"' }] expected: [{ type: "literal", text: "a", ignoreCase: false, description: '"a"' }]
}); });
}); });
@ -1385,9 +1385,9 @@ describe("generated parser behavior", function() {
expect(parser).toFailToParse("d", { expect(parser).toFailToParse("d", {
expected: [ expected: [
{ type: "literal", value: "a", description: '"a"' }, { type: "literal", text: "a", ignoreCase: false, description: '"a"' },
{ type: "literal", value: "b", description: '"b"' }, { type: "literal", text: "b", ignoreCase: false, description: '"b"' },
{ type: "literal", value: "c", description: '"c"' } { type: "literal", text: "c", ignoreCase: false, description: '"c"' }
] ]
}); });
}); });

@ -35,11 +35,11 @@ describe("compiler pass |generateBytecode|", function() {
'c = "c"' 'c = "c"'
].join("\n"), constsDetails([ ].join("\n"), constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }', '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }',
'"b"', '"b"',
'{ type: "literal", value: "b", description: "\\"b\\"" }', '{ type: "literal", text: "b", ignoreCase: false, description: "\\"b\\"" }',
'"c"', '"c"',
'{ type: "literal", value: "c", description: "\\"c\\"" }' '{ type: "literal", text: "c", ignoreCase: false, description: "\\"c\\"" }'
])); ]));
}); });
}); });
@ -69,7 +69,7 @@ describe("compiler pass |generateBytecode|", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'{ type: "other", description: "start" }', '{ type: "other", description: "start" }',
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }' '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }'
])); ]));
}); });
}); });
@ -106,7 +106,7 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }', '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }',
'function() { code }' 'function() { code }'
])); ]));
}); });
@ -129,7 +129,7 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }', '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }',
'function(a) { code }' 'function(a) { code }'
])); ]));
}); });
@ -165,11 +165,11 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }', '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }',
'"b"', '"b"',
'{ type: "literal", value: "b", description: "\\"b\\"" }', '{ type: "literal", text: "b", ignoreCase: false, description: "\\"b\\"" }',
'"c"', '"c"',
'{ type: "literal", value: "c", description: "\\"c\\"" }', '{ type: "literal", text: "c", ignoreCase: false, description: "\\"c\\"" }',
'function(a, b, c) { code }' 'function(a, b, c) { code }'
])); ]));
}); });
@ -205,11 +205,11 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }', '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }',
'"b"', '"b"',
'{ type: "literal", value: "b", description: "\\"b\\"" }', '{ type: "literal", text: "b", ignoreCase: false, description: "\\"b\\"" }',
'"c"', '"c"',
'{ type: "literal", value: "c", description: "\\"c\\"" }' '{ type: "literal", text: "c", ignoreCase: false, description: "\\"c\\"" }'
])); ]));
}); });
}); });
@ -257,7 +257,7 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }' '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }'
])); ]));
}); });
}); });
@ -284,7 +284,7 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }' '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }'
])); ]));
}); });
}); });
@ -304,7 +304,7 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }' '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }'
])); ]));
}); });
}); });
@ -326,7 +326,7 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }' '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }'
])); ]));
}); });
}); });
@ -352,7 +352,7 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }' '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }'
])); ]));
}); });
}); });
@ -429,11 +429,11 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }', '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }',
'"b"', '"b"',
'{ type: "literal", value: "b", description: "\\"b\\"" }', '{ type: "literal", text: "b", ignoreCase: false, description: "\\"b\\"" }',
'"c"', '"c"',
'{ type: "literal", value: "c", description: "\\"c\\"" }', '{ type: "literal", text: "c", ignoreCase: false, description: "\\"c\\"" }',
'function(a, b, c) { code }' 'function(a, b, c) { code }'
])); ]));
}); });
@ -504,11 +504,11 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }', '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }',
'"b"', '"b"',
'{ type: "literal", value: "b", description: "\\"b\\"" }', '{ type: "literal", text: "b", ignoreCase: false, description: "\\"b\\"" }',
'"c"', '"c"',
'{ type: "literal", value: "c", description: "\\"c\\"" }', '{ type: "literal", text: "c", ignoreCase: false, description: "\\"c\\"" }',
'function(a, b, c) { code }' 'function(a, b, c) { code }'
])); ]));
}); });
@ -560,7 +560,7 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "a", description: "\\"a\\"" }' '{ type: "literal", text: "a", ignoreCase: false, description: "\\"a\\"" }'
])); ]));
}); });
}); });
@ -579,7 +579,7 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() { it("defines correct constants", function() {
expect(pass).toChangeAST(grammar, constsDetails([ expect(pass).toChangeAST(grammar, constsDetails([
'"a"', '"a"',
'{ type: "literal", value: "A", description: "\\"A\\"" }' '{ type: "literal", text: "A", ignoreCase: true, description: "\\"A\\"" }'
])); ]));
}); });
}); });

Loading…
Cancel
Save