1// Flags: --expose-internals 2'use strict'; 3require('../common'); 4 5// Test helper objects from internal/util 6 7const assert = require('assert'); 8const { 9 kEnumerableProperty, 10 kEmptyObject, 11} = require('internal/util'); 12 13Object.prototype.blep = 'blop'; 14 15{ 16 assert.strictEqual( 17 kEnumerableProperty.blep, 18 undefined 19 ); 20 assert.strictEqual( 21 kEnumerableProperty.enumerable, 22 true 23 ); 24 assert.strictEqual( 25 Object.getPrototypeOf(kEnumerableProperty), 26 null 27 ); 28 assert.deepStrictEqual( 29 Object.getOwnPropertyNames(kEnumerableProperty), 30 [ 'enumerable' ] 31 ); 32 33 assert.throws( 34 () => Object.setPrototypeOf(kEnumerableProperty, { value: undefined }), 35 TypeError 36 ); 37 assert.throws( 38 () => delete kEnumerableProperty.enumerable, 39 TypeError 40 ); 41 assert.throws( 42 () => kEnumerableProperty.enumerable = false, 43 TypeError 44 ); 45 assert.throws( 46 () => Object.assign(kEnumerableProperty, { enumerable: false }), 47 TypeError 48 ); 49 assert.throws( 50 () => kEnumerableProperty.value = undefined, 51 TypeError 52 ); 53 assert.throws( 54 () => Object.assign(kEnumerableProperty, { value: undefined }), 55 TypeError 56 ); 57 assert.throws( 58 () => Object.defineProperty(kEnumerableProperty, 'value', {}), 59 TypeError 60 ); 61} 62 63{ 64 assert.strictEqual( 65 kEmptyObject.blep, 66 undefined 67 ); 68 assert.strictEqual( 69 kEmptyObject.prototype, 70 undefined 71 ); 72 assert.strictEqual( 73 Object.getPrototypeOf(kEmptyObject), 74 null 75 ); 76 assert.strictEqual( 77 kEmptyObject instanceof Object, 78 false 79 ); 80 assert.deepStrictEqual( 81 Object.getOwnPropertyDescriptors(kEmptyObject), 82 {} 83 ); 84 assert.deepStrictEqual( 85 Object.getOwnPropertyNames(kEmptyObject), 86 [] 87 ); 88 assert.deepStrictEqual( 89 Object.getOwnPropertySymbols(kEmptyObject), 90 [] 91 ); 92 assert.strictEqual( 93 Object.isExtensible(kEmptyObject), 94 false 95 ); 96 assert.strictEqual( 97 Object.isSealed(kEmptyObject), 98 true 99 ); 100 assert.strictEqual( 101 Object.isFrozen(kEmptyObject), 102 true 103 ); 104 105 assert.throws( 106 () => kEmptyObject.foo = 'bar', 107 TypeError 108 ); 109 assert.throws( 110 () => Object.assign(kEmptyObject, { foo: 'bar' }), 111 TypeError 112 ); 113 assert.throws( 114 () => Object.defineProperty(kEmptyObject, 'foo', {}), 115 TypeError 116 ); 117} 118 119delete Object.prototype.blep; 120