11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciassert.throws( 61cb0ef41Sopenharmony_ci () => { 71cb0ef41Sopenharmony_ci Object.defineProperty(process.env, 'foo', { 81cb0ef41Sopenharmony_ci value: 'foo1' 91cb0ef41Sopenharmony_ci }); 101cb0ef41Sopenharmony_ci }, 111cb0ef41Sopenharmony_ci { 121cb0ef41Sopenharmony_ci code: 'ERR_INVALID_OBJECT_DEFINE_PROPERTY', 131cb0ef41Sopenharmony_ci name: 'TypeError', 141cb0ef41Sopenharmony_ci message: '\'process.env\' only accepts a ' + 151cb0ef41Sopenharmony_ci 'configurable, writable,' + 161cb0ef41Sopenharmony_ci ' and enumerable data descriptor' 171cb0ef41Sopenharmony_ci } 181cb0ef41Sopenharmony_ci); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciassert.strictEqual(process.env.foo, undefined); 211cb0ef41Sopenharmony_ciprocess.env.foo = 'foo2'; 221cb0ef41Sopenharmony_ciassert.strictEqual(process.env.foo, 'foo2'); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciassert.throws( 251cb0ef41Sopenharmony_ci () => { 261cb0ef41Sopenharmony_ci Object.defineProperty(process.env, 'goo', { 271cb0ef41Sopenharmony_ci get() { 281cb0ef41Sopenharmony_ci return 'goo'; 291cb0ef41Sopenharmony_ci }, 301cb0ef41Sopenharmony_ci set() {} 311cb0ef41Sopenharmony_ci }); 321cb0ef41Sopenharmony_ci }, 331cb0ef41Sopenharmony_ci { 341cb0ef41Sopenharmony_ci code: 'ERR_INVALID_OBJECT_DEFINE_PROPERTY', 351cb0ef41Sopenharmony_ci name: 'TypeError', 361cb0ef41Sopenharmony_ci message: '\'process.env\' does not accept an ' + 371cb0ef41Sopenharmony_ci 'accessor(getter/setter) descriptor' 381cb0ef41Sopenharmony_ci } 391cb0ef41Sopenharmony_ci); 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ciconst attributes = ['configurable', 'writable', 'enumerable']; 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ciattributes.forEach((attribute) => { 441cb0ef41Sopenharmony_ci assert.throws( 451cb0ef41Sopenharmony_ci () => { 461cb0ef41Sopenharmony_ci Object.defineProperty(process.env, 'goo', { 471cb0ef41Sopenharmony_ci [attribute]: false 481cb0ef41Sopenharmony_ci }); 491cb0ef41Sopenharmony_ci }, 501cb0ef41Sopenharmony_ci { 511cb0ef41Sopenharmony_ci code: 'ERR_INVALID_OBJECT_DEFINE_PROPERTY', 521cb0ef41Sopenharmony_ci name: 'TypeError', 531cb0ef41Sopenharmony_ci message: '\'process.env\' only accepts a ' + 541cb0ef41Sopenharmony_ci 'configurable, writable,' + 551cb0ef41Sopenharmony_ci ' and enumerable data descriptor' 561cb0ef41Sopenharmony_ci } 571cb0ef41Sopenharmony_ci ); 581cb0ef41Sopenharmony_ci}); 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ciassert.strictEqual(process.env.goo, undefined); 611cb0ef41Sopenharmony_ciObject.defineProperty(process.env, 'goo', { 621cb0ef41Sopenharmony_ci value: 'goo', 631cb0ef41Sopenharmony_ci configurable: true, 641cb0ef41Sopenharmony_ci writable: true, 651cb0ef41Sopenharmony_ci enumerable: true 661cb0ef41Sopenharmony_ci}); 671cb0ef41Sopenharmony_ciassert.strictEqual(process.env.goo, 'goo'); 68