Chromium Code Reviews| Index: test/mjsunit/debug-backtrace-text.js |
| diff --git a/test/mjsunit/debug-backtrace-text.js b/test/mjsunit/debug-backtrace-text.js |
| index 61648fa4e2e6ee4e8554556db02e18acd93fe0b1..e4154d2ba0a9c3be2a0711c8389eb3a82b00cd9a 100644 |
| --- a/test/mjsunit/debug-backtrace-text.js |
| +++ b/test/mjsunit/debug-backtrace-text.js |
| @@ -58,7 +58,7 @@ a=[1,2,distance]; |
| // Get the Debug object exposed from the debug context global object. |
| Debug = debug.Debug |
| -testConstructor = false; // Flag to control which part of the test is run. |
| +what = 'constructor'; // Flag to control which part of the test is run. |
| listenerCalled = false; |
| exception = false; |
| @@ -72,30 +72,47 @@ function safeEval(code) { |
| function listener(event, exec_state, event_data, data) { |
| try { |
| - if (event == Debug.DebugEvent.Break) |
| - { |
| - if (!testConstructor) { |
| - // The expected backtrace is |
| - // 0: Call distance on Point where distance is a property on the prototype |
| - // 1: Call distance on Point where distance is a direct property |
| - // 2: Call on function an array element 2 |
| - // 3: [anonymous] |
| - assertEquals("#<Point>.distanceTo(p=#<Point>)", exec_state.frame(0).invocationText()); |
| - assertEquals("#<Point>.distanceTo(p=#<Point>)", exec_state.frame(1).invocationText()); |
| - assertEquals("#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)", exec_state.frame(2).invocationText()); |
| - assertEquals("[anonymous]()", exec_state.frame(3).invocationText()); |
| - listenerCalled = true; |
| - } else { |
| - // The expected backtrace is |
| - // 0: Call Point constructor |
| - // 1: Call on global function createPoint |
| - // 2: [anonymous] |
| - assertEquals("new Point(x=0, y=0)", exec_state.frame(0).invocationText()); |
| - assertEquals("createPoint(x=0, y=0)", exec_state.frame(1).invocationText()); |
| - assertEquals("[anonymous]()", exec_state.frame(2).invocationText()); |
| - listenerCalled = true; |
| + if (event == Debug.DebugEvent.Break) { |
| + if (what == 'constructor') { |
| + // The expected backtrace is |
| + // 0: Call distance on Point where distance is a property on the prototype |
|
Yang
2016/07/06 05:39:29
Since you already did the work below, how about al
|
| + // 1: Call distance on Point where distance is a direct property |
| + // 2: Call on function an array element 2 |
| + // 3: [anonymous] |
| + assertEquals("#<Point>.distanceTo(p=#<Point>)", |
| + exec_state.frame(0).invocationText()); |
| + assertEquals("#<Point>.distanceTo(p=#<Point>)", |
| + exec_state.frame(1).invocationText()); |
| + assertEquals("#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)", |
| + exec_state.frame(2).invocationText()); |
| + assertEquals("[anonymous]()", exec_state.frame(3).invocationText()); |
| + listenerCalled = true; |
| + } else if (what == 'breakpoint') { |
| + // The expected backtrace is |
| + // 0: Call Point constructor |
| + // 1: Call on global function createPoint |
| + // 2: [anonymous] |
| + assertEquals("new Point(x=0, y=0)", |
| + exec_state.frame(0).invocationText()); |
| + assertEquals("createPoint(x=0, y=0)", |
| + exec_state.frame(1).invocationText()); |
| + assertEquals("[anonymous]()", exec_state.frame(2).invocationText()); |
| + listenerCalled = true; |
| + } else if (what == 'symbol') { |
| + // The expected backtrace is |
| + // 0: Call Point constructor |
| + // 1: Call on symbol method |
| + // 2: [anonymous] |
| + assertEquals("new Point(x=0, y=0)", |
| + exec_state.frame(0).invocationText()); |
| + assertEquals("#<Object>[Symbol(Das Symbol)](x=0, y=0)", |
| + exec_state.frame(1).invocationText()); |
| + assertEquals("[anonymous]()", exec_state.frame(2).invocationText()); |
| + listenerCalled = true; |
| + } else { |
| + assertUnreachable(); |
| + } |
| } |
| - } |
| } catch (e) { |
| exception = e |
| }; |
| @@ -112,11 +129,21 @@ assertTrue(listenerCalled); |
| assertFalse(exception, "exception in listener") |
| // Set a break point and call to invoke the debug event listener. |
| +what = 'breakpoint'; |
| listenerCalled = false; |
| -testConstructor = true; |
| Debug.setBreakPoint(Point, 0, 0); |
| createPoint(0, 0); |
| // Make sure that the debug event listener vas invoked (again). |
| assertTrue(listenerCalled); |
| assertFalse(exception, "exception in listener") |
| + |
| +what = 'symbol'; |
| +listenerCalled = false; |
| +var S = Symbol('Das Symbol'); |
| +var o = { [S](x, y) { return new Point(x, y); } }; |
| +Debug.setBreakPoint(Point, 0, 0); |
| +o[S](0, 0); |
| + |
| +assertTrue(listenerCalled); |
| +assertFalse(exception, "exception in listener") |