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

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

Issue 9049016: in dartc, generics in Typedef not working as expected, when extending generic type (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--enable_type_checks 4 // VMOptions=--enable_type_checks
5 // 5 //
6 // Dart test for function type alias. 6 // Dart test for function type alias.
7 7
8 typedef Fun(a, b); 8 typedef Fun(a, b);
9 9
10 typedef int IntFun(a, b); 10 typedef int IntFun(a, b);
11 11
12 typedef bool BoolFun(a, b); 12 typedef bool BoolFun(a, b);
13 13
14 typedef int CompareObj(Object a, Object b); 14 typedef int CompareObj(Object a, Object b);
15 15
16 typedef int CompareInt(int a, int b); 16 typedef int CompareInt(int a, int b);
17 17
18 typedef int CompareString(String a, String b, [bool swap]); 18 typedef int CompareString(String a, String b, [bool swap]);
19 19
20 typedef void Test(); 20 typedef void Test();
21 21
22 typedef ParametrizedFun1<T, U extends bool, V>(T t, U u); 22 typedef ParametrizedFun1<T, U extends bool, V>(T t, U u);
23 23
24 typedef List<T> ParametrizedFun2<T, U, V extends Map<T, int>>( 24 typedef List<T> ParametrizedFun2<T, U, V extends Map<T, int>>(
25 Map<T, int> t, U u); 25 Map<T, int> t, U u);
26 26
27 typedef void BoundsCheck<T extends num>(T arg);
28
27 class FunctionTypeAliasTest { 29 class FunctionTypeAliasTest {
28 FunctionTypeAliasTest() {} 30 FunctionTypeAliasTest() {}
29 static int test(CompareObj compare, Object a, Object b) { 31 static int test(CompareObj compare, Object a, Object b) {
30 return compare(a, b); 32 return compare(a, b);
31 } 33 }
32 foo(Test test) {} 34 foo(Test arg) {}
33 static bar() { 35 static bar() {
34 FunctionTypeAliasTest a = new FunctionTypeAliasTest(); 36 FunctionTypeAliasTest a = new FunctionTypeAliasTest();
35 a.foo(() { }); 37 a.foo(() { });
36 return 0; 38 return 0;
37 } 39 }
38 40
39 static void testMain() { 41 static void testMain() {
40 int compareStrLen(String a, String b) { return a.length - b.length; } 42 int compareStrLen(String a, String b) { return a.length - b.length; }
41 Expect.isTrue(compareStrLen is Fun); 43 Expect.isTrue(compareStrLen is Fun);
42 Expect.isTrue(compareStrLen is IntFun); 44 Expect.isTrue(compareStrLen is IntFun);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 88
87 int plus (int a, [int b = 1]) { return a + b; }; 89 int plus (int a, [int b = 1]) { return a + b; };
88 Expect.isTrue(plus is !Fun); 90 Expect.isTrue(plus is !Fun);
89 Expect.isTrue(plus is !IntFun); 91 Expect.isTrue(plus is !IntFun);
90 Expect.isTrue(plus is !BoolFun); 92 Expect.isTrue(plus is !BoolFun);
91 Expect.isTrue(plus is !CompareObj); 93 Expect.isTrue(plus is !CompareObj);
92 Expect.isTrue(plus is !CompareInt); 94 Expect.isTrue(plus is !CompareInt);
93 Expect.isTrue(plus is !CompareString); 95 Expect.isTrue(plus is !CompareString);
94 96
95 Expect.equals(0, bar()); 97 Expect.equals(0, bar());
98
99 Function boundsTrue = void _(int arg) { };
100 Function boundsFalse = void _(String arg) { };
101 Expect.isTrue(boundsTrue is BoundsCheck<num>);
102 Expect.isFalse(boundsFalse is BoundsCheck<num>);
zundel 2012/01/04 21:28:54 The way I wanted to write this test was: Expect.i
96 } 103 }
97 } 104 }
98 105
99 main() { 106 main() {
100 FunctionTypeAliasTest.testMain(); 107 FunctionTypeAliasTest.testMain();
101 } 108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698