OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import "package:async_helper/async_helper.dart"; | 6 import "package:async_helper/async_helper.dart"; |
7 import 'package:compiler/src/elements/resolution_types.dart'; | 7 import 'package:compiler/src/elements/resolution_types.dart'; |
8 import "compiler_helper.dart"; | 8 import "compiler_helper.dart"; |
9 | 9 |
10 test(compiler, String name1, String name2, {bool expect}) { | 10 test(compiler, String name1, String name2, {bool expect}) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } | 46 } |
47 if (expect) { | 47 if (expect) { |
48 Expect.equals(type1, type2, "$type1 != $type2"); | 48 Expect.equals(type1, type2, "$type1 != $type2"); |
49 } else { | 49 } else { |
50 Expect.notEquals(type1, type2, "$type1 == $type2"); | 50 Expect.notEquals(type1, type2, "$type1 == $type2"); |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 void main() { | 54 void main() { |
55 var uri = new Uri(scheme: 'source'); | 55 var uri = new Uri(scheme: 'source'); |
56 var compiler = compilerFor( | 56 var compiler = compilerFor(r""" |
57 r""" | |
58 typedef int Typedef1<X,Y>(String s1); | 57 typedef int Typedef1<X,Y>(String s1); |
59 typedef void Typedef2<Z>(T t1, S s1); | 58 typedef void Typedef2<Z>(T t1, S s1); |
60 | 59 |
61 class Class<T,S> { | 60 class Class<T,S> { |
62 void void1() {} | 61 void void1() {} |
63 void void2() {} | 62 void void2() {} |
64 void int1(int a) {} | 63 void int1(int a) {} |
65 void int2(int b) {} | 64 void int2(int b) {} |
66 void String1(String a) {} | 65 void String1(String a) {} |
67 void String2(String b) {} | 66 void String2(String b) {} |
(...skipping 11 matching lines...) Expand all Loading... |
79 void Function2b(void b(T t2, S s2)) {} | 78 void Function2b(void b(T t2, S s2)) {} |
80 void Typedef1a(Typedef1<int,String> a) {} | 79 void Typedef1a(Typedef1<int,String> a) {} |
81 void Typedef2a(Typedef1<int,String> b) {} | 80 void Typedef2a(Typedef1<int,String> b) {} |
82 void Typedef1b(Typedef2<T> a) {} | 81 void Typedef1b(Typedef2<T> a) {} |
83 void Typedef2b(Typedef2<T> b) {} | 82 void Typedef2b(Typedef2<T> b) {} |
84 void Typedef1c(Typedef2<S> a) {} | 83 void Typedef1c(Typedef2<S> a) {} |
85 void Typedef2c(Typedef2<S> b) {} | 84 void Typedef2c(Typedef2<S> b) {} |
86 } | 85 } |
87 | 86 |
88 void main() {} | 87 void main() {} |
89 """, | 88 """, uri, analyzeAll: true, analyzeOnly: true); |
90 uri, | |
91 analyzeAll: true, | |
92 analyzeOnly: true); | |
93 asyncTest(() => compiler.run(uri).then((_) { | 89 asyncTest(() => compiler.run(uri).then((_) { |
94 test(compiler, "void1", "void2", expect: true); | 90 test(compiler, "void1", "void2", expect: true); |
95 test(compiler, "int1", "int2", expect: true); | 91 test(compiler, "int1", "int2", expect: true); |
96 test(compiler, "String1", "String2", expect: true); | 92 test(compiler, "String1", "String2", expect: true); |
97 test(compiler, "ListInt1", "ListInt2", expect: true); | 93 test(compiler, "ListInt1", "ListInt2", expect: true); |
98 test(compiler, "ListString1", "ListString2", expect: true); | 94 test(compiler, "ListString1", "ListString2", expect: true); |
99 test(compiler, "MapIntString1", "MapIntString2", expect: true); | 95 test(compiler, "MapIntString1", "MapIntString2", expect: true); |
100 test(compiler, "TypeVar1", "TypeVar2", expect: true); | 96 test(compiler, "TypeVar1", "TypeVar2", expect: true); |
101 test(compiler, "Function1a", "Function2a", expect: true); | 97 test(compiler, "Function1a", "Function2a", expect: true); |
102 test(compiler, "Function1b", "Function2b", expect: true); | 98 test(compiler, "Function1b", "Function2b", expect: true); |
103 test(compiler, "Typedef1a", "Typedef2a", expect: true); | 99 test(compiler, "Typedef1a", "Typedef2a", expect: true); |
104 test(compiler, "Typedef1b", "Typedef2b", expect: true); | 100 test(compiler, "Typedef1b", "Typedef2b", expect: true); |
105 test(compiler, "Typedef1c", "Typedef2c", expect: true); | 101 test(compiler, "Typedef1c", "Typedef2c", expect: true); |
106 | 102 |
107 test(compiler, "void1", "int1", expect: false); | 103 test(compiler, "void1", "int1", expect: false); |
108 test(compiler, "int1", "String1", expect: false); | 104 test(compiler, "int1", "String1", expect: false); |
109 test(compiler, "String1", "ListInt1", expect: false); | 105 test(compiler, "String1", "ListInt1", expect: false); |
110 test(compiler, "ListInt1", "ListString1", expect: false); | 106 test(compiler, "ListInt1", "ListString1", expect: false); |
111 test(compiler, "ListString1", "MapIntString1", expect: false); | 107 test(compiler, "ListString1", "MapIntString1", expect: false); |
112 test(compiler, "MapIntString1", "TypeVar1", expect: false); | 108 test(compiler, "MapIntString1", "TypeVar1", expect: false); |
113 test(compiler, "TypeVar1", "Function1a", expect: false); | 109 test(compiler, "TypeVar1", "Function1a", expect: false); |
114 test(compiler, "Function1a", "Function1b", expect: false); | 110 test(compiler, "Function1a", "Function1b", expect: false); |
115 test(compiler, "Function1b", "Typedef1a", expect: false); | 111 test(compiler, "Function1b", "Typedef1a", expect: false); |
116 test(compiler, "Typedef1a", "Typedef1b", expect: false); | 112 test(compiler, "Typedef1a", "Typedef1b", expect: false); |
117 test(compiler, "Typedef1b", "Typedef1c", expect: false); | 113 test(compiler, "Typedef1b", "Typedef1c", expect: false); |
118 })); | 114 })); |
119 } | 115 } |
OLD | NEW |