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

Side by Side Diff: tests/compiler/dart2js/message_span_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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
OLDNEW
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 'package:async_helper/async_helper.dart'; 5 import 'package:async_helper/async_helper.dart';
6 import 'package:compiler/src/commandline_options.dart'; 6 import 'package:compiler/src/commandline_options.dart';
7 import 'package:compiler/src/diagnostics/messages.dart'; 7 import 'package:compiler/src/diagnostics/messages.dart';
8 import 'package:compiler/src/io/source_file.dart'; 8 import 'package:compiler/src/io/source_file.dart';
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 import 'memory_compiler.dart'; 10 import 'memory_compiler.dart';
11 import 'memory_source_file_helper.dart'; 11 import 'memory_source_file_helper.dart';
12 12
13 const List<Test> TESTS = const <Test>[ 13 const List<Test> TESTS = const <Test>[
14 const Test(''' 14 const Test(
15 '''
15 class A { A(b); } 16 class A { A(b); }
16 class B extends A { 17 class B extends A {
17 a() {} 18 a() {}
18 19
19 lot() {} 20 lot() {}
20 21
21 of() {} 22 of() {}
22 23
23 var members; 24 var members;
24 } 25 }
25 main() => new B();''', 26 main() => new B();''',
26 const { 27 const {
27 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: ''' 28 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
28 class B extends A { 29 class B extends A {
29 ^^^^^^^^^^^^^^^^^'''}), 30 ^^^^^^^^^^^^^^^^^'''
30 31 }),
31 const Test(''' 32 const Test(
33 '''
32 class I {} 34 class I {}
33 class A { A(b); } 35 class A { A(b); }
34 class B extends A implements I { 36 class B extends A implements I {
35 a() {} 37 a() {}
36 38
37 lot() {} 39 lot() {}
38 40
39 of() {} 41 of() {}
40 42
41 var members; 43 var members;
42 } 44 }
43 main() => new B();''', 45 main() => new B();''',
44 const { 46 const {
45 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: ''' 47 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
46 class B extends A implements I { 48 class B extends A implements I {
47 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'''}), 49 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'''
48 50 }),
49 const Test(''' 51 const Test(
52 '''
50 class M<T> {} 53 class M<T> {}
51 class A { A(b); } 54 class A { A(b); }
52 class B extends A with M<int> { 55 class B extends A with M<int> {
53 a() {} 56 a() {}
54 57
55 lot() {} 58 lot() {}
56 59
57 of() {} 60 of() {}
58 61
59 var members; 62 var members;
60 } 63 }
61 main() => new B();''', 64 main() => new B();''',
62 const { 65 const {
63 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: ''' 66 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
64 class B extends A with M<int> { 67 class B extends A with M<int> {
65 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'''}), 68 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'''
66 69 }),
67 const Test(''' 70 const Test(
71 '''
68 class A { A(b); } 72 class A { A(b); }
69 class B 73 class B
70 extends A { 74 extends A {
71 a() {} 75 a() {}
72 76
73 lot() {} 77 lot() {}
74 78
75 of() {} 79 of() {}
76 80
77 var members; 81 var members;
78 } 82 }
79 main() => new B();''', 83 main() => new B();''',
80 const { 84 const {
81 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: ''' 85 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
82 class B 86 class B
83 extends A { 87 extends A {
84 '''}), 88 '''
85 89 }),
86 const Test(''' 90 const Test(
91 '''
87 void foo(int a) { 92 void foo(int a) {
88 // a 93 // a
89 // non-empty 94 // non-empty
90 // body 95 // body
91 } 96 }
92 main() => foo('');''', 97 main() => foo('');''',
93 const { 98 const {
94 MessageKind.THIS_IS_THE_METHOD: ''' 99 MessageKind.THIS_IS_THE_METHOD: '''
95 void foo(int a) { 100 void foo(int a) {
96 ^^^^^^^^^^^^^^^'''}), 101 ^^^^^^^^^^^^^^^'''
97 102 }),
98 const Test(''' 103 const Test(
104 '''
99 void foo(int a, 105 void foo(int a,
100 int b) { 106 int b) {
101 // a 107 // a
102 // non-empty 108 // non-empty
103 // body 109 // body
104 } 110 }
105 main() => foo('', 0);''', 111 main() => foo('', 0);''',
106 const { 112 const {
107 MessageKind.THIS_IS_THE_METHOD: ''' 113 MessageKind.THIS_IS_THE_METHOD: '''
108 void foo(int a, 114 void foo(int a,
109 int b) { 115 int b) {
110 '''}), 116 '''
111 117 }),
112 const Test(''' 118 const Test(
119 '''
113 class A { 120 class A {
114 int foo() { 121 int foo() {
115 // a 122 // a
116 // non-empty 123 // non-empty
117 // body 124 // body
118 } 125 }
119 } 126 }
120 class B extends A { 127 class B extends A {
121 int get foo { 128 int get foo {
122 // a 129 // a
123 // non-empty 130 // non-empty
124 // body 131 // body
125 return 0; 132 return 0;
126 } 133 }
127 } 134 }
128 main() => new B();''', 135 main() => new B();''',
129 const { 136 const {
130 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER: ''' 137 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER: '''
131 int get foo { 138 int get foo {
132 ^^^^^^^^^^^''', 139 ^^^^^^^^^^^''',
133 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT: ''' 140 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT: '''
134 int foo() { 141 int foo() {
135 ^^^^^^^^^'''}), 142 ^^^^^^^^^'''
143 }),
136 ]; 144 ];
137 145
138 class Test { 146 class Test {
139 final String code; 147 final String code;
140 final Map<MessageKind, String> kindToSpan; 148 final Map<MessageKind, String> kindToSpan;
141 149
142 const Test(this.code, this.kindToSpan); 150 const Test(this.code, this.kindToSpan);
143 } 151 }
144 152
145 const String MARKER = '---marker---'; 153 const String MARKER = '---marker---';
(...skipping 12 matching lines...) Expand all
158 MemorySourceFileProvider provider = cachedCompiler.provider; 166 MemorySourceFileProvider provider = cachedCompiler.provider;
159 Map<MessageKind, String> kindToSpan = 167 Map<MessageKind, String> kindToSpan =
160 new Map<MessageKind, String>.from(test.kindToSpan); 168 new Map<MessageKind, String>.from(test.kindToSpan);
161 for (CollectedMessage message in collector.messages) { 169 for (CollectedMessage message in collector.messages) {
162 String expectedSpanText = kindToSpan[message.messageKind]; 170 String expectedSpanText = kindToSpan[message.messageKind];
163 if (expectedSpanText != null) { 171 if (expectedSpanText != null) {
164 SourceFile sourceFile = provider.getSourceFile(message.uri); 172 SourceFile sourceFile = provider.getSourceFile(message.uri);
165 String locationMessage = 173 String locationMessage =
166 sourceFile.getLocationMessage(MARKER, message.begin, message.end); 174 sourceFile.getLocationMessage(MARKER, message.begin, message.end);
167 // Remove `filename:line:column:` and message. 175 // Remove `filename:line:column:` and message.
168 String strippedLocationMessage = locationMessage.substring( 176 String strippedLocationMessage = locationMessage
169 locationMessage.indexOf(MARKER) + MARKER.length + 1); 177 .substring(locationMessage.indexOf(MARKER) + MARKER.length + 1);
170 Expect.equals(expectedSpanText, strippedLocationMessage, 178 Expect.equals(
179 expectedSpanText,
180 strippedLocationMessage,
171 "Unexpected span for ${message.messageKind} in\n${test.code}" 181 "Unexpected span for ${message.messageKind} in\n${test.code}"
172 "\nExpected:${expectedSpanText.codeUnits}" 182 "\nExpected:${expectedSpanText.codeUnits}"
173 "\nActual :${strippedLocationMessage.codeUnits}"); 183 "\nActual :${strippedLocationMessage.codeUnits}");
174 kindToSpan.remove(message.messageKind); 184 kindToSpan.remove(message.messageKind);
175 } 185 }
176 } 186 }
177 kindToSpan.forEach((MessageKind kind, _) { 187 kindToSpan.forEach((MessageKind kind, _) {
178 Expect.fail("Missing message kin $kind in\n${test.code}"); 188 Expect.fail("Missing message kin $kind in\n${test.code}");
179 }); 189 });
180 } 190 }
181 }); 191 });
182 } 192 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/message_kind_test.dart ('k') | tests/compiler/dart2js/metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698