tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

short-circuit-compound-assignment-deleted-decl-binding.js (942B)


      1 // SKIP test262 export
      2 // Pending review.
      3 
      4 // Test when a declarative binding is deleted.
      5 
      6 // ES2020, 8.1.1.1.5 SetMutableBinding ( N, V, S )
      7 //
      8 // 1. ...
      9 // 2. If envRec does not have a binding for N, then
     10 //   a. ...
     11 //   b. Perform envRec.CreateMutableBinding(N, true).
     12 //   c. Perform envRec.InitializeBinding(N, V).
     13 //   d. Return NormalCompletion(empty).
     14 // 3. ...
     15 
     16 // AndAssignExpr
     17 {
     18  let a = 0;
     19 
     20  let f = function() {
     21    eval("var a = 1;");
     22 
     23    a &&= (delete a, 2);
     24 
     25    assertEq(a, 2);
     26  }
     27 
     28  f();
     29 
     30  assertEq(a, 0);
     31 }
     32 
     33 // OrAssignExpr
     34 {
     35  let a = 1;
     36 
     37  let f = function() {
     38    eval("var a = 0;");
     39 
     40    a ||= (delete a, 2);
     41 
     42    assertEq(a, 2);
     43  }
     44 
     45  f();
     46 
     47  assertEq(a, 1);
     48 }
     49 
     50 // CoalesceAssignExpr
     51 {
     52  let a = undefined;
     53 
     54  let f = function() {
     55    eval("var a = null;");
     56 
     57    a ??= (delete a, 2);
     58 
     59    assertEq(a, 2);
     60  }
     61 
     62  f();
     63 
     64  assertEq(a, undefined);
     65 }
     66 
     67 if (typeof reportCompare === "function")
     68  reportCompare(0, 0);