summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Script-getEffectfulOffsets.js
blob: 49289a946fc73a438db2a4d1d81df336d1e0b66b (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
// Check that Script.getEffectfulOffsets behaves sensibly.

var g = newGlobal({newCompartment: true});
var dbg = Debugger(g);
var numEffectfulOperations;

function onNewScript(script) {
  script.getChildScripts().forEach(onNewScript);
  numEffectfulOperations += script.getEffectfulOffsets().length;
}
dbg.onNewScript = onNewScript;

function test(code, expected) {
  numEffectfulOperations = 0;
  g.eval(`
function f(a, b, c) {
${code}
}
`);
  assertEq(numEffectfulOperations, expected);
}

test("a.f = 0", 2);
test("a.f++", 2);
test("return a.f", 1);
test("a[b] = 0", 2);
test("a[b]++", 2);
test("return a[b]", 1);
test("a = 0", 1);
test("d = 0", 2);
test("with (a) { b = 0; }", 4);
test("let o = {}; ({x: o.x} = { x: 10 })", 2);
test("var x", 1);