| 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 library analyzer.test.src.summary.resynthesize_ast_test; | 5 library analyzer.test.src.summary.resynthesize_ast_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/src/dart/element/element.dart'; | 9 import 'package:analyzer/src/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart' | 10 import 'package:analyzer/src/generated/engine.dart' |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 @override | 72 @override |
| 73 DartSdk createDartSdk() => AbstractContextTest.SHARED_STRONG_MOCK_SDK; | 73 DartSdk createDartSdk() => AbstractContextTest.SHARED_STRONG_MOCK_SDK; |
| 74 | 74 |
| 75 @override | 75 @override |
| 76 AnalysisOptionsImpl createOptions() => new AnalysisOptionsImpl() | 76 AnalysisOptionsImpl createOptions() => new AnalysisOptionsImpl() |
| 77 ..enableGenericMethods = true | 77 ..enableGenericMethods = true |
| 78 ..strongMode = true; | 78 ..strongMode = true; |
| 79 | 79 |
| 80 void fail_infer_invokeMethodRef_function() { |
| 81 // TODO(scheglov) requires an element for top-level functions |
| 82 // TODO(scheglov) add more tests - imported, and with prefix |
| 83 var unit = checkFile(r''' |
| 84 int m() => 0; |
| 85 var a = m(); |
| 86 '''); |
| 87 expect(unit.topLevelVariables[0].type.toString(), 'int'); |
| 88 } |
| 89 |
| 80 @override | 90 @override |
| 81 @failingTest | 91 @failingTest |
| 82 void test_blockBodiedLambdas_async_allReturnsAreValues() { | 92 void test_blockBodiedLambdas_async_allReturnsAreValues() { |
| 83 super.test_blockBodiedLambdas_async_allReturnsAreValues(); | 93 super.test_blockBodiedLambdas_async_allReturnsAreValues(); |
| 84 } | 94 } |
| 85 | 95 |
| 86 @override | 96 @override |
| 87 @failingTest | 97 @failingTest |
| 88 void test_blockBodiedLambdas_async_alReturnsAreFutures() { | 98 void test_blockBodiedLambdas_async_alReturnsAreFutures() { |
| 89 super.test_blockBodiedLambdas_async_alReturnsAreFutures(); | 99 super.test_blockBodiedLambdas_async_alReturnsAreFutures(); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 void test_infer_invokeConstructor_unnamed_synthetic() { | 399 void test_infer_invokeConstructor_unnamed_synthetic() { |
| 390 checkFile(r''' | 400 checkFile(r''' |
| 391 class A {} | 401 class A {} |
| 392 class B<T> {} | 402 class B<T> {} |
| 393 var a = new A(); | 403 var a = new A(); |
| 394 var b1 = new B(); | 404 var b1 = new B(); |
| 395 var b2 = new B<int>(); | 405 var b2 = new B<int>(); |
| 396 '''); | 406 '''); |
| 397 } | 407 } |
| 398 | 408 |
| 409 void test_infer_invokeMethodRef_method() { |
| 410 var unit = checkFile(r''' |
| 411 class A { |
| 412 int m() => 0; |
| 413 } |
| 414 var a = new A(); |
| 415 var b = a.m(); |
| 416 '''); |
| 417 expect(unit.topLevelVariables[1].type.toString(), 'int'); |
| 418 } |
| 419 |
| 420 void test_infer_invokeMethodRef_method_g() { |
| 421 var unit = checkFile(r''' |
| 422 class A { |
| 423 /*=T*/ m/*<T>*/(/*=T*/ a) => null; |
| 424 } |
| 425 var a = new A(); |
| 426 var b = a.m(1.0); |
| 427 '''); |
| 428 expect(unit.topLevelVariables[1].type.toString(), 'double'); |
| 429 } |
| 430 |
| 431 void test_infer_invokeMethodRef_method_gg() { |
| 432 var unit = checkFile(r''' |
| 433 class A<K> { |
| 434 /*=Map<K, V>*/ m/*<V>*/(/*=V*/ a) => null; |
| 435 } |
| 436 var a = new A<int>(); |
| 437 var b = a.m(1.0); |
| 438 '''); |
| 439 expect(unit.topLevelVariables[1].type.toString(), 'Map<int, double>'); |
| 440 } |
| 441 |
| 442 void test_infer_invokeMethodRef_method_genericSequence() { |
| 443 var unit = checkFile(r''' |
| 444 class A<T> { |
| 445 B<T> b = new B<T>(); |
| 446 } |
| 447 class B<K> { |
| 448 C<List<K>, int> c = new C<List<K>, int>(); |
| 449 } |
| 450 class C<K, V> { |
| 451 Map<K, V> m() => null; |
| 452 } |
| 453 var a = new A<double>(); |
| 454 var v = a.b.c.m(); |
| 455 '''); |
| 456 expect(unit.topLevelVariables[1].type.toString(), 'Map<List<double>, int>'); |
| 457 } |
| 458 |
| 459 void test_infer_invokeMethodRef_method_importedWithPrefix() { |
| 460 addFile( |
| 461 r''' |
| 462 class A { |
| 463 int m() => 0; |
| 464 } |
| 465 var a = new A(); |
| 466 ''', |
| 467 name: '/a.dart'); |
| 468 var unit = checkFile(r''' |
| 469 import 'a.dart' as p; |
| 470 var b = p.a.m(); |
| 471 '''); |
| 472 expect(unit.topLevelVariables[0].type.toString(), 'int'); |
| 473 } |
| 474 |
| 475 void test_infer_invokeMethodRef_method_importedWithPrefix2() { |
| 476 addFile( |
| 477 r''' |
| 478 class A { |
| 479 B b = new B(); |
| 480 } |
| 481 class B { |
| 482 int m() => 0; |
| 483 } |
| 484 var a = new A(); |
| 485 ''', |
| 486 name: '/a.dart'); |
| 487 var unit = checkFile(r''' |
| 488 import 'a.dart' as p; |
| 489 var b = p.a.b.m(); |
| 490 '''); |
| 491 expect(unit.topLevelVariables[0].type.toString(), 'int'); |
| 492 } |
| 493 |
| 399 @override | 494 @override |
| 400 @failingTest | 495 @failingTest |
| 401 void test_inferCorrectlyOnMultipleVariablesDeclaredTogether() { | 496 void test_inferCorrectlyOnMultipleVariablesDeclaredTogether() { |
| 402 super.test_inferCorrectlyOnMultipleVariablesDeclaredTogether(); | 497 super.test_inferCorrectlyOnMultipleVariablesDeclaredTogether(); |
| 403 } | 498 } |
| 404 | 499 |
| 405 @override | 500 @override |
| 406 @failingTest | 501 @failingTest |
| 407 void test_inferenceInCyclesIsDeterministic() { | 502 void test_inferenceInCyclesIsDeterministic() { |
| 408 super.test_inferenceInCyclesIsDeterministic(); | 503 super.test_inferenceInCyclesIsDeterministic(); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 742 } |
| 648 | 743 |
| 649 UnlinkedUnit definingUnit = _getUnlinkedUnit(librarySource); | 744 UnlinkedUnit definingUnit = _getUnlinkedUnit(librarySource); |
| 650 LinkedLibraryBuilder linkedLibrary = | 745 LinkedLibraryBuilder linkedLibrary = |
| 651 prelink(definingUnit, getPart, getImport); | 746 prelink(definingUnit, getPart, getImport); |
| 652 linkedLibrary.dependencies.skip(1).forEach((LinkedDependency d) { | 747 linkedLibrary.dependencies.skip(1).forEach((LinkedDependency d) { |
| 653 _serializeLibrary(resolveRelativeUri(d.uri)); | 748 _serializeLibrary(resolveRelativeUri(d.uri)); |
| 654 }); | 749 }); |
| 655 } | 750 } |
| 656 } | 751 } |
| OLD | NEW |