Files
sdk/tests/language/exception/finally11_test.dart
T
Robert Nystrom 74ef393e6d Migrate language_2/exception to NNBD.
Change-Id: I0f758fce0af79be77b2fc885afcc3bd17d9fb55e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142701
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2020-04-07 22:13:46 +00:00

51 lines
1.0 KiB
Dart

// Copyright (c) 2013, 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.
// Regression test for dart2js that used to not treat the finally
// block as a successor of a nested try block.
import "package:expect/expect.dart";
class A {
var field;
start() {}
stop() {
field = 42;
}
}
class B {
var totalCompileTime = new A();
var runCompiler = new Object();
run() {
totalCompileTime.start();
try {
throw 'foo';
} catch (exception) {
try {
// Use [runCompiler] twice to ensure it will have a local
// variable.
runCompiler.toString();
runCompiler.toString();
} catch (exception) {}
rethrow;
} finally {
totalCompileTime.stop();
}
}
}
main() {
var b = new B();
try {
b.run();
throw 'Expected exception';
} catch (exception) {
// Expected exception.
}
Expect.equals(42, b.totalCompileTime.field);
}