tor-browser

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

delazifications-nest.js (1354B)


      1 load(libdir + 'bytecode-cache.js');
      2 
      3 let test = `
      4 // Put some unused atoms in the initial stencil, to verify that atoms are
      5 // correctly mapped while merging stencils.
      6 if (false) {
      7  "unused text1";
      8  "unused text2";
      9  "unused text3";
     10  "unused text4";
     11  "unused text5";
     12 }
     13 
     14 var result = 0;
     15 
     16 function func() {
     17  var anonFunc = function() {
     18    // Method/accessor as inner-inner function.
     19    var obj = {
     20      method(name) {
     21        // Test object literal.
     22        var object = {
     23          propA: 9,
     24          propB: 10,
     25          propC: 11,
     26        };
     27 
     28        // Test object property access.
     29        return object["prop" + name];
     30      },
     31      get prop1() {
     32        return 200;
     33      },
     34      set prop2(value) {
     35        result += value;
     36      }
     37    };
     38    result += obj.prop1;
     39    obj.prop2 = 3000;
     40    result += obj.method("B");
     41  };
     42 
     43  function anotherFunc() {
     44    return 40000;
     45  }
     46 
     47  function unused() {
     48  }
     49 
     50  class MyClass {
     51    constructor() {
     52      result += 500000;
     53    }
     54  }
     55 
     56  // Functions inside arrow parameters, that are parsed multiple times.
     57  const arrow = (a = (b = c => { result += 6000000 }) => b) => a()();
     58 
     59  // Delazify in the different order as definition.
     60  new MyClass();
     61  anonFunc();
     62  result += anotherFunc();
     63  arrow();
     64 }
     65 func();
     66 
     67 result;
     68 `;
     69 
     70 evalWithCache(test, { collectDelazifications: true, oassertEqResult : true });