11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_cirequire('../common');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst symbol = Symbol('sym');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci// Verify that getting via a symbol key returns undefined.
81cb0ef41Sopenharmony_ciassert.strictEqual(process.env[symbol], undefined);
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci// Verify that assigning via a symbol key throws.
111cb0ef41Sopenharmony_ci// The message depends on the JavaScript engine and so will be different between
121cb0ef41Sopenharmony_ci// different JavaScript engines. Confirm that the `Error` is a `TypeError` only.
131cb0ef41Sopenharmony_ciassert.throws(() => {
141cb0ef41Sopenharmony_ci  process.env[symbol] = 42;
151cb0ef41Sopenharmony_ci}, TypeError);
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci// Verify that assigning a symbol value throws.
181cb0ef41Sopenharmony_ci// The message depends on the JavaScript engine and so will be different between
191cb0ef41Sopenharmony_ci// different JavaScript engines. Confirm that the `Error` is a `TypeError` only.
201cb0ef41Sopenharmony_ciassert.throws(() => {
211cb0ef41Sopenharmony_ci  process.env.foo = symbol;
221cb0ef41Sopenharmony_ci}, TypeError);
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci// Verify that using a symbol with the in operator returns false.
251cb0ef41Sopenharmony_ciassert.strictEqual(symbol in process.env, false);
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci// Verify that deleting a symbol key returns true.
281cb0ef41Sopenharmony_ciassert.strictEqual(delete process.env[symbol], true);
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci// Checks that well-known symbols like `Symbol.toStringTag` won’t throw.
311cb0ef41Sopenharmony_ciObject.prototype.toString.call(process.env);
32