mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Allow equals() to receive functions from which it then extracts the code for the message.
This commit is contained in:
parent
566f52201c
commit
66824b780a
1 changed files with 14 additions and 1 deletions
|
@ -1,5 +1,18 @@
|
|||
// Let's be strict
|
||||
equals = strictEqual;
|
||||
|
||||
function equals(actual, expected, message) {
|
||||
if (typeof actual === 'function') {
|
||||
if (!message) {
|
||||
message = actual.toString().match(
|
||||
/^\s*function[^\{]*\{([\s\S]*)\}\s*$/)[1]
|
||||
.replace(/ /g, '')
|
||||
.replace(/^\s+|\s+$/g, '')
|
||||
.replace(/^return /, '');
|
||||
}
|
||||
actual = actual();
|
||||
}
|
||||
return strictEqual(actual, expected, message);
|
||||
}
|
||||
|
||||
function compareNumbers(number1, number2, message) {
|
||||
if (number1 !== 0)
|
||||
|
|
Loading…
Reference in a new issue