Skip to content

Commit

Permalink
test: make test-process-env-symbols agnostic
Browse files Browse the repository at this point in the history
Do not check the error message if it is generated by the JavaScript
engine (V8, ChakraCore, etc.). Do confirm that it is a `TypeError`.

PR-URL: #16272
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
Trott authored and evanlucas committed Nov 13, 2017
1 parent 9bf8874 commit e2f5648
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/parallel/test-process-env-symbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@ require('../common');

const assert = require('assert');
const symbol = Symbol('sym');
const errRegExp = /^TypeError: Cannot convert a Symbol value to a string$/;

// Verify that getting via a symbol key returns undefined.
assert.strictEqual(process.env[symbol], undefined);

// Verify that assigning via a symbol key throws.
// The message depends on the JavaScript engine and so will be different between
// different JavaScript engines. Confirm that the `Error` is a `TypeError` only.
assert.throws(() => {
process.env[symbol] = 42;
}, errRegExp);
}, TypeError);

// Verify that assigning a symbol value throws.
// The message depends on the JavaScript engine and so will be different between
// different JavaScript engines. Confirm that the `Error` is a `TypeError` only.
assert.throws(() => {
process.env.foo = symbol;
}, errRegExp);
}, TypeError);

// Verify that using a symbol with the in operator returns false.
assert.strictEqual(symbol in process.env, false);
Expand Down

0 comments on commit e2f5648

Please sign in to comment.