Extend assertion error messages

When invoked without a custom assertion message, `assert.sameValue` and
`assert.notSameValue` automatically create a message that describes the
actual and expected values.

Extend both assertion methods to also include this information in cases
where a custom message has been specified.
This commit is contained in:
Mike Pennisi 2015-04-21 13:15:19 -04:00
parent f1900713aa
commit c91267235c
1 changed files with 12 additions and 2 deletions

View File

@ -25,8 +25,13 @@ assert.sameValue = function (actual, expected, message) {
}
if (message === undefined) {
message = 'Expected SameValue(' + String(actual) + ', ' + String(expected) + ') to be true';
message = '';
} else {
message += ' ';
}
message += 'Expected SameValue(' + String(actual) + ', ' + String(expected) + ') to be true';
$ERROR(message);
};
@ -36,8 +41,13 @@ assert.notSameValue = function (actual, unexpected, message) {
}
if (message === undefined) {
message = 'Expected SameValue(' + String(actual) + ', ' + String(unexpected) + ') to be false';
message = '';
} else {
message += ' ';
}
message += 'Expected SameValue(' + String(actual) + ', ' + String(unexpected) + ') to be false';
$ERROR(message);
};