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".
redux
David Majda 9 years ago
parent 7089debae2
commit f866712c90

@ -34,9 +34,8 @@ describe("generated parser behavior", function() {
beforeEach(function() {
this.addMatchers({
toParse: function(input) {
var options = arguments.length > 2 ? arguments[1] : {},
expected = arguments[arguments.length - 1],
toParse: function(input, expected) {
var options = arguments.length > 2 ? arguments[2] : {},
result;
try {
@ -68,11 +67,8 @@ describe("generated parser behavior", function() {
}
},
toFailToParse: function(input) {
var options = arguments.length > 2 ? arguments[1] : {},
details = arguments.length > 1
? arguments[arguments.length - 1]
: undefined,
toFailToParse: function(input, details) {
var options = arguments.length > 2 ? arguments[2] : {},
result;
try {

@ -4,7 +4,7 @@
beforeEach(function() {
this.addMatchers({
toChangeAST: function(grammar) {
toChangeAST: function(grammar, details) {
function matchDetails(value, details) {
function isArray(value) {
return Object.prototype.toString.apply(value) === "[object Array]";
@ -42,8 +42,7 @@ beforeEach(function() {
}
}
var options = arguments.length > 2 ? arguments[1] : {},
details = arguments[arguments.length - 1],
var options = arguments.length > 2 ? arguments[2] : {},
ast = PEG.parser.parse(grammar);
this.actual(ast, options);

@ -13,7 +13,6 @@ describe("compiler pass |removeProxyRules|", function() {
'proxy = proxied',
'proxied = "a"'
].join("\n"),
{ allowedStartRules: ["start"] },
{
rules: [
{
@ -22,7 +21,8 @@ describe("compiler pass |removeProxyRules|", function() {
},
{ name: "proxied" }
]
}
},
{ allowedStartRules: ["start"] }
);
});
});
@ -35,7 +35,6 @@ describe("compiler pass |removeProxyRules|", function() {
'proxy = proxied',
'proxied = "a"'
].join("\n"),
{ allowedStartRules: ["start", "proxy"] },
{
rules: [
{
@ -48,7 +47,8 @@ describe("compiler pass |removeProxyRules|", function() {
},
{ name: "proxied" }
]
}
},
{ allowedStartRules: ["start", "proxy"] }
);
});
});

Loading…
Cancel
Save