ion-private-idempotent.js (801B)
1 var acc = 0; 2 const loopCount = 100; 3 4 class A { 5 #x = 1; 6 static loopRead(o) { 7 for (var i = 0; i < loopCount; i++) { 8 // If this getelem were hoisted out of the loop, 9 // we need the IC that is attached to that to 10 // correctly throw if .#x is not in o. 11 var b = o.#x; 12 acc += 1; 13 } 14 } 15 }; 16 17 // Two non-A objects, because we're concerned not about the first 18 // attempt to read .#x from a non A, but the second, because if 19 // we attach the wrong IC, we'll attach an IC that provides 20 // regular object semantics, which would be to return undefined. 21 var array = [new A, new A, new A, {}, {}]; 22 for (var e of array) { 23 acc = 0; 24 try { 25 A.loopRead(e); 26 assertEq(acc, loopCount); 27 } catch (e) { 28 assertEq(e instanceof TypeError, true); 29 assertEq(acc, 0); 30 } 31 }