Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: tests/lib/mirrors/invoke_throws_test.dart

Issue 23994007: Properly handle exceptions that arise when reflectively invoking a constructor/factory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.invoke_throws_test;
6
7 import 'dart:mirrors';
8
9 import 'package:expect/expect.dart';
10
11 class MyException {
12 }
13
14 class Class {
15 Class.noException();
16 Class.generative() { throw new MyException(); }
17 Class.redirecting() : this.generative();
18 factory Class.faktory() { throw new MyException(); }
19 factory Class.redirectingFactory() = Class.faktory;
20
21 get getter { throw new MyException(); }
22 set setter(v) { throw new MyException(); }
23 method() { throw new MyException(); }
24
25 noSuchMethod(invocation) { throw new MyException(); }
26
27 static get staticGetter { throw new MyException(); }
28 static set staticSetter(v) { throw new MyException(); }
29 static staticFunction() { throw new MyException(); }
30 }
31
32 get libraryGetter { throw new MyException(); }
33 set librarySetter(v) { throw new MyException(); }
34 libraryFunction() { throw new MyException(); }
35
36 main() {
37 InstanceMirror im = reflect(new Class.noException());
38 Expect.throws(() => im.getField(const Symbol('getter')),
39 (e) => e is MyException);
40 Expect.throws(() => im.setField(const Symbol('setter'), ['arg']),
41 (e) => e is MyException);
42 Expect.throws(() => im.invoke(const Symbol('method'), []),
43 (e) => e is MyException);
44 Expect.throws(() => im.invoke(const Symbol('triggerNoSuchMethod'), []),
45 (e) => e is MyException);
46
47 ClassMirror cm = reflectClass(Class);
48 Expect.throws(() => cm.getField(const Symbol('staticGetter')),
49 (e) => e is MyException);
50 Expect.throws(() => cm.setField(const Symbol('staticSetter'), ['arg']),
51 (e) => e is MyException);
52 Expect.throws(() => cm.invoke(const Symbol('staticFunction'), []),
53 (e) => e is MyException);
54 Expect.throws(() => cm.newInstance(const Symbol('generative'), []),
55 (e) => e is MyException);
56 Expect.throws(() => cm.newInstance(const Symbol('redirecting'), []),
57 (e) => e is MyException);
58 Expect.throws(() => cm.newInstance(const Symbol('faktory'), []),
59 (e) => e is MyException);
60 Expect.throws(() => cm.newInstance(const Symbol('redirectingFactory'), []),
61 (e) => e is MyException);
62
63 LibraryMirror lm = reflectClass(Class).owner;
64 Expect.throws(() => lm.getField(const Symbol('libraryGetter')),
65 (e) => e is MyException);
66 Expect.throws(() => lm.setField(const Symbol('librarySetter'), ['arg']),
67 (e) => e is MyException);
68 Expect.throws(() => lm.invoke(const Symbol('libraryFunction'), []),
69 (e) => e is MyException);
70 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698