| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, 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 // Dart test for generic types. | |
| 5 | |
| 6 import "package:expect/expect.dart"; | |
| 7 | |
| 8 class GenericsTest<T, V> implements Map<int, int> { | |
| 9 static int myFunc(bool a, bool b) { | |
| 10 Expect.equals(true, a); | |
| 11 Expect.equals(false, b); | |
| 12 return 42; | |
| 13 } | |
| 14 | |
| 15 static void testMain() { | |
| 16 int a = 1; | |
| 17 int b = 2; | |
| 18 int c = 3; | |
| 19 int d = 4; | |
| 20 Expect.equals(true, a < b); | |
| 21 Expect.equals(42, myFunc(a < b, c > d)); | |
| 22 Map<int, int> e; | |
| 23 GenericsTest<int, GenericsTest<int, int>> f; | |
| 24 | |
| 25 e = new Map(); | |
| 26 takesMapMethod(e); | |
| 27 Expect.equals(2, e[0]); | |
| 28 Map h = new Map<int, int>(); | |
| 29 } | |
| 30 | |
| 31 static void takesMapMethod(Map<int, int> m) { | |
| 32 m[0] = 2; | |
| 33 } | |
| 34 | |
| 35 Map<int, int> returnMap() { | |
| 36 return null; | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 class LongGeneric<A, B, C> {} | |
| 41 | |
| 42 class LongerGeneric<A, B, C, D, E, F, G, H, I, J> { | |
| 43 void func() { | |
| 44 LongGeneric<String, A, LongGeneric<C, List<E>, Map<G, Map<I, J>>>> id; | |
| 45 | |
| 46 LongGeneric<num, Map<int, int>, | |
| 47 LongGeneric<C, List<E>, Map<G, LongGeneric<I, J, List<A>>>>> id2; | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 main() { | |
| 52 GenericsTest.testMain(); | |
| 53 } | |
| OLD | NEW |