set-get-add-method-failure.js (692B)
1 // Copyright (C) 2015 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-set-constructor 5 description: > 6 Set ( [ iterable ] ) 7 8 When the Set function is called with optional argument iterable the following steps are taken: 9 10 ... 11 6. If iterable is either undefined or null, let iter be undefined. 12 7. Else, 13 a. Let adder be Get(set, "add"). 14 b. ReturnIfAbrupt(adder). 15 ---*/ 16 17 function MyError() {} 18 Object.defineProperty(Set.prototype, 'add', { 19 get: function() { 20 throw new MyError(); 21 } 22 }); 23 24 new Set(); 25 26 assert.throws(MyError, function() { 27 new Set([]); 28 }); 29 30 reportCompare(0, 0);