Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions test/parallel/test-tty-stdout-end.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
'use strict';
// Can't test this when 'make test' doesn't assign a tty to the stdout.
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

var exceptionCaught = false;

try {
const shouldThrow = function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not the function declaration form?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were no other functions defined in the file, so I did function expressions because it is what I tend to use. There is precedence for function expressions in test/parallel files. test-http-parser.js has 21 function expressions. Still, it was basically an arbitrary decision on my part and I can switch them to function declarations in this file if you or anyone else has a strong preference.

process.stdout.end();
} catch (e) {
exceptionCaught = true;
assert.ok(common.isError(e));
assert.equal('process.stdout cannot be closed.', e.message);
}
};

const validateError = function(e) {
return e instanceof Error &&
e.message === 'process.stdout cannot be closed.';
};

assert.ok(exceptionCaught);
assert.throws(shouldThrow, validateError);