blob: db0878d7a9ecd96a9bfeb684ed29adfe5f633112 [file] [log] [blame]
Ben Murdochda12d292016-06-02 14:46:10 +01001// Copyright 2016 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --expose-debug-as debug --harmony-tailcalls
6
7"use strict";
8
9var Debug = debug.Debug
10var exception = null;
11var breaks = 0;
12
13function f(x) {
14 if (x > 0) {
15 return f(x - 1); // Tail call
16 }
17 debugger; // Break 0
18}
19
20function g(x) {
21 return f(x); // Tail call
22}
23
24function h(x) {
25 g(x); // Not tail call
26} // Break 1
27
28
29function listener(event, exec_state, event_data, data) {
30 if (event != Debug.DebugEvent.Break) return;
31 try {
32 assertTrue(event_data.sourceLineText().indexOf(`Break ${breaks++}`) > 0);
33 exec_state.prepareStep(Debug.StepAction.StepOut);
34 } catch (e) {
35 exception = e;
36 };
37};
38
39Debug.setListener(listener);
40
41h(3);
42
43Debug.setListener(null); // Break 2
44assertNull(exception);
45assertEquals(3, breaks);