2015-12-22 13:28:34 +00:00
|
|
|
// Copyright 2015 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.
|
|
|
|
|
|
|
|
|
|
|
|
var exception = null;
|
|
|
|
var Debug = debug.Debug;
|
|
|
|
var break_count = 0;
|
|
|
|
|
|
|
|
function listener(event, exec_state, event_data, data) {
|
|
|
|
if (event != Debug.DebugEvent.Break) return;
|
|
|
|
try {
|
|
|
|
var source = exec_state.frame(0).sourceLineText();
|
|
|
|
print(source, break_count);
|
|
|
|
assertTrue(source.indexOf(`B${break_count++}`) > 0);
|
|
|
|
if (source.indexOf("assertEquals") > 0) {
|
|
|
|
exec_state.prepareStep(Debug.StepAction.StepNext);
|
|
|
|
} else {
|
|
|
|
exec_state.prepareStep(Debug.StepAction.StepIn);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
exception = e;
|
|
|
|
print(e);
|
2019-01-09 13:21:06 +00:00
|
|
|
} // B34
|
2015-12-22 13:28:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Debug.setListener(listener);
|
|
|
|
|
2019-01-09 13:21:06 +00:00
|
|
|
var id = x => x; // B11 B12 B42 B43
|
2015-12-22 13:28:34 +00:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
debugger; // B0
|
|
|
|
function fx1([
|
2019-01-09 13:21:06 +00:00
|
|
|
a, // B3
|
|
|
|
b // B4
|
|
|
|
]) { // B2
|
|
|
|
assertEquals([1, 2], [a, b]); // B5
|
|
|
|
} // B6
|
2015-12-22 13:28:34 +00:00
|
|
|
fx1([1, 2, 3]); // B1
|
|
|
|
|
|
|
|
function f2([
|
2019-01-09 13:21:06 +00:00
|
|
|
a, // B9
|
|
|
|
b = id(3) // B10
|
|
|
|
]) { // B8
|
|
|
|
assertEquals([4, 3], [a, b]); // B13
|
|
|
|
} // B14
|
|
|
|
f2([4]); // B7
|
2015-12-22 13:28:34 +00:00
|
|
|
|
|
|
|
function f3({
|
2019-01-09 13:21:06 +00:00
|
|
|
x: a, // B17
|
|
|
|
y: b // B18
|
|
|
|
}) { // B16
|
|
|
|
assertEquals([5, 6], [a, b]); // B19
|
|
|
|
} // B20
|
|
|
|
f3({y: 6, x: 5}); // B15
|
2015-12-22 13:28:34 +00:00
|
|
|
|
|
|
|
function f4([
|
2019-01-09 13:21:06 +00:00
|
|
|
a, // B23
|
2015-12-22 13:28:34 +00:00
|
|
|
{
|
2019-01-09 13:21:06 +00:00
|
|
|
b, // B24
|
|
|
|
c, // B25
|
2015-12-22 13:28:34 +00:00
|
|
|
}
|
2019-01-09 13:21:06 +00:00
|
|
|
]) { // B22
|
|
|
|
assertEquals([2, 4, 6], [a, b, c]); // B26
|
|
|
|
} // B27
|
|
|
|
f4([2, {c: 6, b: 4}]); // B21
|
2015-12-22 13:28:34 +00:00
|
|
|
|
|
|
|
function f5([
|
|
|
|
{
|
2019-01-09 13:21:06 +00:00
|
|
|
a, // B30
|
|
|
|
b = 7 // B31
|
2015-12-22 13:28:34 +00:00
|
|
|
},
|
2019-01-09 13:21:06 +00:00
|
|
|
c = 3 // B32
|
|
|
|
] = [{a:1}]) { // B29
|
|
|
|
assertEquals([1, 7, 3], [a, b, c]); // B33
|
|
|
|
} // B34
|
|
|
|
f5(); // B28
|
2015-12-22 13:28:34 +00:00
|
|
|
|
2019-01-09 13:21:06 +00:00
|
|
|
var name = "x"; // B35
|
2015-12-22 13:28:34 +00:00
|
|
|
function f6({
|
2019-01-09 13:21:06 +00:00
|
|
|
[id(name)]: a, // B40 B41
|
|
|
|
b = a // B44
|
|
|
|
}) { // B39
|
|
|
|
assertEquals([9, 9], [a, b]); // B45
|
|
|
|
} // B46
|
|
|
|
var o6 = {}; // B36
|
|
|
|
o6[name] = 9; // B37
|
|
|
|
f6(o6); // B38
|
2015-12-22 13:28:34 +00:00
|
|
|
|
|
|
|
try {
|
2019-01-09 13:21:06 +00:00
|
|
|
throw [3, 4]; // B47
|
2015-12-22 13:28:34 +00:00
|
|
|
} catch ([
|
2019-01-09 13:21:06 +00:00
|
|
|
a, // B49
|
|
|
|
b, // B50
|
|
|
|
c = 6 // B51
|
|
|
|
]) { // B48
|
|
|
|
assertEquals([3, 4, 6], [a, b, c]); // B52
|
2015-12-22 13:28:34 +00:00
|
|
|
}
|
|
|
|
|
2016-03-01 12:47:27 +00:00
|
|
|
var {
|
2019-01-09 13:21:06 +00:00
|
|
|
x: a, // B54
|
|
|
|
y: b = 9 // B55
|
|
|
|
} = { x: 4 }; // B53
|
|
|
|
assertEquals([4, 9], [a, b]); // B56
|
|
|
|
} // B57
|
2015-12-22 13:28:34 +00:00
|
|
|
|
|
|
|
test();
|
2019-01-09 13:21:06 +00:00
|
|
|
Debug.setListener(null); // B58
|
2015-12-22 13:28:34 +00:00
|
|
|
assertNull(exception);
|