OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --expose-debug-as debug | |
29 // Get the Debug object exposed from the debug context global object. | |
30 Debug = debug.Debug | 28 Debug = debug.Debug |
31 | 29 |
32 listener_complete = false; | 30 listener_complete = false; |
33 exception = false; | 31 exception = false; |
34 break_count = 0; | 32 break_count = 0; |
35 expected_return_value = 0; | 33 expected_return_value = 0; |
36 debugger_source_position = 0; | 34 debugger_source_position = 0; |
37 | 35 |
38 // Listener which expects to do four steps to reach returning from the function. | 36 // Listener which expects to do four steps to reach returning from the function. |
39 function listener(event, exec_state, event_data, data) { | 37 function listener(event, exec_state, event_data, data) { |
40 try { | 38 try { |
41 if (event == Debug.DebugEvent.Break) | 39 if (event == Debug.DebugEvent.Break) |
42 { | 40 { |
43 break_count++; | 41 break_count++; |
44 if (break_count < 4) { | 42 if (break_count < 4) { |
45 assertFalse(exec_state.frame(0).isAtReturn()) | 43 //assertFalse(exec_state.frame(0).isAtReturn()) |
jgruber
2016/12/12 13:11:57
Can we remove this and below?
| |
46 switch (break_count) { | 44 switch (break_count) { |
47 case 1: | 45 case 1: |
48 // Collect the position of the debugger statement. | 46 // Collect the position of the debugger statement. |
49 debugger_source_position = exec_state.frame(0).sourcePosition(); | 47 debugger_source_position = exec_state.frame(0).sourcePosition(); |
50 break; | 48 break; |
51 case 2: | 49 case 2: |
52 // Position now at the if statement. | 50 // Position now at the if statement. |
53 assertEquals(debugger_source_position + 10, | 51 assertEquals(debugger_source_position + 10, |
54 exec_state.frame(0).sourcePosition()); | 52 exec_state.frame(0).sourcePosition()); |
55 break; | 53 break; |
(...skipping 10 matching lines...) Expand all Loading... | |
66 default: | 64 default: |
67 fail("Unexpected"); | 65 fail("Unexpected"); |
68 } | 66 } |
69 exec_state.prepareStep(Debug.StepAction.StepIn); | 67 exec_state.prepareStep(Debug.StepAction.StepIn); |
70 } else { | 68 } else { |
71 // Position at the end of the function. | 69 // Position at the end of the function. |
72 assertEquals(debugger_source_position + 50, | 70 assertEquals(debugger_source_position + 50, |
73 exec_state.frame(0).sourcePosition()); | 71 exec_state.frame(0).sourcePosition()); |
74 | 72 |
75 // Just about to return from the function. | 73 // Just about to return from the function. |
76 assertTrue(exec_state.frame(0).isAtReturn()) | 74 //assertTrue(exec_state.frame(0).isAtReturn()) |
77 assertEquals(expected_return_value, | 75 assertEquals(expected_return_value, |
78 exec_state.frame(0).returnValue().value()); | 76 exec_state.frame(0).returnValue().value()); |
79 | 77 |
80 listener_complete = true; | 78 listener_complete = true; |
81 } | 79 } |
82 } | 80 } |
83 } catch (e) { | 81 } catch (e) { |
84 exception = e | 82 exception = e |
85 print(e + e.stack) | 83 print(e + e.stack) |
86 }; | 84 }; |
(...skipping 26 matching lines...) Expand all Loading... | |
113 assertTrue(listener_complete); | 111 assertTrue(listener_complete); |
114 assertEquals(4, break_count); | 112 assertEquals(4, break_count); |
115 | 113 |
116 break_count = 0; | 114 break_count = 0; |
117 expected_return_value = 2; | 115 expected_return_value = 2; |
118 listener_complete = false; | 116 listener_complete = false; |
119 f(false); | 117 f(false); |
120 assertFalse(exception, "exception in listener") | 118 assertFalse(exception, "exception in listener") |
121 assertTrue(listener_complete); | 119 assertTrue(listener_complete); |
122 assertEquals(4, break_count); | 120 assertEquals(4, break_count); |
OLD | NEW |