(funcA, funcB, ...params)
| 133 | // A helper function to assert that the behavior of two functions are the |
| 134 | // same. |
| 135 | function assert_same_behavior(funcA, funcB, ...params) { |
| 136 | let resultA; |
| 137 | let errA = null; |
| 138 | try { |
| 139 | resultA = funcA(...params); |
| 140 | } catch (err) { |
| 141 | errA = err; |
| 142 | } |
| 143 | |
| 144 | let resultB; |
| 145 | let errB = null; |
| 146 | try { |
| 147 | resultB = funcB(...params); |
| 148 | } catch (err) { |
| 149 | errB = err; |
| 150 | } |
| 151 | |
| 152 | if (errA || errB) { |
| 153 | assert_equals(errA === null, errB === null, errA ? errA.message : errB.message); |
| 154 | assert_equals(Object.getPrototypeOf(errA), Object.getPrototypeOf(errB)); |
| 155 | } |
| 156 | assert_equals(resultA, resultB); |
| 157 | |
| 158 | if (errA) { |
| 159 | throw errA; |
| 160 | } |
| 161 | return resultA; |
| 162 | } |
| 163 | |
| 164 | function assert_throws_if(func, shouldThrow, constructor) { |
| 165 | let error = null; |
no test coverage detected