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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 eval(code); | 369 eval(code); |
370 } | 370 } |
371 threwException = false; | 371 threwException = false; |
372 } catch (e) { | 372 } catch (e) { |
373 if (typeof type_opt === 'function') { | 373 if (typeof type_opt === 'function') { |
374 assertInstanceof(e, type_opt); | 374 assertInstanceof(e, type_opt); |
375 } else if (type_opt !== void 0) { | 375 } else if (type_opt !== void 0) { |
376 failWithMessage("invalid use of assertThrows, maybe you want assertThrow sEquals"); | 376 failWithMessage("invalid use of assertThrows, maybe you want assertThrow sEquals"); |
377 } | 377 } |
378 if (arguments.length >= 3) { | 378 if (arguments.length >= 3) { |
379 assertEquals(e.type, cause_opt); | 379 assertEquals(e.message, cause_opt); |
titzer
2016/11/24 15:37:01
What about checking both the type and the cause he
ahaas
2016/11/28 09:47:53
The JS standard defines only message, not type. I
| |
380 } | 380 } |
381 // Success. | 381 // Success. |
382 return; | 382 return; |
383 } | 383 } |
384 failWithMessage("Did not throw exception"); | 384 failWithMessage("Did not throw exception"); |
385 }; | 385 }; |
386 | 386 |
387 | 387 |
388 assertThrowsEquals = function assertThrowsEquals(fun, val) { | 388 assertThrowsEquals = function assertThrowsEquals(fun, val) { |
389 try { | 389 try { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 if (sync_opt === undefined) sync_opt = ""; | 464 if (sync_opt === undefined) sync_opt = ""; |
465 assertTrue(OptimizationStatus(fun, sync_opt) !== 1, name_opt); | 465 assertTrue(OptimizationStatus(fun, sync_opt) !== 1, name_opt); |
466 } | 466 } |
467 | 467 |
468 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { | 468 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { |
469 if (sync_opt === undefined) sync_opt = ""; | 469 if (sync_opt === undefined) sync_opt = ""; |
470 assertTrue(OptimizationStatus(fun, sync_opt) !== 2, name_opt); | 470 assertTrue(OptimizationStatus(fun, sync_opt) !== 2, name_opt); |
471 } | 471 } |
472 | 472 |
473 })(); | 473 })(); |
OLD | NEW |