Chromium Code Reviews| Index: test/mjsunit/debug-liveedit-double-call.js |
| diff --git a/test/mjsunit/debug-liveedit-restart-frame.js b/test/mjsunit/debug-liveedit-double-call.js |
| similarity index 50% |
| copy from test/mjsunit/debug-liveedit-restart-frame.js |
| copy to test/mjsunit/debug-liveedit-double-call.js |
| index d978a9709fb0f7d394b9377d93b65c1fba1109c4..e38d187af7899c1e92b7b5e016cc5ac462873df6 100644 |
| --- a/test/mjsunit/debug-liveedit-restart-frame.js |
| +++ b/test/mjsunit/debug-liveedit-double-call.js |
| @@ -1,4 +1,4 @@ |
| -// Copyright 2012 the V8 project authors. All rights reserved. |
| +// Copyright 2010 the V8 project authors. All rights reserved. |
|
Yang
2012/06/22 08:13:23
Update to 2012.
|
| // Redistribution and use in source and binary forms, with or without |
| // modification, are permitted provided that the following conditions are |
| // met: |
| @@ -30,87 +30,84 @@ |
| Debug = debug.Debug |
| -function FindCallFrame(exec_state, frame_code) { |
| - var number = Number(frame_code); |
| - if (number >= 0) { |
| - return exec_state.frame(number); |
| - } else { |
| - for (var i = 0; i < exec_state.frameCount(); i++) { |
| - var frame = exec_state.frame(i); |
| - var func_mirror = frame.func(); |
| - if (frame_code == func_mirror.name()) { |
| - return frame; |
| - } |
| - } |
| - } |
| - throw new Error("Failed to find function name " + function_name); |
| -} |
| function TestCase(test_scenario, expected_output) { |
| // Global variable, accessed from eval'd script. |
| test_output = ""; |
| - function TestCode() { |
| - function A() { |
| - // Extra stack variable. To make function not slim. |
| - // Restarter doesn't work on slim function when stopped on 'debugger' |
| - // statement. (There is no padding for 'debugger' statement). |
| - var o = {}; |
| - test_output += 'A'; |
| - test_output += '='; |
| - debugger; |
| - return 'Capybara'; |
| - } |
| - function B(p1, p2) { |
| - test_output += 'B'; |
| - return A(); |
| - } |
| - function C() { |
| - test_output += 'C'; |
| - // Function call with argument adaptor is intentional. |
| - return B(); |
| - } |
| - function D() { |
| - test_output += 'D'; |
| - // Function call with argument adaptor is intentional. |
| - return C(1, 2); |
| - } |
| - function E() { |
| - test_output += 'E'; |
| - return D(); |
| - } |
| - function F() { |
| - test_output += 'F'; |
| - return E(); |
| - } |
| - return F(); |
| - } |
| + var script_text_generator = (function() { |
| + var variables = { a: 1, b: 1, c: 1, d: 1, e: 1, f: 1 }; |
| + |
| + return { |
| + get: function() { |
| + return "(function() {\n " + |
| + " function A() {\n " + |
| + " test_output += 'a' + " + variables.a + ";\n " + |
| + " test_output += '=';\n " + |
| + " debugger;\n " + |
| + " return 'Capybara';\n " + |
| + " }\n " + |
| + " function B(p1, p2) {\n " + |
| + " test_output += 'b' + " + variables.b + ";\n " + |
| + " return A();\n " + |
| + " }\n " + |
| + " function C() {\n " + |
| + " test_output += 'c' + " + variables.c + ";\n " + |
| + " // Function call with argument adaptor is intentional.\n " + |
| + " return B();\n " + |
| + " }\n " + |
| + " function D() {\n " + |
| + " test_output += 'd' + " + variables.d + ";\n " + |
| + " // Function call with argument adaptor is intentional.\n " + |
| + " return C(1, 2);\n " + |
| + " }\n " + |
| + " function E() {\n " + |
| + " test_output += 'e' + " + variables.e + ";\n " + |
| + " return D();\n " + |
| + " }\n " + |
| + " function F() {\n " + |
| + " test_output += 'f' + " + variables.f + ";\n " + |
| + " return E();\n " + |
| + " }\n " + |
| + " return F();\n " + |
| + "})\n"; |
| + }, |
| + change: function(var_name) { |
| + variables[var_name]++; |
| + } |
| + }; |
| + })(); |
| + |
| + var test_fun = eval(script_text_generator.get()); |
| + |
| + var script = Debug.findScript(test_fun); |
| var scenario_pos = 0; |
| - function DebuggerStatementHandler(exec_state) { |
| + function DebuggerStatementHandler() { |
| while (true) { |
| assertTrue(scenario_pos < test_scenario.length); |
| - var change_code = test_scenario[scenario_pos++]; |
| - if (change_code == '=') { |
| + var change_var = test_scenario[scenario_pos++]; |
| + if (change_var == '=') { |
| // Continue. |
| return; |
| } |
| - var frame = FindCallFrame(exec_state, change_code); |
| - // Throws if fails. |
| - Debug.LiveEdit.RestartFrame(frame); |
| + script_text_generator.change(change_var); |
| + try { |
| + Debug.LiveEdit.SetScriptSource(script, script_text_generator.get(), false, []); |
|
Yang
2012/06/22 08:13:23
80 char limit.
|
| + } catch (e) { |
| + print("LiveEdit exception: " + e); |
| + throw e; |
| + } |
| } |
| } |
| var saved_exception = null; |
| function listener(event, exec_state, event_data, data) { |
| - if (saved_exception != null) { |
| - return; |
| - } |
| if (event == Debug.DebugEvent.Break) { |
| try { |
| - DebuggerStatementHandler(exec_state); |
| + DebuggerStatementHandler(); |
| } catch (e) { |
| saved_exception = e; |
| } |
| @@ -120,12 +117,11 @@ function TestCase(test_scenario, expected_output) { |
| } |
| Debug.setListener(listener); |
| - assertEquals("Capybara", TestCode()); |
| + assertEquals("Capybara", test_fun()); |
| Debug.setListener(null); |
| if (saved_exception) { |
| print("Exception: " + saved_exception); |
| - print("Stack: " + saved_exception.stack); |
| assertUnreachable(); |
| } |
| @@ -134,20 +130,12 @@ function TestCase(test_scenario, expected_output) { |
| assertEquals(expected_output, test_output); |
| } |
| -TestCase('0==', "FEDCBA=A="); |
| -TestCase('1==', "FEDCBA=BA="); |
| -TestCase('2==', "FEDCBA=CBA="); |
| -TestCase('3==', "FEDCBA=DCBA="); |
| -TestCase('4==', "FEDCBA=EDCBA="); |
| -TestCase('5==', "FEDCBA=FEDCBA="); |
| +TestCase(['='], "f1e1d1c1b1a1="); |
| -TestCase('=', "FEDCBA="); |
| +TestCase(['c', '=', '='], "f1e1d1c1b1a1=c2b1a1="); |
| -TestCase('C==', "FEDCBA=CBA="); |
| +TestCase(['b', 'c', 'd', 'e', '=', '='], "f1e1d1c1b1a1=e2d2c2b2a1="); |
| -TestCase('B=C=A=D==', "FEDCBA=BA=CBA=A=DCBA="); |
| +TestCase(['b', 'c', '=', 'b', 'c', 'd', 'e', '=', '='], "f1e1d1c1b1a1=c2b2a1=e2d2c3b3a1="); |
| -// Successive restarts don't work now and require additional fix. |
| -//TestCase('BCDE==', "FEDCBA=EDCBA="); |
| -//TestCase('BC=BCDE==', "FEDCBA=CBA=EDCBA="); |
| -//TestCase('EF==', "FEDCBA=FEDCBA="); |
| +TestCase(['e', 'f', '=', '='], "f1e1d1c1b1a1=f2e2d1c1b1a1="); |