2015-06-08 20:21:19 +02:00
|
|
|
"use strict";
|
|
|
|
|
2016-12-08 08:59:04 +01:00
|
|
|
let chai = require("chai");
|
|
|
|
let helpers = require("./helpers");
|
2016-12-16 13:21:48 +01:00
|
|
|
let pass = require("../../../../lib/compiler/passes/remove-proxy-rules");
|
2016-09-08 13:29:06 +02:00
|
|
|
|
2016-12-08 08:59:04 +01:00
|
|
|
chai.use(helpers);
|
|
|
|
|
|
|
|
let expect = chai.expect;
|
|
|
|
|
2012-04-30 19:51:05 +02:00
|
|
|
describe("compiler pass |removeProxyRules|", function() {
|
2014-06-07 09:11:00 +02:00
|
|
|
describe("when a proxy rule isn't listed in |allowedStartRules|", function() {
|
|
|
|
it("updates references and removes it", function() {
|
2016-12-08 08:59:04 +01:00
|
|
|
expect(pass).to.changeAST(
|
2014-06-07 09:11:00 +02:00
|
|
|
[
|
2016-09-21 15:06:56 +02:00
|
|
|
"start = proxy",
|
|
|
|
"proxy = proxied",
|
|
|
|
"proxied = 'a'"
|
2014-06-07 09:11:00 +02:00
|
|
|
].join("\n"),
|
|
|
|
{
|
|
|
|
rules: [
|
|
|
|
{
|
2016-09-22 05:25:09 +02:00
|
|
|
name: "start",
|
2014-06-07 09:11:00 +02:00
|
|
|
expression: { type: "rule_ref", name: "proxied" }
|
|
|
|
},
|
|
|
|
{ name: "proxied" }
|
|
|
|
]
|
Regularize Jasmine custom matcher signatures
The "toParse" matcher in generated-parser-behavior.spec.js effectively
had these signatures:
toParse(input)
toParse(input, expected)
toParse(input, options, expected)
This commit regularizes them to:
toParse(input)
toParse(input, expected)
toParse(input, expected, options)
Similarly, the "toFailToParse" matcher in
generated-parser-behavior.spec.js effectively had these signatures:
toFailToParse(input)
toFailToParse(input, details)
toFailToParse(input, options, details)
This commit regularizes them to:
toFailToParse(input)
toFailToParse(input, details)
toFailToParse(input, details, options)
Finally, the "toChangeAST" matcher in helpers.js effectively had these
signatures:
toChangeAST(grammar, details)
toChangeAST(grammar, options, details)
This commit regularizes them to:
toChangeAST(grammar, details)
toChangeAST(grammar, details, options)
The overall purpose of these changes is to avoid different parameters
appearing at the same position, which is hard to manage without using
"arguments".
2016-03-18 15:27:51 +01:00
|
|
|
},
|
|
|
|
{ allowedStartRules: ["start"] }
|
2014-06-07 09:11:00 +02:00
|
|
|
);
|
2012-04-30 19:51:05 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-06-07 09:11:00 +02:00
|
|
|
describe("when a proxy rule is listed in |allowedStartRules|", function() {
|
|
|
|
it("updates references but doesn't remove it", function() {
|
2016-12-08 08:59:04 +01:00
|
|
|
expect(pass).to.changeAST(
|
2014-06-07 09:11:00 +02:00
|
|
|
[
|
2016-09-21 15:06:56 +02:00
|
|
|
"start = proxy",
|
|
|
|
"proxy = proxied",
|
|
|
|
"proxied = 'a'"
|
2014-06-07 09:11:00 +02:00
|
|
|
].join("\n"),
|
|
|
|
{
|
|
|
|
rules: [
|
|
|
|
{
|
2016-09-22 05:25:09 +02:00
|
|
|
name: "start",
|
2014-06-07 09:11:00 +02:00
|
|
|
expression: { type: "rule_ref", name: "proxied" }
|
|
|
|
},
|
|
|
|
{
|
2016-09-22 05:25:09 +02:00
|
|
|
name: "proxy",
|
2014-06-07 09:11:00 +02:00
|
|
|
expression: { type: "rule_ref", name: "proxied" }
|
|
|
|
},
|
|
|
|
{ name: "proxied" }
|
|
|
|
]
|
Regularize Jasmine custom matcher signatures
The "toParse" matcher in generated-parser-behavior.spec.js effectively
had these signatures:
toParse(input)
toParse(input, expected)
toParse(input, options, expected)
This commit regularizes them to:
toParse(input)
toParse(input, expected)
toParse(input, expected, options)
Similarly, the "toFailToParse" matcher in
generated-parser-behavior.spec.js effectively had these signatures:
toFailToParse(input)
toFailToParse(input, details)
toFailToParse(input, options, details)
This commit regularizes them to:
toFailToParse(input)
toFailToParse(input, details)
toFailToParse(input, details, options)
Finally, the "toChangeAST" matcher in helpers.js effectively had these
signatures:
toChangeAST(grammar, details)
toChangeAST(grammar, options, details)
This commit regularizes them to:
toChangeAST(grammar, details)
toChangeAST(grammar, details, options)
The overall purpose of these changes is to avoid different parameters
appearing at the same position, which is hard to manage without using
"arguments".
2016-03-18 15:27:51 +01:00
|
|
|
},
|
|
|
|
{ allowedStartRules: ["start", "proxy"] }
|
2014-06-07 09:11:00 +02:00
|
|
|
);
|
|
|
|
});
|
2013-01-06 10:16:17 +01:00
|
|
|
});
|
2012-04-30 19:51:05 +02:00
|
|
|
});
|