using-outer-inner-using-bindings.js (1058B)
1 // |reftest| shell-option(--enable-explicit-resource-management) skip-if(!(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('explicit-resource-management'))||!xulRuntime.shell) -- explicit-resource-management is not enabled unconditionally, requires shell-options 2 // Copyright (C) 2023 Ron Buckton. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-runtime-semantics-fordeclarationbindinginstantiation 7 description: > 8 outer using binding unchanged by for-loop using binding 9 features: [explicit-resource-management] 10 ---*/ 11 12 const outer_x = { [Symbol.dispose]() {} }; 13 const outer_y = { [Symbol.dispose]() {} }; 14 const inner_x = { [Symbol.dispose]() {} }; 15 const inner_y = { [Symbol.dispose]() {} }; 16 17 { 18 using x = outer_x; 19 using y = outer_y; 20 var i = 0; 21 22 for (using x = inner_x; i < 1; i++) { 23 using y = inner_y; 24 25 assert.sameValue(x, inner_x); 26 assert.sameValue(y, inner_y); 27 } 28 assert.sameValue(x, outer_x); 29 assert.sameValue(y, outer_y); 30 } 31 32 reportCompare(0, 0);