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 <targos@protonmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • 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
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.