| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c688a00 commit 9c3a7bf
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,9 +44,18 @@ assert.strictEqual(util.format(symbol), 'Symbol(foo)'); | |||
| 44 | 44 | assert.strictEqual(util.format('foo', symbol), 'foo Symbol(foo)'); | |
| 45 | 45 | assert.strictEqual(util.format('%s', symbol), 'Symbol(foo)'); | |
| 46 | 46 | assert.strictEqual(util.format('%j', symbol), 'undefined'); | |
| 47 | - assert.throws(function() { | ||
| 48 | - util.format('%d', symbol); | ||
| 49 | - }, /^TypeError: Cannot convert a Symbol value to a number$/); | ||
| 47 | + assert.throws( | ||
| 48 | + () => { util.format('%d', symbol); }, | ||
| 49 | + (e) => { | ||
| 50 | + // The error should be a TypeError. | ||
| 51 | + if (!(e instanceof TypeError)) | ||
| 52 | + return false; | ||
| 53 | + | ||
| 54 | + // The error should be from the JS engine and not from Node.js. | ||
| 55 | + // JS engine errors do not have the `code` property. | ||
| 56 | + return e.code === undefined; | ||
| 57 | + } | ||
| 58 | + ); | ||
| 50 | 59 | ||
| 51 | 60 | // Number format specifier | |
| 52 | 61 | assert.strictEqual(util.format('%d'), '%d'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments