js/src/jit-test/tests/debug/Environment-identity-04.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Environment-identity-04.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,19 @@
     1.4 +// Observably different visits to the same with-statement produce distinct Environments.
     1.5 +
     1.6 +var g = newGlobal();
     1.7 +g.eval("function f(a, obj) { with (obj) return function () { return a; }; }");
     1.8 +var dbg = Debugger(g);
     1.9 +var hits = 0;
    1.10 +dbg.onDebuggerStatement = function (frame) {
    1.11 +    // Even though the two visits to the with-statement have the same target
    1.12 +    // object, Math, the environments are observably different.
    1.13 +    var f1 = frame.eval("f(1, Math);").return;
    1.14 +    var f2 = frame.eval("f(2, Math);").return;
    1.15 +    assertEq(f1.environment !== f2.environment, true);
    1.16 +    assertEq(f1.object, f2.object);
    1.17 +    assertEq(f1.call().return, 1);
    1.18 +    assertEq(f2.call().return, 2);
    1.19 +    hits++;
    1.20 +};
    1.21 +g.eval("debugger;");
    1.22 +assertEq(hits, 1);

mercurial