|
3 | 3 | const common = require('../common'); |
4 | 4 | const assert = require('assert'); |
5 | 5 | const internalUtil = require('internal/util'); |
| 6 | +const binding = process.binding('util'); |
6 | 7 | const spawnSync = require('child_process').spawnSync; |
7 | 8 | const path = require('path'); |
8 | 9 |
|
| 10 | +const kArrowMessagePrivateSymbolIndex = binding['arrow_message_private_symbol']; |
| 11 | +const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol']; |
| 12 | + |
9 | 13 | assert.doesNotThrow(function() { |
10 | 14 | internalUtil.decorateErrorStack(); |
11 | 15 | internalUtil.decorateErrorStack(null); |
@@ -53,6 +57,19 @@ checkStack(result.stderr); |
53 | 57 |
|
54 | 58 | // Verify that the stack is unchanged when there is no arrow message |
55 | 59 | err = new Error('foo'); |
56 | | -const originalStack = err.stack; |
| 60 | +let originalStack = err.stack; |
57 | 61 | internalUtil.decorateErrorStack(err); |
58 | 62 | assert.strictEqual(originalStack, err.stack); |
| 63 | + |
| 64 | +// Verify that the arrow message is added to the start of the stack when it |
| 65 | +// exists |
| 66 | +const arrowMessage = 'arrow_message'; |
| 67 | +err = new Error('foo'); |
| 68 | +originalStack = err.stack; |
| 69 | + |
| 70 | +internalUtil.setHiddenValue(err, kArrowMessagePrivateSymbolIndex, arrowMessage); |
| 71 | +internalUtil.decorateErrorStack(err); |
| 72 | + |
| 73 | +assert.strictEqual(err.stack, `${arrowMessage}${originalStack}`); |
| 74 | +assert.strictEqual(internalUtil |
| 75 | + .getHiddenValue(err, kDecoratedPrivateSymbolIndex), true); |
0 commit comments