mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 03:31:35 +00:00

This commit causes process.env to throw when a symbol is used as either a key or a value. Fixes: https://github.com/nodejs/node/issues/9429 PR-URL: https://github.com/nodejs/node/pull/9446 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
27 lines
638 B
JavaScript
27 lines
638 B
JavaScript
'use strict';
|
|
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 throws.
|
|
assert.throws(() => {
|
|
process.env[symbol];
|
|
}, errRegExp);
|
|
|
|
// Verify that assigning via a symbol key throws.
|
|
assert.throws(() => {
|
|
process.env[symbol] = 42;
|
|
}, errRegExp);
|
|
|
|
// Verify that assigning a symbol value throws.
|
|
assert.throws(() => {
|
|
process.env.foo = symbol;
|
|
}, errRegExp);
|
|
|
|
// Verify that using a symbol with the in operator throws.
|
|
assert.throws(() => {
|
|
symbol in process.env;
|
|
}, errRegExp);
|