symbol_property_valueOf.js (769B)
1 // Copyright (C) 2021 Jamie Kyle. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-object.hasown 6 description: Object.hasOwn with symbol and valueOf conversion 7 info: | 8 Object.hasOwn ( _O_, _P_ ) 9 10 1. Let _obj_ be ? ToObject(_O_). 11 2. Let _key_ be ? ToPropertyKey(_P_). 12 ... 13 author: Jamie Kyle 14 features: [Symbol, Object.hasOwn] 15 ---*/ 16 17 var obj = {}; 18 var sym = Symbol(); 19 20 var callCount = 0; 21 var wrapper = { 22 valueOf: function() { 23 callCount += 1; 24 return sym; 25 }, 26 toString: null 27 }; 28 29 obj[sym] = 0; 30 31 assert.sameValue( 32 Object.hasOwn(obj, wrapper), 33 true, 34 "Returns true if symbol own property found" 35 ); 36 37 assert.sameValue(callCount, 1, "valueOf method called exactly once"); 38 39 reportCompare(0, 0);