2014-11-12 08:25:59 +00:00
|
|
|
// 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.
|
|
|
|
|
2016-11-16 08:34:01 +00:00
|
|
|
// Flags: --harmony
|
2014-11-12 08:25:59 +00:00
|
|
|
|
|
|
|
Debug = debug.Debug;
|
|
|
|
var break_count = 0
|
|
|
|
var exception = null;
|
|
|
|
var log = []
|
|
|
|
|
|
|
|
var s = 0;
|
|
|
|
var a = [1, 2, 3];
|
2016-04-25 06:51:44 +00:00
|
|
|
var b = [1, 2, 3, 4];
|
|
|
|
var null_value = null;
|
2014-11-12 08:25:59 +00:00
|
|
|
var i = 0;
|
|
|
|
|
|
|
|
function f() {
|
|
|
|
"use strict";
|
|
|
|
debugger; // Break a
|
|
|
|
var j; // Break b
|
|
|
|
|
2016-04-25 06:51:44 +00:00
|
|
|
for (var i in null_value) { // Break c
|
2014-11-12 08:25:59 +00:00
|
|
|
s += a[i];
|
|
|
|
}
|
|
|
|
|
2016-04-25 06:51:44 +00:00
|
|
|
for (j in null_value) { // Break d
|
2014-11-12 08:25:59 +00:00
|
|
|
s += a[j];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i in a) { // Break e
|
|
|
|
s += a[i]; // Break E
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j in a) { // Break f
|
|
|
|
s += a[j]; // Break F
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let i in a) { // Break g
|
|
|
|
s += a[i]; // Break G
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i of a) { // Break h
|
|
|
|
s += i; // Break H
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j of a) { // Break i
|
|
|
|
s += j; // Break I
|
|
|
|
}
|
|
|
|
|
2016-04-25 06:51:44 +00:00
|
|
|
for (let i of a) { // Break j
|
2014-11-12 08:25:59 +00:00
|
|
|
s += i; // Break J
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i = 0; i < 3; i++) { // Break k
|
|
|
|
s += a[i]; // Break K
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < 3; j++) { // Break l
|
|
|
|
s += a[j]; // Break L
|
|
|
|
}
|
|
|
|
|
2015-07-07 19:11:24 +00:00
|
|
|
for (let i = 0; i < 3; i++) { // Break m
|
|
|
|
s += a[i]; // Break M
|
|
|
|
}
|
2016-04-25 06:51:44 +00:00
|
|
|
|
|
|
|
for (let i of a) {} // Break n
|
|
|
|
|
|
|
|
[1, ...a] // Break o
|
|
|
|
|
2014-11-12 08:25:59 +00:00
|
|
|
} // Break y
|
|
|
|
|
|
|
|
function listener(event, exec_state, event_data, data) {
|
|
|
|
if (event != Debug.DebugEvent.Break) return;
|
|
|
|
try {
|
|
|
|
var line = exec_state.frame(0).sourceLineText();
|
|
|
|
var col = exec_state.frame(0).sourceColumn();
|
|
|
|
print(line);
|
|
|
|
var match = line.match(/\/\/ Break (\w)$/);
|
|
|
|
assertEquals(2, match.length);
|
|
|
|
log.push(match[1] + col);
|
2015-12-16 08:39:39 +00:00
|
|
|
exec_state.prepareStep(Debug.StepAction.StepNext);
|
2014-11-12 08:25:59 +00:00
|
|
|
break_count++;
|
|
|
|
} catch (e) {
|
|
|
|
exception = e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Debug.setListener(listener);
|
|
|
|
f();
|
|
|
|
Debug.setListener(null); // Break z
|
|
|
|
|
2015-05-21 17:47:07 +00:00
|
|
|
print("log:\n"+ JSON.stringify(log));
|
2014-11-12 08:25:59 +00:00
|
|
|
// The let declaration differs from var in that the loop variable
|
|
|
|
// is declared in every iteration.
|
2015-12-02 18:36:39 +00:00
|
|
|
// TODO(verwaest): For-of has hacky position numbers for Symbol.iterator and
|
|
|
|
// .next. Restore to proper positions once the CallPrinter can disambiguate
|
|
|
|
// based on other values.
|
2014-11-12 08:25:59 +00:00
|
|
|
var expected = [
|
|
|
|
// Entry
|
2016-03-01 12:47:27 +00:00
|
|
|
"a2",
|
2015-05-21 17:47:07 +00:00
|
|
|
// Empty for-in-var: get enumerable
|
|
|
|
"c16",
|
2014-11-12 08:25:59 +00:00
|
|
|
// Empty for-in: get enumerable
|
|
|
|
"d12",
|
2015-05-21 17:47:07 +00:00
|
|
|
// For-in-var: get enumerable, assign, body, assign, body, ...
|
|
|
|
"e16","e11","E4","e11","E4","e11","E4","e11",
|
2014-11-12 08:25:59 +00:00
|
|
|
// For-in: get enumerable, assign, body, assign, body, ...
|
|
|
|
"f12","f7","F4","f7","F4","f7","F4","f7",
|
2015-05-21 17:47:07 +00:00
|
|
|
// For-in-let: get enumerable, next, body, next, ...
|
|
|
|
"g16","g11","G4","g11","G4","g11","G4","g11",
|
2015-12-02 18:36:39 +00:00
|
|
|
// For-of-var: [Symbol.iterator](), next(), body, next(), body, ...
|
2017-05-24 12:12:53 +00:00
|
|
|
"h16","h11","H4","h11","H4","h11","H4","h11",
|
2015-12-02 18:36:39 +00:00
|
|
|
// For-of: [Symbol.iterator](), next(), body, next(), body, ...
|
2017-05-24 12:12:53 +00:00
|
|
|
"i12","i7","I4","i7","I4","i7","I4","i7",
|
2015-12-02 18:36:39 +00:00
|
|
|
// For-of-let: [Symbol.iterator](), next(), body, next(), ...
|
2017-05-24 12:12:53 +00:00
|
|
|
"j18","j11","J4","j11","J4","j11","J4","j11",
|
2016-03-11 12:02:37 +00:00
|
|
|
// For-var: init, condition, body, next, condition, body, ...
|
|
|
|
"k15","k20","K4","k26","k20","K4","k26","k20","K4","k26","k20",
|
2014-11-12 08:25:59 +00:00
|
|
|
// For: init, condition, body, next, condition, body, ...
|
2015-08-24 13:08:05 +00:00
|
|
|
"l7","l16","L4","l22","l16","L4","l22","l16","L4","l22","l16",
|
2015-07-07 19:11:24 +00:00
|
|
|
// For-let: init, condition, body, next, condition, body, ...
|
2016-03-07 13:39:49 +00:00
|
|
|
"m15","m20","M4","m26","m20","M4","m26","m20","M4","m26","m20",
|
2016-04-25 06:51:44 +00:00
|
|
|
// For-of, empty: [Symbol.iterator](), next() once
|
2017-05-24 12:12:53 +00:00
|
|
|
"n16", "n11",
|
2016-04-25 06:51:44 +00:00
|
|
|
// Spread: expression statement, spread
|
|
|
|
"o2", "o9",
|
2014-11-12 08:25:59 +00:00
|
|
|
// Exit.
|
|
|
|
"y0","z0",
|
|
|
|
]
|
2015-07-01 00:27:15 +00:00
|
|
|
print("expected:\n"+ JSON.stringify(expected));
|
2014-11-12 08:25:59 +00:00
|
|
|
|
|
|
|
assertArrayEquals(expected, log);
|
2015-07-07 19:11:24 +00:00
|
|
|
assertEquals(54, s);
|
2014-11-12 08:25:59 +00:00
|
|
|
assertNull(exception);
|