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

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

Issue 114593002: VM: Match language error when attempting to reflectively instantiate an abstract class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: sync Created 7 years 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.instantiate_abstract_class;
6
7 import 'dart:mirrors';
8 import 'package:expect/expect.dart';
9
10
11 assertInstanitationErrorOnGenerativeConstructors(classMirror) {
12 classMirror.declarations.values.forEach((decl) {
13 if (decl is! MethodMirror) return;
14 if (!decl.isGenerativeConstructor) return;
15 var args = new List(decl.parameters.length);
16 Expect.throws(() => classMirror.newInstance(decl.constructorName, args),
17 (e) => e is AbstractClassInstantiationError,
18 '${decl.qualifiedName} should have failed');
19 });
20 }
21
22 runFactoryConstructors(classMirror) {
23 classMirror.declarations.values.forEach((decl) {
24 if (decl is! MethodMirror) return;
25 if (!decl.isFactoryConstructor) return;
26 var args = new List(decl.parameters.length);
27 classMirror.newInstance(decl.constructorName, args); // Should not throw.
28 });
29 }
30
31 abstract class AbstractClass {
32 AbstractClass();
33 AbstractClass.named();
34 factory AbstractClass.named2() => new ConcreteClass();
35 }
36
37 class ConcreteClass implements AbstractClass {}
38
39 main() {
40 assertInstanitationErrorOnGenerativeConstructors(reflectType(num));
41 assertInstanitationErrorOnGenerativeConstructors(reflectType(double));
42 assertInstanitationErrorOnGenerativeConstructors(reflectType(StackTrace));
43
44 assertInstanitationErrorOnGenerativeConstructors(reflectType(AbstractClass));
45 runFactoryConstructors(reflectType(AbstractClass));
46 }
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