js/src/jit-test/tests/debug/Frame-onStep-06.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/Frame-onStep-06.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +// After returning from an implicit toString call, the calling frame's onStep
     1.5 +// hook fires.
     1.6 +
     1.7 +var g = newGlobal();
     1.8 +g.eval("var originalX = {toString: function () { debugger; log += 'x'; return 1; }};\n");
     1.9 +
    1.10 +var dbg = Debugger(g);
    1.11 +dbg.onDebuggerStatement = function (frame) {
    1.12 +    g.log += 'd';
    1.13 +    frame.older.onStep = function () {
    1.14 +        if (!g.log.match(/[sy]$/))
    1.15 +            g.log += 's';
    1.16 +    };
    1.17 +};
    1.18 +
    1.19 +// expr is an expression that will trigger an implicit toString call.
    1.20 +function check(expr) {
    1.21 +    g.log = '';
    1.22 +    g.x = g.originalX;
    1.23 +    g.eval(expr + ";\n" +
    1.24 +	   "log += 'y';\n");
    1.25 +    assertEq(g.log, 'dxsy');
    1.26 +}
    1.27 +
    1.28 +check("'' + x");
    1.29 +check("0 + x");
    1.30 +check("0 - x");
    1.31 +check("0 * x");
    1.32 +check("0 / x");
    1.33 +check("0 % x");
    1.34 +check("+x");
    1.35 +check("x in {}");
    1.36 +check("x++");
    1.37 +check("++x");
    1.38 +check("x--");
    1.39 +check("--x");
    1.40 +check("x < 0");
    1.41 +check("x > 0");
    1.42 +check("x >= 0");
    1.43 +check("x <= 0");
    1.44 +check("x == 0");
    1.45 +check("x != 0");
    1.46 +check("x & 1");
    1.47 +check("x | 1");
    1.48 +check("x ^ 1");
    1.49 +check("~x");
    1.50 +check("x << 1");
    1.51 +check("x >> 1");
    1.52 +check("x >>> 1");
    1.53 +
    1.54 +g.eval("function lastStep() { throw StopIteration; }");
    1.55 +g.eval("function emptyIterator() { debugger; log += 'x'; return { next: lastStep }; }");
    1.56 +g.eval("var customEmptyIterator = { __iterator__: emptyIterator };");
    1.57 +g.log = '';
    1.58 +g.eval("for (i in customEmptyIterator);\n" +
    1.59 +       "log += 'y';\n");
    1.60 +assertEq(g.log, 'dxsy');
    1.61 +
    1.62 +g.eval("var getter = { get x() { debugger; return log += 'x'; } }");
    1.63 +check("getter.x");
    1.64 +
    1.65 +g.eval("var setter = { set x(v) { debugger; return log += 'x'; } }");
    1.66 +check("setter.x = 1");
    1.67 +
    1.68 +g.eval("Object.defineProperty(this, 'thisgetter', { get: function() { debugger; log += 'x'; }});");
    1.69 +check("thisgetter");

mercurial