mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 08:02:06 +00:00

PR-URL: https://github.com/nodejs/node/pull/28016 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
// Copyright 2019 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.
|
|
|
|
(function() {
|
|
|
|
function Simple() {
|
|
new Error("Simple Error");
|
|
}
|
|
|
|
class CustomError extends Error {};
|
|
function Custom() {
|
|
new CustomError("Custom Error");
|
|
}
|
|
|
|
function Inline() {
|
|
function Inner() {
|
|
new Error("Error from inlined function!");
|
|
}
|
|
function Middle() { Inner(); }
|
|
function Outer() { Middle(); }
|
|
|
|
%PrepareFunctionForOptimization(Outer);
|
|
Outer();
|
|
Outer();
|
|
%OptimizeFunctionOnNextCall(Outer);
|
|
Outer();
|
|
}
|
|
|
|
const kInitialRecursionValue = 10;
|
|
function Recursive() {
|
|
function StepOne(val) {
|
|
if (val <= 0) return new Error("Error in StepOne!");
|
|
StepTwo(val - 3);
|
|
StepTwo(val - 4);
|
|
}
|
|
function StepTwo(val) {
|
|
if (val <= 0) return new Error("Error in StepTwo!");
|
|
StepOne(val - 1);
|
|
StepOne(val - 2);
|
|
}
|
|
|
|
StepOne(kInitialRecursionValue);
|
|
}
|
|
|
|
createSuite('Simple-Capture-Error', 1000, Simple, () => {});
|
|
createSuite('Custom-Capture-Error', 1000, Custom, () => {});
|
|
|
|
createSuite('Inline-Capture-Error', 1000, Inline, () => {});
|
|
createSuite('Recursive-Capture-Error', 1000, Recursive, () => {});
|
|
|
|
})();
|