| 90 | |
| 91 | // Override equals to convert functions to message and execute them as tests() |
| 92 | var equals = function(actual, expected, message, options) { |
| 93 | // Allow the use of functions for actual, which will get called and their |
| 94 | // source content extracted for readable reports. |
| 95 | if (typeof actual === 'function') { |
| 96 | if (!message) |
| 97 | message = getFunctionMessage(actual); |
| 98 | actual = actual(); |
| 99 | } |
| 100 | // Get the comparator based on the expected value's type only and ignore the |
| 101 | // actual value's type. |
| 102 | var type = typeof expected, |
| 103 | cls; |
| 104 | type = expected === null && 'Null' |
| 105 | || type === 'number' && 'Number' |
| 106 | || type === 'boolean' && 'Boolean' |
| 107 | || type === 'undefined' && 'Undefined' |
| 108 | || Array.isArray(expected) && 'Array' |
| 109 | || expected instanceof window.Element && 'Element' // DOM Elements |
| 110 | || (cls = expected && expected._class) // check _class 2nd last |
| 111 | || type === 'object' && 'Object'; // Object as catch-all |
| 112 | var comparator = type && comparators[type]; |
| 113 | if (!message) { |
| 114 | message = type ? type.toLowerCase() : 'value'; |
| 115 | } |
| 116 | if (comparator) { |
| 117 | comparator(actual, expected, message, options); |
| 118 | } else if (expected && expected.equals) { |
| 119 | // Fall back to equals |
| 120 | QUnit.push(expected.equals(actual), actual, expected, message); |
| 121 | } else { |
| 122 | // Finally perform a strict compare |
| 123 | QUnit.push(actual === expected, actual, expected, message); |
| 124 | } |
| 125 | if (options && options.cloned && cls) { |
| 126 | var identical = identicalAfterCloning[cls]; |
| 127 | QUnit.push(identical ? actual === expected : actual !== expected, |
| 128 | actual, identical ? expected : 'not ' + expected, |
| 129 | message + ': identical after cloning'); |
| 130 | } |
| 131 | }; |
| 132 | |
| 133 | // A list of classes that should be identical after their owners were cloned. |
| 134 | var identicalAfterCloning = { |