OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 function assertInstanceof(obj, type) { | 173 function assertInstanceof(obj, type) { |
174 if (!(obj instanceof type)) { | 174 if (!(obj instanceof type)) { |
175 assertTrue(false, "Object <" + obj + "> is not an instance of <" + type + ">
"); | 175 assertTrue(false, "Object <" + obj + "> is not an instance of <" + type + ">
"); |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 | 179 |
180 function assertDoesNotThrow(code) { | 180 function assertDoesNotThrow(code) { |
181 try { | 181 try { |
182 eval(code); | 182 if (typeof code == 'function') { |
| 183 code(); |
| 184 } else { |
| 185 eval(code); |
| 186 } |
183 } catch (e) { | 187 } catch (e) { |
184 assertTrue(false, "threw an exception"); | 188 assertTrue(false, "threw an exception: " + (e.message || e)); |
185 } | 189 } |
186 } | 190 } |
187 | 191 |
188 | 192 |
189 function assertUnreachable(name_opt) { | 193 function assertUnreachable(name_opt) { |
190 // Fix this when we ditch the old test runner. | 194 // Fix this when we ditch the old test runner. |
191 var message = "Fail" + "ure: unreachable" | 195 var message = "Fail" + "ure: unreachable" |
192 if (name_opt) { | 196 if (name_opt) { |
193 message += " - " + name_opt; | 197 message += " - " + name_opt; |
194 } | 198 } |
195 throw new MjsUnitAssertionError(message); | 199 throw new MjsUnitAssertionError(message); |
196 } | 200 } |
OLD | NEW |