regress-3225.js 1.37 KB
Newer Older
1 2 3 4
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
// Flags: --noalways-opt
6 7 8 9 10 11 12 13 14 15 16 17

Debug = debug.Debug

var debug_step = 0;
var failure = null;

function listener(event, exec_state, event_data, data) {
  if (event != Debug.DebugEvent.Break) return;
  try {
    if (debug_step == 0) {
      assertEquals(1, exec_state.frame(0).evaluate('a').value());
      assertEquals(3, exec_state.frame(0).evaluate('b').value());
18
      exec_state.frame(0).evaluate("a = 4").value();
19 20
      debug_step++;
    } else {
21
      assertEquals(4, exec_state.frame(0).evaluate('a').value());
22
      assertEquals(3, exec_state.frame(0).evaluate('b').value());
23
      exec_state.frame(0).evaluate("set_a_to_5()");
24
      exec_state.frame(0).evaluate("b = 5").value();
25 26 27 28 29 30 31 32 33
    }
  } catch (e) {
    failure = e;
  }
}

Debug.setListener(listener);

function* generator(a, b) {
34
  function set_a_to_5() { a = 5 }
35 36
  // Make sure set_a_to_5 is 'used' so that it is visible to the debugger.
  set_a_to_5;
37 38 39 40 41
  var b = 3;  // Shadows a parameter.
  debugger;
  yield a;
  yield b;
  debugger;
42
  yield a;
43 44 45 46 47
  return b;
}

var foo = generator(1, 2);

48
assertEquals(4, foo.next().value);
49 50
assertEquals(3, foo.next().value);
assertEquals(5, foo.next().value);
51
assertEquals(5, foo.next().value);
52 53 54
assertNull(failure);

Debug.setListener(null);