summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/xdr/delazifications-nest.js
blob: 0a8fc23a583f79fd8367dfe6e960cbf9d1a6a76f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
load(libdir + 'bytecode-cache.js');

let test = `
// Put some unused atoms in the initial stencil, to verify that atoms are
// correctly mapped while merging stencils.
if (false) {
  "unused text1";
  "unused text2";
  "unused text3";
  "unused text4";
  "unused text5";
}

var result = 0;

function func() {
  var anonFunc = function() {
    // Method/accessor as inner-inner function.
    var obj = {
      method(name) {
        // Test object literal.
        var object = {
          propA: 9,
          propB: 10,
          propC: 11,
        };

        // Test object property access.
        return object["prop" + name];
      },
      get prop1() {
        return 200;
      },
      set prop2(value) {
        result += value;
      }
    };
    result += obj.prop1;
    obj.prop2 = 3000;
    result += obj.method("B");
  };

  function anotherFunc() {
    return 40000;
  }

  function unused() {
  }

  class MyClass {
    constructor() {
      result += 500000;
    }
  }

  // Functions inside arrow parameters, that are parsed multiple times.
  const arrow = (a = (b = c => { result += 6000000 }) => b) => a()();

  // Delazify in the different order as definition.
  new MyClass();
  anonFunc();
  result += anotherFunc();
  arrow();
}
func();

result;
`;

evalWithCache(test, { incremental: true, oassertEqResult : true });