Behavior specs cleanup: Make |toParse| work without expected value
This means we can assert just "this string parses" and ignore the returned value.
This commit is contained in:
parent
ce91921a1d
commit
2faff0000e
|
@ -38,20 +38,24 @@ describe("generated parser behavior", function() {
|
||||||
try {
|
try {
|
||||||
result = this.actual.parse(input, options);
|
result = this.actual.parse(input, options);
|
||||||
|
|
||||||
this.message = function() {
|
if (arguments.length > 1) {
|
||||||
return "Expected " + jasmine.pp(input) + " "
|
this.message = function() {
|
||||||
+ "with options " + jasmine.pp(options) + " "
|
return "Expected " + jasmine.pp(input) + " "
|
||||||
+ (this.isNot ? "not " : "")
|
+ "with options " + jasmine.pp(options) + " "
|
||||||
+ "to parse as " + jasmine.pp(expected) + ", "
|
+ (this.isNot ? "not " : "")
|
||||||
+ "but it parsed as " + jasmine.pp(result) + ".";
|
+ "to parse as " + jasmine.pp(expected) + ", "
|
||||||
};
|
+ "but it parsed as " + jasmine.pp(result) + ".";
|
||||||
|
};
|
||||||
|
|
||||||
return this.env.equals_(result, expected);
|
return this.env.equals_(result, expected);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.message = function() {
|
this.message = function() {
|
||||||
return "Expected " + jasmine.pp(input) + " "
|
return "Expected " + jasmine.pp(input) + " "
|
||||||
+ "with options " + jasmine.pp(options) + " "
|
+ "with options " + jasmine.pp(options) + " "
|
||||||
+ "to parse as " + jasmine.pp(expected) + ", "
|
+ "to parse" + (arguments.length > 1 ? " as " + jasmine.pp(expected) : "") + ", "
|
||||||
+ "but it failed to parse with message "
|
+ "but it failed to parse with message "
|
||||||
+ jasmine.pp(e.message) + ".";
|
+ jasmine.pp(e.message) + ".";
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue