js/src/jit-test/tests/debug/Frame-identity-03.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // |jit-test| debug
     2 // Test that we create new Debugger.Frames and reuse old ones correctly with recursion.
     4 var g = newGlobal();
     5 g.debuggeeGlobal = this;
     6 g.eval("(" + function () {
     7         function id(f) {
     8             return ("id" in f) ? f.id : (f.id = nextid++);
     9         }
    11         var dbg = new Debugger(debuggeeGlobal);
    12         dbg.onDebuggerStatement = function (frame) {
    13             var a = [];
    14             for (; frame; frame = frame.older)
    15                 a.push(frame);
    16             var s = '';
    17             while (a.length)
    18                 s += id(a.pop());
    19             results.push(s);
    20         };
    21     } + ")();");
    23 function cons(a, b) {
    24     debugger;
    25     return [a, b];
    26 }
    28 function tree(n) {
    29     if (n < 2)
    30         return n;
    31     return cons(tree(n - 1), tree(n - 2));
    32 }
    34 g.eval("results = []; nextid = 0;");
    35 debugger;
    36 assertEq(g.results.join(","), "0");
    37 assertEq(g.nextid, 1);
    39 g.eval("results = [];");
    40 tree(2);
    41 assertEq(g.results.join(","), "012"); // 0=global, 1=tree, 2=cons
    43 g.eval("results = []; nextid = 1;");
    44 tree(3);
    45 assertEq(g.results.join(","), "0123,014"); //0=global, 1=tree(3), 2=tree(2), 3=cons, 4=cons
    47 g.eval("results = []; nextid = 1;");
    48 tree(4);
    49 // 0=global, 1=tree(4), 2=tree(3), 3=tree(2), 4=cons, tree(1), 5=cons, 6=tree(2), 7=cons, 8=cons
    50 assertEq(g.results.join(","), "01234,0125,0167,018");

mercurial