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

Unified Diff: pkg/kernel/test/typedef_unalias_test.dart

Issue 2825053002: Add typedef AST node boilerplate. (Closed)
Patch Set: Update FastaVerifyingVisitor to work with the changes in VerifyingVisitor Created 3 years, 8 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 | « pkg/kernel/test/type_parser.dart ('k') | pkg/kernel/test/verify_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/test/typedef_unalias_test.dart
diff --git a/pkg/kernel/test/typedef_unalias_test.dart b/pkg/kernel/test/typedef_unalias_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9457680dc894de34779dd64aba893e7a44657269
--- /dev/null
+++ b/pkg/kernel/test/typedef_unalias_test.dart
@@ -0,0 +1,68 @@
+// Copyright (c) 2016, 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 kernel.typedef_unalias_test;
+
+import 'package:kernel/ast.dart';
+import 'package:test/test.dart';
+import 'verify_test.dart' show TestHarness;
+
+void harnessTest(String name, void doTest(TestHarness harness)) {
+ test(name, () {
+ doTest(new TestHarness());
+ });
+}
+
+main() {
+ harnessTest('`Foo` where typedef Foo = C', (TestHarness harness) {
+ var foo = new Typedef('Foo', harness.otherClass.rawType);
+ harness.enclosingLibrary.addTypedef(foo);
+ var type = new TypedefType(foo);
+ expect(type.unalias, equals(harness.otherClass.rawType));
+ });
+ harnessTest('`Foo<Obj>` where typedef Foo<T> = C<T>', (TestHarness harness) {
+ var param = harness.makeTypeParameter('T');
+ var foo = new Typedef('Foo',
+ new InterfaceType(harness.otherClass, [new TypeParameterType(param)]),
+ typeParameters: [param]);
+ harness.enclosingLibrary.addTypedef(foo);
+ var input = new TypedefType(foo, [harness.objectClass.rawType]);
+ var expected =
+ new InterfaceType(harness.otherClass, [harness.objectClass.rawType]);
+ expect(input.unalias, equals(expected));
+ });
+ harnessTest('`Bar<Obj>` where typedef Bar<T> = Foo<T>, Foo<T> = C<T>',
+ (TestHarness harness) {
+ var fooParam = harness.makeTypeParameter('T');
+ var foo = new Typedef(
+ 'Foo',
+ new InterfaceType(
+ harness.otherClass, [new TypeParameterType(fooParam)]),
+ typeParameters: [fooParam]);
+ var barParam = harness.makeTypeParameter('T');
+ var bar = new Typedef(
+ 'Bar', new TypedefType(foo, [new TypeParameterType(barParam)]),
+ typeParameters: [barParam]);
+ harness.enclosingLibrary.addTypedef(foo);
+ harness.enclosingLibrary.addTypedef(bar);
+ var input = new TypedefType(bar, [harness.objectClass.rawType]);
+ var expected =
+ new InterfaceType(harness.otherClass, [harness.objectClass.rawType]);
+ expect(input.unalias, equals(expected));
+ });
+ harnessTest('`Foo<Foo<C>>` where typedef Foo<T> = C<T>',
+ (TestHarness harness) {
+ var param = harness.makeTypeParameter('T');
+ var foo = new Typedef('Foo',
+ new InterfaceType(harness.otherClass, [new TypeParameterType(param)]),
+ typeParameters: [param]);
+ harness.enclosingLibrary.addTypedef(foo);
+ var input = new TypedefType(foo, [
+ new TypedefType(foo, [harness.objectClass.rawType])
+ ]);
+ var expected = new InterfaceType(harness.otherClass, [
+ new TypedefType(foo, [harness.objectClass.rawType])
+ ]);
+ expect(input.unalias, equals(expected));
+ });
+}
« no previous file with comments | « pkg/kernel/test/type_parser.dart ('k') | pkg/kernel/test/verify_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698