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) {
|
2021-06-01 08:32:39 +00:00
|
|
|
exec_state.prepareStep(Debug.StepAction.StepOver);
|
2015-12-22 13:28:34 +00:00
|
|
|
} else {
|
2021-06-01 08:32:39 +00:00
|
|
|
exec_state.prepareStep(Debug.StepAction.StepInto);
|
2015-12-22 13:28:34 +00:00
|
|
|
}
|
|
|
|
} 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-23 12:49:23 +00:00
|
|
|
var id = x => x; // B9 B10 B36 B37
|
2015-12-22 13:28:34 +00:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
debugger; // B0
|
|
|
|
function fx1([
|
2019-01-23 12:49:23 +00:00
|
|
|
a, // B2
|
|
|
|
b // B3
|
|
|
|
]) {
|
|
|
|
assertEquals([1, 2], [a, b]); // B4
|
|
|
|
} // B5
|
2015-12-22 13:28:34 +00:00
|
|
|
fx1([1, 2, 3]); // B1
|
|
|
|
|
|
|
|
function f2([
|
2019-01-23 12:49:23 +00:00
|
|
|
a, // B7
|
|
|
|
b = id(3) // B8
|
|
|
|
]) {
|
|
|
|
assertEquals([4, 3], [a, b]); // B11
|
|
|
|
} // B12
|
|
|
|
f2([4]); // B6
|
2015-12-22 13:28:34 +00:00
|
|
|
|
|
|
|
function f3({
|
2019-01-23 12:49:23 +00:00
|
|
|
x: a, // B14
|
|
|
|
y: b // B15
|
|
|
|
}) {
|
|
|
|
assertEquals([5, 6], [a, b]); // B16
|
|
|
|
} // B17
|
|
|
|
f3({y: 6, x: 5}); // B13
|
2015-12-22 13:28:34 +00:00
|
|
|
|
|
|
|
function f4([
|
2019-01-23 12:49:23 +00:00
|
|
|
a, // B19
|
2015-12-22 13:28:34 +00:00
|
|
|
{
|
2019-01-23 12:49:23 +00:00
|
|
|
b, // B20
|
|
|
|
c, // B21
|
2015-12-22 13:28:34 +00:00
|
|
|
}
|
2019-01-23 12:49:23 +00:00
|
|
|
]) { // B19
|
|
|
|
assertEquals([2, 4, 6], [a, b, c]); // B22
|
|
|
|
} // B23
|
|
|
|
f4([2, {c: 6, b: 4}]); // B18
|
2015-12-22 13:28:34 +00:00
|
|
|
|
|
|
|
function f5([
|
|
|
|
{
|
2019-01-23 12:49:23 +00:00
|
|
|
a, // B25
|
|
|
|
b = 7 // B26
|
2015-12-22 13:28:34 +00:00
|
|
|
},
|
2019-01-23 12:49:23 +00:00
|
|
|
c = 3 // B27
|
|
|
|
] = [{a:1}]) {
|
|
|
|
assertEquals([1, 7, 3], [a, b, c]); // B28
|
|
|
|
} // B29
|
|
|
|
f5(); // B24
|
2015-12-22 13:28:34 +00:00
|
|
|
|
2019-01-23 12:49:23 +00:00
|
|
|
var name = "x"; // B30
|
2015-12-22 13:28:34 +00:00
|
|
|
function f6({
|
2019-01-23 12:49:23 +00:00
|
|
|
[id(name)]: a, // B34 B35
|
|
|
|
b = a // B38
|
|
|
|
}) {
|
|
|
|
assertEquals([9, 9], [a, b]); // B39
|
|
|
|
} // B40
|
|
|
|
var o6 = {}; // B31
|
|
|
|
o6[name] = 9; // B32
|
|
|
|
f6(o6); // B33
|
2015-12-22 13:28:34 +00:00
|
|
|
|
|
|
|
try {
|
2019-01-23 12:49:23 +00:00
|
|
|
throw [3, 4]; // B41
|
2015-12-22 13:28:34 +00:00
|
|
|
} catch ([
|
2019-01-23 12:49:23 +00:00
|
|
|
a, // B42
|
|
|
|
b, // B43
|
|
|
|
c = 6 // B44
|
|
|
|
]) {
|
|
|
|
assertEquals([3, 4, 6], [a, b, c]); // B45
|
2015-12-22 13:28:34 +00:00
|
|
|
}
|
|
|
|
|
2016-03-01 12:47:27 +00:00
|
|
|
var {
|
2019-01-23 12:49:23 +00:00
|
|
|
x: a, // B47
|
|
|
|
y: b = 9 // B48
|
|
|
|
} = { x: 4 }; // B46
|
|
|
|
assertEquals([4, 9], [a, b]); // B49
|
|
|
|
} // B50
|
2015-12-22 13:28:34 +00:00
|
|
|
|
|
|
|
test();
|
2019-01-23 12:49:23 +00:00
|
|
|
Debug.setListener(null); // B51
|
2015-12-22 13:28:34 +00:00
|
|
|
assertNull(exception);
|