iterator-noSuchMethod.js (748B)
1 // __noSuchMethod__ is totally non-standard and evil, but in this one weird case 2 // below we don't actually use it. So this test is bog-standard ES6, not 3 // SpiderMonkey-specific. 4 // 5 // In ES6: 6 // Accessing 1[Symbol.iterator]() throws a TypeError calling |undefined|. 7 // In SpiderMonkey: 8 // Accessing 1[Symbol.iterator]() does *not* invoke __noSuchMethod__ looked up 9 // on 1 (or on an implicitly boxed 1), because 1 is a primitive value. 10 // SpiderMonkey then does exactly the ES6 thing here and throws a TypeError 11 // calling |undefined|. 12 13 Object.prototype.__noSuchMethod__ = {}; 14 15 try 16 { 17 var [x] = 1; 18 throw new Error("didn't throw"); 19 } 20 catch (e) 21 { 22 assertEq(e instanceof TypeError, true, 23 "expected TypeError, got " + e); 24 }