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

Unified Diff: test/codegen/language/type_literal_test.dart

Issue 1944483002: Redo how Type objects are exposed from DDC. (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: More tweaks. Created 4 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 | « test/codegen/expect/misc.js ('k') | tool/input_sdk/lib/js/dart2js/js_dart2js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/language/type_literal_test.dart
diff --git a/test/codegen/language/type_literal_test.dart b/test/codegen/language/type_literal_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d689a0dc5e783f02a29dc00274e435efb2312d58
--- /dev/null
+++ b/test/codegen/language/type_literal_test.dart
@@ -0,0 +1,52 @@
+// 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.
+
+import "package:expect/expect.dart";
+
+// TODO(rnystrom): This test has a lot of overlap with some other language
+// tests, but those are sort of all over the place so I thought it useful to
+// test all of the relevant bits in one place here.
+
+class Foo {}
+
+class Box<T> {
+ Type get typeArg => T;
+}
+
+typedef int Func(bool b);
+typedef int GenericFunc<T>(T t);
+
+main() {
+ // Primitive types.
+ testType(Object, "Object");
+ testType(Null, "Null");
+ testType(bool, "bool");
+ testType(double, "double");
+ testType(int, "int");
+ testType(num, "num");
+ testType(String, "String");
+
+ // Class types.
+ testType(Foo, "Foo");
+
+ // Generic classes.
+ testType(Box, "Box");
+ testType(new Box<Foo>().typeArg, "Foo");
+ testType(new Box<dynamic>().typeArg, "dynamic");
+ testType(new Box<Box<Foo>>().typeArg, "Box<Foo>");
+
+ // Typedef.
+ testType(Func, "Func");
+ testType(GenericFunc, "GenericFunc");
+
+ // TODO(rnystrom): This should print "GenericFunc<int>", but that isn't
+ // implemented yet.
+ testType(new Box<GenericFunc<int>>().typeArg, "GenericFunc");
+
+ // Literals are canonicalized.
+ Expect.identical(Foo, Foo);
+ Expect.identical(Box, Box);
+ Expect.identical(new Box<Foo>().typeArg, new Box<Foo>().typeArg);
+ Expect.identical(Func, Func);
+}
« no previous file with comments | « test/codegen/expect/misc.js ('k') | tool/input_sdk/lib/js/dart2js/js_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698