6cd6d6f6c5
BUG=5024 TEST= Review URL: https://chromiumcodereview.appspot.com//10915163 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@12095 260f80e4-7a28-3924-810f-c04153c831b5
43 lines
1.1 KiB
Dart
43 lines
1.1 KiB
Dart
// Copyright (c) 2011, 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.
|
|
|
|
class MyException { }
|
|
|
|
class MyException1 extends MyException { }
|
|
|
|
class MyException2 extends MyException { }
|
|
|
|
class TryCatchTest {
|
|
static void test1() {
|
|
var foo = 0;
|
|
try {
|
|
throw new MyException1();
|
|
}
|
|
on MyException3 catch (e) { } /// 01: compile-time error
|
|
on on MyException2 catch (e) { } /// 02: compile-time error
|
|
catch MyException2 catch (e) { } /// 03: compile-time error
|
|
catch catch catch (e) { } /// 04: compile-time error
|
|
on (e) { } /// 05: compile-time error
|
|
catch MyException2 catch (e) { } /// 06: compile-time error
|
|
on MyException2 catch (e) {
|
|
foo = 1;
|
|
} on MyException1 catch (e) {
|
|
foo = 2;
|
|
} on MyException catch (e) {
|
|
foo = 3;
|
|
}
|
|
on UndefinedClass /// 07: compile-time error
|
|
catch(e) { foo = 4; }
|
|
Expect.equals(2, foo);
|
|
}
|
|
|
|
static void testMain() {
|
|
test1();
|
|
}
|
|
}
|
|
|
|
main() {
|
|
TryCatchTest.testMain();
|
|
}
|