Skip to content

Commit

Permalink
Revert "[Tests] handle a broken error cause in node 16.9/16.10"
Browse files Browse the repository at this point in the history
This reverts commit 53d9e18, plus a little extra.
  • Loading branch information
ljharb committed Aug 16, 2022
1 parent f4c7214 commit 775ba37
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/error.js
Expand Up @@ -20,7 +20,7 @@ tap.test('failures', function (tt) {
' expected: |-',
' undefined',
' actual: |-',
' ' + ('cause' in Error.prototype ? '{ [Error: this is a message] [cause]: undefined }' : '[Error: this is a message]'),
' [Error: this is a message]',
' at: Test.<anonymous> ($TEST/error.js:$LINE:$COL)',
' stack: |-',
' Error: this is a message',
Expand Down
8 changes: 3 additions & 5 deletions test/stackTrace.js
Expand Up @@ -14,8 +14,6 @@ tap.test('preserves stack trace with newlines', function (tt) {
var parser = stream.pipe(tapParser());
var stackTrace = 'foo\n bar';

var inspected = 'cause' in Error.prototype ? '{ [Error: Preserve stack] [cause]: undefined }' : '[Error: Preserve stack]';

parser.once('assert', function (data) {
delete data.diag.at;
tt.deepEqual(data, {
Expand All @@ -26,7 +24,7 @@ tap.test('preserves stack trace with newlines', function (tt) {
stack: stackTrace,
operator: 'error',
expected: 'undefined',
actual: inspected
actual: '[Error: Preserve stack]'
}
});
});
Expand All @@ -43,7 +41,7 @@ tap.test('preserves stack trace with newlines', function (tt) {
+ ' expected: |-\n'
+ ' undefined\n'
+ ' actual: |-\n'
+ ' ' + inspected + '\n'
+ ' [Error: Preserve stack]\n'
+ ' stack: |-\n'
+ ' foo\n'
+ ' bar\n'
Expand All @@ -59,7 +57,7 @@ tap.test('preserves stack trace with newlines', function (tt) {
stack: stackTrace,
operator: 'error',
expected: 'undefined',
actual: inspected
actual: '[Error: Preserve stack]'
});
}));

Expand Down
20 changes: 9 additions & 11 deletions test/throws.js
Expand Up @@ -26,8 +26,6 @@ var thrower = function () { throw messageGetterError; };
tap.test('failures', function (tt) {
tt.plan(1);

var maybeCause = 'cause' in Error.prototype ? '[cause]: undefined, ' : '';

var test = tape.createHarness();
test.createStream().pipe(concat(function (body) {
tt.same(stripFullStack(body.toString('utf8')), [
Expand All @@ -39,7 +37,7 @@ tap.test('failures', function (tt) {
' expected: |-',
' undefined',
' actual: |-',
' { [TypeError: ' + getNonFunctionMessage() + '] ' + maybeCause + "message: '" + getNonFunctionMessage() + "' }",
' { [TypeError: ' + getNonFunctionMessage() + "] message: '" + getNonFunctionMessage() + "' }",
' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
' stack: |-',
String(' TypeError: ' + getNonFunctionMessage(undefined)),
Expand All @@ -53,7 +51,7 @@ tap.test('failures', function (tt) {
' expected: |-',
' undefined',
' actual: |-',
' { [TypeError: ' + getNonFunctionMessage(null) + '] ' + maybeCause + "message: '" + getNonFunctionMessage(null) + "' }",
' { [TypeError: ' + getNonFunctionMessage(null) + "] message: '" + getNonFunctionMessage(null) + "' }",
' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
' stack: |-',
String(' TypeError: ' + getNonFunctionMessage(null)),
Expand All @@ -67,7 +65,7 @@ tap.test('failures', function (tt) {
' expected: |-',
' undefined',
' actual: |-',
' { [TypeError: ' + getNonFunctionMessage(true) + '] ' + maybeCause + "message: '" + getNonFunctionMessage(true) + "' }",
' { [TypeError: ' + getNonFunctionMessage(true) + "] message: '" + getNonFunctionMessage(true) + "' }",
' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
' stack: |-',
String(' TypeError: ' + getNonFunctionMessage(true)),
Expand All @@ -81,7 +79,7 @@ tap.test('failures', function (tt) {
' expected: |-',
' undefined',
' actual: |-',
' { [TypeError: ' + getNonFunctionMessage(false) + '] ' + maybeCause + "message: '" + getNonFunctionMessage(false) + "' }",
' { [TypeError: ' + getNonFunctionMessage(false) + "] message: '" + getNonFunctionMessage(false) + "' }",
' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
' stack: |-',
String(' TypeError: ' + getNonFunctionMessage(false)),
Expand All @@ -95,7 +93,7 @@ tap.test('failures', function (tt) {
' expected: |-',
' undefined',
' actual: |-',
' { [TypeError: ' + getNonFunctionMessage('abc') + '] ' + maybeCause + "message: '" + getNonFunctionMessage('abc') + "' }",
' { [TypeError: ' + getNonFunctionMessage('abc') + "] message: '" + getNonFunctionMessage('abc') + "' }",
' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
' stack: |-',
String(' TypeError: ' + getNonFunctionMessage('abc')),
Expand All @@ -109,7 +107,7 @@ tap.test('failures', function (tt) {
' expected: |-',
' undefined',
' actual: |-',
' { [TypeError: ' + getNonFunctionMessage(/a/g) + '] ' + maybeCause + "message: '" + getNonFunctionMessage(/a/g) + "' }",
' { [TypeError: ' + getNonFunctionMessage(/a/g) + "] message: '" + getNonFunctionMessage(/a/g) + "' }",
' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
' stack: |-',
String(' TypeError: ' + getNonFunctionMessage(/a/g)),
Expand All @@ -123,7 +121,7 @@ tap.test('failures', function (tt) {
' expected: |-',
' undefined',
' actual: |-',
' { [TypeError: ' + getNonFunctionMessage([]) + '] ' + maybeCause + "message: '" + getNonFunctionMessage([]) + "' }",
' { [TypeError: ' + getNonFunctionMessage([]) + "] message: '" + getNonFunctionMessage([]) + "' }",
' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
' stack: |-',
String(' TypeError: ' + getNonFunctionMessage([])),
Expand All @@ -137,7 +135,7 @@ tap.test('failures', function (tt) {
' expected: |-',
' undefined',
' actual: |-',
' { [TypeError: ' + getNonFunctionMessage({}) + '] ' + maybeCause + "message: '" + getNonFunctionMessage({}) + "' }",
' { [TypeError: ' + getNonFunctionMessage({}) + "] message: '" + getNonFunctionMessage({}) + "' }",
' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
' stack: |-',
String(' TypeError: ' + getNonFunctionMessage({})),
Expand Down Expand Up @@ -171,7 +169,7 @@ tap.test('failures', function (tt) {
' expected: |-',
' [Function: TypeError]',
' actual: |-',
' { [RangeError: actual!] ' + maybeCause + "message: 'actual!' }",
" { [RangeError: actual!] message: 'actual!' }",
' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
' stack: |-',
' RangeError: actual!',
Expand Down

0 comments on commit 775ba37

Please sign in to comment.