1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
expected = ''; function g(code) { f = Function(code); gen = f(); gen.next(); try { gen.next(); } catch (ex) { expected = ex.toString() } } g("\ yield this.__defineGetter__('x', function(){ return z }); \ let z = new String('hi'); \ "); eval(); gc(); str = x; assertEq(expected, "[object StopIteration]"); assertEq(str.toString(), "hi");