Commit 6c726eeb 6c726eebedd4a8cd768c29420338c6bfa6009247 by Nicolas Perriault

updated assertion processing system

1 parent 37cbe2c3
......@@ -82,6 +82,7 @@ var Tester = function Tester(casper, options) {
// special printing
switch (failure.type) {
case 'assertEquals':
case 'assertEvalEquals':
this.comment(' got: ' + utils.serialize(failure.values.subject));
this.comment(' expected: ' + utils.serialize(failure.values.expected));
break;
......@@ -163,9 +164,20 @@ var Tester = function Tester(casper, options) {
* @param Function fn A function to be evaluated in remote DOM
* @param String message Test description
* @param Object params Object containing the parameters to inject into the function (optional)
* @param Object|null context Assertion context object (Optional)
*/
this.assertEval = function assertEval(fn, message, params, context) {
return this.assert(casper.evaluate(fn, params), message, context);
this.assertEval = this.assertEvaluate = function assertEval(fn, message, params, context) {
return this.processAssertionResult(utils.mergeObjects({
success: casper.evaluate(fn, params),
type: "assertEval",
details: "function didn't evaluate to true",
message: message,
file: this.currentTestFile,
values: {
fn: fn,
params: params
}
}, context || {}));
};
/**
......@@ -174,11 +186,22 @@ var Tester = function Tester(casper, options) {
*
* @param Function fn The function to be evaluated in remote DOM
* @param Boolean expected The expected value
* @param String message Test description
* @param Object params Object containing the parameters to inject into the function (optional)
* @param String|null message Test description
* @param Object|null params Object containing the parameters to inject into the function (optional)
* @param Object|null context Assertion context object (Optional)
*/
this.assertEvalEquals = this.assertEvalEqual = function assertEvalEquals(fn, expected, message, context) {
return this.assertEquals(casper.evaluate(fn, context), expected, message);
this.assertEvalEquals = this.assertEvalEqual = function assertEvalEquals(fn, expected, message, params, context) {
return this.processAssertionResult(utils.mergeObjects({
success: this.testEquals(casper.evaluate(fn, params), expected),
type: "assertEvalEquals",
details: f("test failed; expected: %s; got: %s", expected, subject),
message: message,
file: this.currentTestFile,
values: {
subject: subject,
expected: expected
}
}, context || {}));
};
/**
......