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

Unified Diff: test/codegen/lib/mirrors/generic_mixin_applications_test.dart

Issue 2265533002: Add mirrors tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: test/codegen/lib/mirrors/generic_mixin_applications_test.dart
diff --git a/test/codegen/lib/mirrors/generic_mixin_applications_test.dart b/test/codegen/lib/mirrors/generic_mixin_applications_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..aac6e281fbe946789f48da1eab7a4b81a0629085
--- /dev/null
+++ b/test/codegen/lib/mirrors/generic_mixin_applications_test.dart
@@ -0,0 +1,96 @@
+// 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.
+
+library test.generic_mixin_applications;
+
+import 'dart:mirrors';
+
+import 'package:expect/expect.dart';
+
+import 'generics_helper.dart';
+
+class Super<S> {}
+class Mixin<M> {}
+class Nixim<N> {}
+
+class NonGenericMixinApplication1 = Super with Mixin;
+class NonGenericMixinApplication2 = Super<num> with Mixin<String>;
+
+class GenericMixinApplication1<MA> = Super<MA> with Mixin<MA>;
+class GenericMixinApplication2<MA> = Super<num> with Mixin<String>;
+
+class NonGenericClass1 extends Super with Mixin {}
+class NonGenericClass2 extends Super<num> with Mixin<String> {}
+
+class GenericClass1<C> extends Super<C> with Mixin<C> {}
+class GenericClass2<C> extends Super<num> with Mixin<String> {}
+
+class GenericMultipleMixins<A, B, C> extends Super<A> with Mixin<B>, Nixim<C> {}
+
+main() {
+ TypeMirror dynamicMirror = currentMirrorSystem().dynamicType;
+
+ // Declarations.
+ typeParameters(reflectClass(NonGenericMixinApplication1), []);
+ typeParameters(reflectClass(NonGenericMixinApplication2), []);
+ typeParameters(reflectClass(GenericMixinApplication1), [#MA]);
+ typeParameters(reflectClass(GenericMixinApplication2), [#MA]);
+ typeParameters(reflectClass(NonGenericClass1), []);
+ typeParameters(reflectClass(NonGenericClass2), []);
+ typeParameters(reflectClass(GenericClass1), [#C]);
+ typeParameters(reflectClass(GenericClass2), [#C]);
+ typeParameters(reflectClass(GenericMultipleMixins), [#A, #B, #C]);
+ // Anonymous mixin applications have no type parameters or type arguments.
+ typeParameters(reflectClass(NonGenericClass1).superclass, []);
+ typeParameters(reflectClass(NonGenericClass2).superclass, []);
+ typeParameters(reflectClass(GenericClass1).superclass, []);
+ typeParameters(reflectClass(GenericClass2).superclass, []);
+
+ typeArguments(reflectClass(NonGenericMixinApplication1), []);
+ typeArguments(reflectClass(NonGenericMixinApplication2), []);
+ typeArguments(reflectClass(GenericMixinApplication1), []);
+ typeArguments(reflectClass(GenericMixinApplication2), []);
+ typeArguments(reflectClass(NonGenericClass1), []);
+ typeArguments(reflectClass(NonGenericClass2), []);
+ typeArguments(reflectClass(GenericClass1), []);
+ typeArguments(reflectClass(GenericClass2), []);
+ typeArguments(reflectClass(GenericMultipleMixins), []);
+ // Anonymous mixin applications have no type parameters or type arguments.
+ typeArguments(reflectClass(NonGenericClass1).superclass.originalDeclaration, []);
+ typeArguments(reflectClass(NonGenericClass2).superclass.originalDeclaration, []);
+ typeArguments(reflectClass(GenericClass1).superclass.originalDeclaration, []);
+ typeArguments(reflectClass(GenericClass2).superclass.originalDeclaration, []);
+
+
+ // Instantiations.
+ typeParameters(reflect(new NonGenericMixinApplication1()).type, []);
+ typeParameters(reflect(new NonGenericMixinApplication2()).type, []);
+ typeParameters(reflect(new GenericMixinApplication1<bool>()).type, [#MA]);
+ typeParameters(reflect(new GenericMixinApplication2<bool>()).type, [#MA]);
+ typeParameters(reflect(new NonGenericClass1()).type, []);
+ typeParameters(reflect(new NonGenericClass2()).type, []);
+ typeParameters(reflect(new GenericClass1<bool>()).type, [#C]);
+ typeParameters(reflect(new GenericClass2<bool>()).type, [#C]);
+ typeParameters(reflect(new GenericMultipleMixins<bool, String, int>()).type, [#A, #B, #C]);
+ // Anonymous mixin applications have no type parameters or type arguments.
+ typeParameters(reflect(new NonGenericClass1()).type.superclass, []);
+ typeParameters(reflect(new NonGenericClass2()).type.superclass, []);
+ typeParameters(reflect(new GenericClass1<bool>()).type.superclass, []);
+ typeParameters(reflect(new GenericClass2<bool>()).type.superclass, []);
+
+ typeArguments(reflect(new NonGenericMixinApplication1()).type, []);
+ typeArguments(reflect(new NonGenericMixinApplication2()).type, []);
+ typeArguments(reflect(new GenericMixinApplication1<bool>()).type, [reflectClass(bool)]);
+ typeArguments(reflect(new GenericMixinApplication2<bool>()).type, [reflectClass(bool)]);
+ typeArguments(reflect(new NonGenericClass1()).type, []);
+ typeArguments(reflect(new NonGenericClass2()).type, []);
+ typeArguments(reflect(new GenericClass1<bool>()).type, [reflectClass(bool)]);
+ typeArguments(reflect(new GenericClass2<bool>()).type, [reflectClass(bool)]);
+ typeArguments(reflect(new GenericMultipleMixins<bool, String, int>()).type, [reflectClass(bool), reflectClass(String), reflectClass(int)]);
+ // Anonymous mixin applications have no type parameters or type arguments.
+ typeArguments(reflect(new NonGenericClass1()).type.superclass, []);
+ typeArguments(reflect(new NonGenericClass2()).type.superclass, []);
+ typeArguments(reflect(new GenericClass1<bool>()).type.superclass, []);
+ typeArguments(reflect(new GenericClass2<bool>()).type.superclass, []);
+}
« no previous file with comments | « test/codegen/lib/mirrors/generic_local_function_test.dart ('k') | test/codegen/lib/mirrors/generic_mixin_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698