| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7bd9ecd commit f7a2f75
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,10 +10,12 @@ process.on('warning', common.mustCall((warning) => { | |||
| 10 | 10 | assert(warning); | |
| 11 | 11 | assert(/^(Warning|CustomWarning)/.test(warning.name)); | |
| 12 | 12 | assert(warning.message, 'A Warning'); | |
| 13 | - }, 3)); | ||
| 13 | + }, 7)); | ||
| 14 | 14 | ||
| 15 | 15 | process.emitWarning('A Warning'); | |
| 16 | 16 | process.emitWarning('A Warning', 'CustomWarning'); | |
| 17 | + process.emitWarning('A Warning', CustomWarning); | ||
| 18 | + process.emitWarning('A Warning', 'CustomWarning', CustomWarning); | ||
| 17 | 19 | ||
| 18 | 20 | function CustomWarning() { | |
| 19 | 21 | Error.call(this); | |
@@ -24,6 +26,16 @@ function CustomWarning() { | |||
| 24 | 26 | util.inherits(CustomWarning, Error); | |
| 25 | 27 | process.emitWarning(new CustomWarning()); | |
| 26 | 28 | ||
| 29 | + const warningNoToString = new CustomWarning(); | ||
| 30 | + warningNoToString.toString = null; | ||
| 31 | + process.emitWarning(warningNoToString); | ||
| 32 | + | ||
| 33 | + const warningThrowToString = new CustomWarning(); | ||
| 34 | + warningThrowToString.toString = function() { | ||
| 35 | + throw new Error('invalid toString'); | ||
| 36 | + }; | ||
| 37 | + process.emitWarning(warningThrowToString); | ||
| 38 | + | ||
| 27 | 39 | // TypeError is thrown on invalid output | |
| 28 | 40 | assert.throws(() => process.emitWarning(1), TypeError); | |
| 29 | 41 | assert.throws(() => process.emitWarning({}), TypeError); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments