js/src/jit-test/tests/debug/Environment-find-01.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-find-01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,19 @@
     1.4 +// find sees that vars are hoisted out of with statements.
     1.5 +
     1.6 +var g = newGlobal();
     1.7 +var dbg = Debugger(g);
     1.8 +var hits = 0;
     1.9 +dbg.onDebuggerStatement = function (frame) {
    1.10 +    assertEq(frame.environment.find("x").type, "with");
    1.11 +    hits++;
    1.12 +};
    1.13 +
    1.14 +assertEq(g.eval("(function () {\n" +
    1.15 +                "    function g() { x = 1; }\n" +
    1.16 +                "    with ({x: 2}) {\n" +
    1.17 +                "        var x;\n" +
    1.18 +                "        debugger;\n" +
    1.19 +                "        return x;\n" +
    1.20 +                "    }\n" +
    1.21 +                "})();"), 2);
    1.22 +assertEq(hits, 1);

mercurial