(name, fun, expected, unexpected)
| 180 | // Utility function for testing that the expected strings occur |
| 181 | // in the stack trace produced when running the given function. |
| 182 | function testTrace(name, fun, expected, unexpected) { |
| 183 | var threw = false; |
| 184 | try { |
| 185 | fun(); |
| 186 | } catch (e) { |
| 187 | for (var i = 0; i < expected.length; i++) { |
| 188 | assertTrue(e.stack.indexOf(expected[i]) != -1, |
| 189 | name + " doesn't contain expected[" + i + "] stack = " + e.stack); |
| 190 | } |
| 191 | if (unexpected) { |
| 192 | for (var i = 0; i < unexpected.length; i++) { |
| 193 | assertEquals(e.stack.indexOf(unexpected[i]), -1, |
| 194 | name + " contains unexpected[" + i + "]"); |
| 195 | } |
| 196 | } |
| 197 | threw = true; |
| 198 | } |
| 199 | assertTrue(threw, name + " didn't throw"); |
| 200 | } |
| 201 | |
| 202 | // Test that the error constructor is not shown in the trace |
| 203 | function testCallerCensorship() { |
no test coverage detected