OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, 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 import "package:expect/expect.dart"; |
| 6 |
| 7 // TODO(rnystrom): This test has a lot of overlap with some other language |
| 8 // tests, but those are sort of all over the place so I thought it useful to |
| 9 // test all of the relevant bits in one place here. |
| 10 |
| 11 class Foo {} |
| 12 |
| 13 class Box<T> { |
| 14 Type get typeArg => T; |
| 15 } |
| 16 |
| 17 typedef int Func(bool b); |
| 18 typedef int GenericFunc<T>(T t); |
| 19 |
| 20 main() { |
| 21 // Primitive types. |
| 22 testType(Object, "Object"); |
| 23 testType(Null, "Null"); |
| 24 testType(bool, "bool"); |
| 25 testType(double, "double"); |
| 26 testType(int, "int"); |
| 27 testType(num, "num"); |
| 28 testType(String, "String"); |
| 29 |
| 30 // Class types. |
| 31 testType(Foo, "Foo"); |
| 32 |
| 33 // Generic classes. |
| 34 testType(Box, "Box"); |
| 35 testType(new Box<Foo>().typeArg, "Foo"); |
| 36 testType(new Box<dynamic>().typeArg, "dynamic"); |
| 37 testType(new Box<Box<Foo>>().typeArg, "Box<Foo>"); |
| 38 |
| 39 // Typedef. |
| 40 testType(Func, "Func"); |
| 41 testType(GenericFunc, "GenericFunc"); |
| 42 |
| 43 // TODO(rnystrom): This should print "GenericFunc<int>", but that isn't |
| 44 // implemented yet. |
| 45 testType(new Box<GenericFunc<int>>().typeArg, "GenericFunc"); |
| 46 |
| 47 // Literals are canonicalized. |
| 48 Expect.identical(Foo, Foo); |
| 49 Expect.identical(Box, Box); |
| 50 Expect.identical(new Box<Foo>().typeArg, new Box<Foo>().typeArg); |
| 51 Expect.identical(Func, Func); |
| 52 } |
OLD | NEW |