6129842d74
The new formatter supports opting a region of code out from being formatted. I'm applying this marker to all of the multitests since those tests are often very sensitive to formatting and easily broken. This way, anyone touching a multitest (including me when I reformat the tests) doesn't have to remember to not run the formatter on it. Change-Id: I06928e08530ad658affd23e594702cff658d8035 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396181 Commit-Queue: Bob Nystrom <rnystrom@google.com> Commit-Queue: Brian Quinlan <bquinlan@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Brian Quinlan <bquinlan@google.com>
183 lines
4.0 KiB
Dart
183 lines
4.0 KiB
Dart
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// Formatting can break multitests, so don't format them.
|
|
// dart format off
|
|
|
|
class SubclassOfError extends Error {}
|
|
|
|
fail() => throw "Fail";
|
|
|
|
// == Rethrow, skipping through typed handlers. ==
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
aa1() {
|
|
try {
|
|
bb1();
|
|
fail();
|
|
} on Error catch (error
|
|
, stacktrace // //# withtraceparameter: ok
|
|
) {
|
|
expectTrace(
|
|
['gg1', 'ff1', 'ee1', 'dd1', 'cc1', 'bb1', 'aa1'], error.stackTrace);
|
|
expectTrace(['gg1', 'ff1', 'ee1', 'dd1', 'cc1', 'bb1', 'aa1'], stacktrace); // //# withtraceparameter: continued
|
|
}
|
|
}
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
bb1() => cc1();
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
cc1() {
|
|
try {
|
|
dd1();
|
|
} on String catch (_) {
|
|
fail();
|
|
} on int catch (_) {
|
|
fail();
|
|
}
|
|
}
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
dd1() => ee1();
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
ee1() {
|
|
try {
|
|
ff1();
|
|
} catch (_) {
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
ff1() => gg1();
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
gg1() => throw new SubclassOfError();
|
|
|
|
// == Rethrow, rethrow again in typed handler. ==
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
aa2() {
|
|
try {
|
|
bb2();
|
|
fail();
|
|
} on Error catch (error
|
|
, stacktrace // //# withtraceparameter: continued
|
|
) {
|
|
expectTrace(
|
|
['gg2', 'ff2', 'ee2', 'dd2', 'cc2', 'bb2', 'aa2'], error.stackTrace);
|
|
expectTrace(['gg2', 'ff2', 'ee2', 'dd2', 'cc2', 'bb2', 'aa2'], stacktrace); // //# withtraceparameter: continued
|
|
}
|
|
}
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
bb2() => cc2();
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
cc2() {
|
|
try {
|
|
dd2();
|
|
} on SubclassOfError catch (_) {
|
|
rethrow;
|
|
} on int catch (_) {
|
|
fail();
|
|
}
|
|
}
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
dd2() => ee2();
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
ee2() {
|
|
try {
|
|
ff2();
|
|
} catch (e) {
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
ff2() => gg2();
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
gg2() => throw new SubclassOfError();
|
|
|
|
// == Rethrow, with intervening catch without a trace parameter.
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
aa3() {
|
|
try {
|
|
bb3();
|
|
fail();
|
|
} on Error catch (error
|
|
, stacktrace // //# withtraceparameter: continued
|
|
) {
|
|
expectTrace(
|
|
['gg3', 'ff3', 'ee3', 'dd3', 'cc3', 'bb3', 'aa3'], error.stackTrace);
|
|
expectTrace(['cc3', 'bb3', 'aa3'], stacktrace); // //# withtraceparameter: continued
|
|
}
|
|
}
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
bb3() => cc3();
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
cc3() {
|
|
try {
|
|
dd3();
|
|
} catch (e) {
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
dd3() => ee3();
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
ee3() {
|
|
try {
|
|
ff3();
|
|
} catch (_) {
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
ff3() => gg3();
|
|
|
|
@pragma("vm:entry-point") // Prevent obfuscation
|
|
gg3() => throw new SubclassOfError();
|
|
|
|
expectTrace(functionNames, stacktrace) {
|
|
// Note we don't expect functionNames to cover the whole trace, only the
|
|
// top portion, because the frames below main are an implementation detail.
|
|
var traceLines = stacktrace.toString().split('\n');
|
|
var expectedIndex = 0;
|
|
var actualIndex = 0;
|
|
print(stacktrace);
|
|
print(functionNames);
|
|
while (expectedIndex < functionNames.length) {
|
|
var expected = functionNames[expectedIndex];
|
|
var actual = traceLines[actualIndex];
|
|
if (actual.indexOf(expected) == -1) {
|
|
if (expectedIndex == 0) {
|
|
actualIndex++; // Skip over some helper frames at the top
|
|
} else {
|
|
throw "Expected: $expected actual: $actual";
|
|
}
|
|
} else {
|
|
actualIndex++;
|
|
expectedIndex++;
|
|
}
|
|
}
|
|
}
|
|
|
|
main() {
|
|
aa1();
|
|
aa2();
|
|
aa3();
|
|
}
|