1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
28 // Flags: --expose-debug-as debug --nocrankshaft
29 // Get the Debug object exposed from the debug context global object.
35 // Simple debug event handler which first time will cause 'step in' action
36 // to get into g.call and than check that execution is stopped inside
38 function listener(event, exec_state, event_data, data) {
40 if (event == Debug.DebugEvent.Break) {
42 exec_state.prepareStep(Debug.StepAction.StepIn, 3);
44 } else if (state == 2) {
45 assertTrue(event_data.sourceLineText().indexOf("Expected to step") > 0,
46 "source line: \"" + event_data.sourceLineText() + "\"");
51 print("Exception: " + e);
56 // Add the debug event listener.
57 Debug.setListener(listener);
63 return count; // Expected to step
68 function testCall_Dots() {
73 function testCall_Quotes() {
78 function testCall_Call() {
83 function testCall_Apply() {
88 function testCall_Variable() {
89 var functionName = "fun";
94 function testCall_Fun2() {
99 function testCall_InternStrings() {
100 var cache = { "fun": "fun" };
101 var functionName = "fu" + "n";
103 obj[cache[functionName]]();
106 function testCall_ViaFunRef() {
107 var functionName = "fu" + "n";
108 var funRef = obj[functionName];
114 function testCall_RuntimeVariable1() {
115 var functionName = "fu" + "n";
121 function testCall_RuntimeVariable2() {
122 var functionName = "un".replace(/u/, "fu");
128 function testCall_RuntimeVariable3() {
129 var expr = "fu" + "n";
130 const functionName = expr;
131 assertEquals("fun", functionName);
136 var functionsCalled = 0;
137 for (var n in this) {
138 if (n.substr(0, 4) != 'test' || typeof this[n] !== "function") {
142 print("Running " + n + "...");
145 assertNull(exception, n);
146 assertEquals(3, state, n);
147 assertEquals(functionsCalled, count, n);
150 assertEquals(11, functionsCalled);
152 // Get rid of the debug event listener.
153 Debug.setListener(null);