mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 23:31:42 +00:00
e166ab3e2b
Successfully migrated 7 tests. Need manual work on 6 tests: - language_2/try_catch_test.dart: (TODO) Merge from language/try_catch_test.dart into this file. - language_2/type_argument_in_super_type_test.dart: (TODO) Ensure code that checks for a TypeError uses 2.0 semantics. - language_2/type_check_const_function_typedef2_test.dart: (TODO) Fix code that mentions "checked" mode. - language_2/type_checks_in_factory_method_test.dart: (TODO) Ensure code that checks for a TypeError uses 2.0 semantics. - language_2/type_conversion_ssa_test.dart: (TODO) Fix code that mentions "checked" mode. - language_2/type_error_test.dart: (TODO) Merge from language/type_error_test.dart into this file. (TODO) Ensure code that checks for a TypeError uses 2.0 semantics. Bug: Change-Id: I43901890540efcf55da13d013571ce91979cbb64 Reviewed-on: https://dart-review.googlesource.com/11142 Commit-Queue: Janice Collins <jcollins@google.com> Reviewed-by: Janice Collins <jcollins@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com>
65 lines
1.3 KiB
Dart
65 lines
1.3 KiB
Dart
// Copyright (c) 2016, 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.
|
|
|
|
// Test correct handling of try-catch inside try-finally.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
void main() {
|
|
print("== test1 ==");
|
|
bool caught = false;
|
|
try {
|
|
test1();
|
|
print("Unexpected 1"); // should never go here
|
|
Expect.isTrue(false);
|
|
} catch (e) {
|
|
caught = true;
|
|
print("main catch 1: $e");
|
|
Expect.equals(e, "Ball");
|
|
}
|
|
Expect.isTrue(caught);
|
|
print("== test2 ==");
|
|
caught = false;
|
|
try {
|
|
test2();
|
|
print("Unexpected 2"); // should never go here
|
|
Expect.isTrue(false);
|
|
} catch (e) {
|
|
caught = true;
|
|
print("main catch 2: $e");
|
|
Expect.equals(e, "Ball");
|
|
}
|
|
Expect.isTrue(caught);
|
|
}
|
|
|
|
void test1() {
|
|
try {
|
|
throw "Ball";
|
|
} finally {
|
|
try {
|
|
throw "Frisbee";
|
|
} catch (e) {
|
|
print("test 1 catch: $e");
|
|
Expect.equals(e, "Frisbee");
|
|
}
|
|
}
|
|
}
|
|
|
|
void test2() {
|
|
try {
|
|
throwError(); // call a method that throws an error
|
|
} finally {
|
|
try {
|
|
throw "Frisbee";
|
|
} catch (e) {
|
|
print("test 2 catch: $e");
|
|
Expect.equals(e, "Frisbee");
|
|
}
|
|
}
|
|
}
|
|
|
|
void throwError() {
|
|
throw "Ball";
|
|
}
|