~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/jit-test/tests/debug/Frame-onStep-06.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// After returning from an implicit toString call, the calling frame's onStep
 
2
// hook fires.
 
3
 
 
4
var g = newGlobal('new-compartment');
 
5
g.eval("var originalX = {toString: function () { debugger; log += 'x'; return 1; }};\n");
 
6
 
 
7
var dbg = Debugger(g);
 
8
dbg.onDebuggerStatement = function (frame) {
 
9
    g.log += 'd';
 
10
    frame.older.onStep = function () {
 
11
        if (!g.log.match(/[sy]$/))
 
12
            g.log += 's';
 
13
    };
 
14
};
 
15
 
 
16
// expr is an expression that will trigger an implicit toString call.
 
17
function check(expr) {
 
18
    g.log = '';
 
19
    g.x = g.originalX;
 
20
    g.eval(expr + ";\n" +
 
21
           "log += 'y';\n");
 
22
    assertEq(g.log, 'dxsy');
 
23
}
 
24
 
 
25
check("'' + x");
 
26
check("0 + x");
 
27
check("0 - x");
 
28
check("0 * x");
 
29
check("0 / x");
 
30
check("0 % x");
 
31
check("+x");
 
32
check("x in {}");
 
33
check("x++");
 
34
check("++x");
 
35
check("x--");
 
36
check("--x");
 
37
check("x < 0");
 
38
check("x > 0");
 
39
check("x >= 0");
 
40
check("x <= 0");
 
41
check("x == 0");
 
42
check("x != 0");
 
43
check("x & 1");
 
44
check("x | 1");
 
45
check("x ^ 1");
 
46
check("~x");
 
47
check("x << 1");
 
48
check("x >> 1");
 
49
check("x >>> 1");
 
50
 
 
51
g.eval("function lastStep() { throw StopIteration; }");
 
52
g.eval("function emptyIterator() { debugger; log += 'x'; return { next: lastStep }; }");
 
53
g.eval("var customEmptyIterator = { __iterator__: emptyIterator };");
 
54
g.log = '';
 
55
g.eval("for (i in customEmptyIterator);\n" +
 
56
       "log += 'y';\n");
 
57
assertEq(g.log, 'dxsy');
 
58
 
 
59
g.eval("var getter = { get x() { debugger; return log += 'x'; } }");
 
60
check("getter.x");
 
61
 
 
62
g.eval("var setter = { set x(v) { debugger; return log += 'x'; } }");
 
63
check("setter.x = 1");
 
64
 
 
65
g.eval("Object.defineProperty(this, 'thisgetter', { get: function() { debugger; log += 'x'; }});");
 
66
check("thisgetter");