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

Side by Side Diff: tests/language/src/GenericsTest.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/language/src/Generics2Test.dart ('k') | tests/language/src/GetSetSyntaxTest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 class GenericsTest<T,V> implements Map<int, int> {
7 static int myFunc(bool a, bool b) {
8 Expect.equals(true, a);
9 Expect.equals(false, b);
10 return 42;
11 }
12
13 static void testMain() {
14 int a = 1;
15 int b = 2;
16 int c = 3;
17 int d = 4;
18 Expect.equals(true, a<b);
19 Expect.equals(42, myFunc(a<b, c> d));
20 Map<int, int> e;
21 GenericsTest<int, GenericsTest<int, int>> f;
22
23 takesVoidMethod(void _(int a) {
24 Expect.equals(2, a);
25 return 99;
26 });
27
28 takesGenericMapMethod(Map<int, int> _(int a) {
29 Expect.equals(2, a);
30 return null;
31 });
32
33 takesIntMethod(int _(int a) {
34 Expect.equals(2, a);
35 return 98;
36 });
37
38 e = new Map();
39 takesMapMethod(e);
40 Expect.equals(2, e[0]);
41 Map h = new Map<int, int>();
42 }
43
44 static void takesVoidMethod(void f(int a)) {
45 Expect.equals(99, f(2));
46 }
47
48 static void takesIntMethod(int f(int a)) {
49 Expect.equals(98, f(2));
50 }
51
52 static void takesGenericMapMethod(Map<int, int> f(int a)) {
53 f(2);
54 }
55
56 static void takesMapMethod(Map<int, int> m) {
57 m[0] = 2;
58 }
59
60 Map<int, int> returnMap() {
61 return null;
62 }
63 }
64
65 class LongGeneric<A, B, C> {
66 }
67
68 class LongerGeneric<A, B, C, D, E, F, G, H, I, J> {
69 void func() {
70 LongGeneric<String,
71 A,
72 LongGeneric<C, List<E>, Map<G, Map<I, J>>>> id;
73
74 LongGeneric<
75 num,
76 Map<int, int>,
77 LongGeneric<
78 C,
79 List<E>,
80 Map<G, LongGeneric<I, J, List<A>>>>> id2;
81 }
82 }
83
84 main() {
85 GenericsTest.testMain();
86 }
OLDNEW
« no previous file with comments | « tests/language/src/Generics2Test.dart ('k') | tests/language/src/GetSetSyntaxTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698