OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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 'dart:convert' show JSON, UTF8; | 5 import 'dart:convert' show JSON, UTF8; |
6 import 'package:async_helper/async_helper.dart'; | 6 import 'package:async_helper/async_helper.dart'; |
7 import 'package:compiler/src/commandline_options.dart'; | 7 import 'package:compiler/src/commandline_options.dart'; |
8 import 'package:compiler/src/diagnostics/messages.dart'; | 8 import 'package:compiler/src/diagnostics/messages.dart'; |
9 import 'package:compiler/src/io/source_file.dart'; | 9 import 'package:compiler/src/io/source_file.dart'; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
11 import 'memory_compiler.dart'; | 11 import 'memory_compiler.dart'; |
12 import 'memory_source_file_helper.dart'; | 12 import 'memory_source_file_helper.dart'; |
13 | 13 |
14 const List<Test> TESTS = const <Test>[ | 14 const List<Test> TESTS = const <Test>[ |
15 const Test( | 15 const Test(''' |
16 ''' | |
17 class A { A(b); } | 16 class A { A(b); } |
18 class B extends A { | 17 class B extends A { |
19 a() {} | 18 a() {} |
20 | 19 |
21 lot() {} | 20 lot() {} |
22 | 21 |
23 of() {} | 22 of() {} |
24 | 23 |
25 var members; | 24 var members; |
26 } | 25 } |
27 main() => new B();''', | 26 main() => new B();''', const { |
28 const { | 27 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: ''' |
29 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: ''' | |
30 class B extends A { | 28 class B extends A { |
31 ^^^^^^^^^^^^^^^^^''' | 29 ^^^^^^^^^^^^^^^^^''' |
32 }), | 30 }), |
33 const Test( | 31 const Test(''' |
34 ''' | |
35 class I {} | 32 class I {} |
36 class A { A(b); } | 33 class A { A(b); } |
37 class B extends A implements I { | 34 class B extends A implements I { |
38 a() {} | 35 a() {} |
39 | 36 |
40 lot() {} | 37 lot() {} |
41 | 38 |
42 of() {} | 39 of() {} |
43 | 40 |
44 var members; | 41 var members; |
45 } | 42 } |
46 main() => new B();''', | 43 main() => new B();''', const { |
47 const { | 44 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: ''' |
48 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: ''' | |
49 class B extends A implements I { | 45 class B extends A implements I { |
50 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^''' | 46 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^''' |
51 }), | 47 }), |
52 const Test( | 48 const Test(''' |
53 ''' | |
54 class M<T> {} | 49 class M<T> {} |
55 class A { A(b); } | 50 class A { A(b); } |
56 class B extends A with M<int> { | 51 class B extends A with M<int> { |
57 a() {} | 52 a() {} |
58 | 53 |
59 lot() {} | 54 lot() {} |
60 | 55 |
61 of() {} | 56 of() {} |
62 | 57 |
63 var members; | 58 var members; |
64 } | 59 } |
65 main() => new B();''', | 60 main() => new B();''', const { |
66 const { | 61 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: ''' |
67 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: ''' | |
68 class B extends A with M<int> { | 62 class B extends A with M<int> { |
69 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^''' | 63 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^''' |
70 }), | 64 }), |
71 const Test( | 65 const Test(''' |
72 ''' | |
73 class A { A(b); } | 66 class A { A(b); } |
74 class B | 67 class B |
75 extends A { | 68 extends A { |
76 a() {} | 69 a() {} |
77 | 70 |
78 lot() {} | 71 lot() {} |
79 | 72 |
80 of() {} | 73 of() {} |
81 | 74 |
82 var members; | 75 var members; |
83 } | 76 } |
84 main() => new B();''', | 77 main() => new B();''', const { |
85 const { | 78 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: ''' |
86 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: ''' | |
87 class B | 79 class B |
88 extends A { | 80 extends A { |
89 ''' | 81 ''' |
90 }), | 82 }), |
91 const Test( | 83 const Test(''' |
92 ''' | |
93 void foo(int a) { | 84 void foo(int a) { |
94 // a | 85 // a |
95 // non-empty | 86 // non-empty |
96 // body | 87 // body |
97 } | 88 } |
98 main() => foo('');''', | 89 main() => foo('');''', const { |
99 const { | 90 MessageKind.THIS_IS_THE_METHOD: ''' |
100 MessageKind.THIS_IS_THE_METHOD: ''' | |
101 void foo(int a) { | 91 void foo(int a) { |
102 ^^^^^^^^^^^^^^^''' | 92 ^^^^^^^^^^^^^^^''' |
103 }), | 93 }), |
104 const Test( | 94 const Test(''' |
105 ''' | |
106 void foo(int a, | 95 void foo(int a, |
107 int b) { | 96 int b) { |
108 // a | 97 // a |
109 // non-empty | 98 // non-empty |
110 // body | 99 // body |
111 } | 100 } |
112 main() => foo('', 0);''', | 101 main() => foo('', 0);''', const { |
113 const { | 102 MessageKind.THIS_IS_THE_METHOD: ''' |
114 MessageKind.THIS_IS_THE_METHOD: ''' | |
115 void foo(int a, | 103 void foo(int a, |
116 int b) { | 104 int b) { |
117 ''' | 105 ''' |
118 }), | 106 }), |
119 const Test( | 107 const Test(''' |
120 ''' | |
121 class A { | 108 class A { |
122 int foo() { | 109 int foo() { |
123 // a | 110 // a |
124 // non-empty | 111 // non-empty |
125 // body | 112 // body |
126 } | 113 } |
127 } | 114 } |
128 class B extends A { | 115 class B extends A { |
129 int get foo { | 116 int get foo { |
130 // a | 117 // a |
131 // non-empty | 118 // non-empty |
132 // body | 119 // body |
133 return 0; | 120 return 0; |
134 } | 121 } |
135 } | 122 } |
136 main() => new B();''', | 123 main() => new B();''', const { |
137 const { | 124 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER: ''' |
138 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER: ''' | |
139 int get foo { | 125 int get foo { |
140 ^^^^^^^^^^^''', | 126 ^^^^^^^^^^^''', |
141 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT: ''' | 127 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT: ''' |
142 int foo() { | 128 int foo() { |
143 ^^^^^^^^^''' | 129 ^^^^^^^^^''' |
144 }), | 130 }), |
145 ]; | 131 ]; |
146 | 132 |
147 class Test { | 133 class Test { |
148 final String code; | 134 final String code; |
149 final Map<MessageKind, String> kindToSpan; | 135 final Map<MessageKind, String> kindToSpan; |
150 | 136 |
151 const Test(this.code, this.kindToSpan); | 137 const Test(this.code, this.kindToSpan); |
152 } | 138 } |
153 | 139 |
154 const String MARKER = '---marker---'; | 140 const String MARKER = '---marker---'; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 "\nActual : $actual"); | 175 "\nActual : $actual"); |
190 kindToSpan.remove(message.messageKind); | 176 kindToSpan.remove(message.messageKind); |
191 } | 177 } |
192 } | 178 } |
193 kindToSpan.forEach((MessageKind kind, _) { | 179 kindToSpan.forEach((MessageKind kind, _) { |
194 Expect.fail("Missing message kin $kind in\n${test.code}"); | 180 Expect.fail("Missing message kin $kind in\n${test.code}"); |
195 }); | 181 }); |
196 } | 182 } |
197 }); | 183 }); |
198 } | 184 } |
OLD | NEW |