to-primitive-observe.js (612B)
1 // Copyright (C) 2020 Qu Xing. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-unescape-string 5 description: Observable operations from string coercion 6 info: | 7 B.2.1.2 unescape ( string ) 8 9 1. Set string to ? ToString(string). 10 .... 11 features: [Symbol.toPrimitive] 12 ---*/ 13 14 var obj = { 15 toString() { throw new Test262Error('this should be unreachable'); }, 16 valueOf() { throw new Test262Error('this should be unreachable'); }, 17 [Symbol.toPrimitive]() { return 'success'; } 18 }; 19 20 assert.sameValue(unescape(obj), 'success'); 21 22 reportCompare(0, 0);