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

Unified Diff: tests/compiler/dart2js/subtypeset_test.dart

Issue 1304083008: Add ClassSet to support ClassWorld.strictSubtypesOf (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js/class_set_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/subtypeset_test.dart
diff --git a/tests/compiler/dart2js/subtypeset_test.dart b/tests/compiler/dart2js/subtypeset_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..66730410f0fdbc7606bebd82d521a2c6f2c4cdc7
--- /dev/null
+++ b/tests/compiler/dart2js/subtypeset_test.dart
@@ -0,0 +1,81 @@
+// Copyright (c) 2015, 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 for iterators on for [SubclassNode].
+
+library world_test;
+
+import 'package:expect/expect.dart';
+import 'package:async_helper/async_helper.dart';
+import 'type_test_helper.dart';
+import 'package:compiler/src/elements/elements.dart'
+ show Element, ClassElement;
+import 'package:compiler/src/universe/class_set.dart';
+import 'package:compiler/src/world.dart';
+
+void main() {
+ asyncTest(() => TypeEnvironment.create(r"""
+ /// A
+ /// / \
+ /// B C
+ /// / /|\
+ /// D E F G
+ ///
+ class A {
+ call(H h, I i) {} // Make `H` and `I` part of the world.
+ }
+ class B extends A implements C {}
+ class C extends A {}
+ class D extends B implements A {}
+ class E extends C implements B {}
+ class F extends C {}
+ class G extends C {}
+ class H implements C {}
+ class I implements H {}
+ """,
+ mainSource: r"""
+ main() {
+ new A();
+ new C();
+ new D();
+ new E();
+ new F();
+ new G();
+ }
+ """,
+ useMockCompiler: false).then((env) {
+ World world = env.compiler.world;
+
+ ClassElement A = env.getElement("A");
+ ClassElement B = env.getElement("B");
+ ClassElement C = env.getElement("C");
+ ClassElement D = env.getElement("D");
+ ClassElement E = env.getElement("E");
+ ClassElement F = env.getElement("F");
+ ClassElement G = env.getElement("G");
+ ClassElement H = env.getElement("H");
+ ClassElement I = env.getElement("I");
+
+ void checkClass(ClassElement cls,
+ List<ClassElement> subtypes) {
+ ClassSet node = world.getClassSet(cls);
+ print('$cls:\n${node}');
+ Expect.listEquals(subtypes,
+ node.subtypes().toList(),
+ "Unexpected subtypes of ${cls.name}:\n"
+ "Expected: $subtypes\n"
+ "Found : ${node.subtypes().toList()}");
+ }
+
+ checkClass(A, [A, C, E, F, G, B, D, H, I]);
+ checkClass(B, [B, D, E]);
+ checkClass(C, [C, E, F, G, H, B, D, I]);
+ checkClass(D, [D]);
+ checkClass(E, [E]);
+ checkClass(F, [F]);
+ checkClass(G, [G]);
+ checkClass(H, [H, I]);
+ checkClass(I, [I]);
+ }));
+}
« no previous file with comments | « tests/compiler/dart2js/class_set_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698