| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// End-to-end test of the analyzer2dart compiler. | 5 /// End-to-end test of the analyzer2dart compiler. |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'mock_sdk.dart'; | 9 import 'mock_sdk.dart'; |
| 10 import 'package:analyzer/file_system/memory_file_system.dart'; | 10 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 11 import 'package:analyzer/src/generated/element.dart'; | 11 import 'package:analyzer/src/generated/element.dart'; |
| 12 import 'package:analyzer/src/generated/sdk.dart'; | 12 import 'package:analyzer/src/generated/sdk.dart'; |
| 13 import 'package:analyzer/src/generated/source.dart'; | 13 import 'package:analyzer/src/generated/source.dart'; |
| 14 import 'package:compiler/implementation/dart_backend/backend_ast_to_frontend_ast
.dart'; | |
| 15 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
| 16 | 15 |
| 17 import '../lib/src/closed_world.dart'; | 16 import '../lib/src/closed_world.dart'; |
| 18 import '../lib/src/driver.dart'; | 17 import '../lib/src/driver.dart'; |
| 19 import '../lib/src/converted_world.dart'; | 18 import '../lib/src/converted_world.dart'; |
| 20 import '../lib/src/dart_backend.dart'; | 19 import '../lib/src/dart_backend.dart'; |
| 21 | 20 |
| 22 main() { | 21 main() { |
| 23 test('Empty main', () { | 22 test('Empty main', () { |
| 24 String expectedResult = ''' | 23 String expectedResult = ''' |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 main() { | 190 main() { |
| 192 var a = 0; | 191 var a = 0; |
| 193 return a; | 192 return a; |
| 194 } | 193 } |
| 195 ''', ''' | 194 ''', ''' |
| 196 main() { | 195 main() { |
| 197 return 0; | 196 return 0; |
| 198 } | 197 } |
| 199 '''); | 198 '''); |
| 200 }); | 199 }); |
| 200 |
| 201 test('Dynamic access', () { |
| 202 checkResult(''' |
| 203 main(a) { |
| 204 return a.foo; |
| 205 } |
| 206 ''', ''' |
| 207 main(a) { |
| 208 return a.foo; |
| 209 } |
| 210 '''); |
| 211 |
| 212 checkResult(''' |
| 213 main() { |
| 214 var a = ""; |
| 215 return a.foo; |
| 216 } |
| 217 ''', ''' |
| 218 main() { |
| 219 return "".foo; |
| 220 } |
| 221 '''); |
| 222 }); |
| 223 |
| 224 test('Dynamic invocation', () { |
| 225 checkResult(''' |
| 226 main(a) { |
| 227 return a.foo(0); |
| 228 } |
| 229 ''', ''' |
| 230 main(a) { |
| 231 return a.foo(0); |
| 232 } |
| 233 '''); |
| 234 |
| 235 checkResult(''' |
| 236 main() { |
| 237 var a = ""; |
| 238 return a.foo(0, 1); |
| 239 } |
| 240 ''', ''' |
| 241 main() { |
| 242 return "".foo(0, 1); |
| 243 } |
| 244 '''); |
| 245 }); |
| 201 } | 246 } |
| 202 | 247 |
| 203 checkResult(String input, [String expectedOutput]) { | 248 checkResult(String input, [String expectedOutput]) { |
| 204 if (expectedOutput == null) { | 249 if (expectedOutput == null) { |
| 205 expectedOutput = input; | 250 expectedOutput = input; |
| 206 } | 251 } |
| 207 | 252 |
| 208 CollectingOutputProvider outputProvider = new CollectingOutputProvider(); | 253 CollectingOutputProvider outputProvider = new CollectingOutputProvider(); |
| 209 MemoryResourceProvider provider = new MemoryResourceProvider(); | 254 MemoryResourceProvider provider = new MemoryResourceProvider(); |
| 210 DartSdk sdk = new MockSdk(); | 255 DartSdk sdk = new MockSdk(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 235 sb.write(text); | 280 sb.write(text); |
| 236 } | 281 } |
| 237 | 282 |
| 238 void addError(errorEvent, [StackTrace stackTrace]) {} | 283 void addError(errorEvent, [StackTrace stackTrace]) {} |
| 239 | 284 |
| 240 void close() {} | 285 void close() {} |
| 241 | 286 |
| 242 String get text => sb.toString(); | 287 String get text => sb.toString(); |
| 243 } | 288 } |
| 244 | 289 |
| OLD | NEW |