| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 test.src.serialization.elements_test; | 5 library test.src.serialization.elements_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/element.dart'; | 7 import 'package:analyzer/src/generated/element.dart'; |
| 8 import 'package:analyzer/src/generated/engine.dart'; | 8 import 'package:analyzer/src/generated/engine.dart'; |
| 9 import 'package:analyzer/src/generated/resolver.dart' show Namespace; | 9 import 'package:analyzer/src/generated/resolver.dart' show Namespace; |
| 10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 compareExecutableElements(resynthesized, original, desc); | 364 compareExecutableElements(resynthesized, original, desc); |
| 365 expect(resynthesized.variable, isNotNull); | 365 expect(resynthesized.variable, isNotNull); |
| 366 expect(resynthesized.variable.location, original.variable.location); | 366 expect(resynthesized.variable.location, original.variable.location); |
| 367 } | 367 } |
| 368 | 368 |
| 369 void comparePropertyInducingElements( | 369 void comparePropertyInducingElements( |
| 370 PropertyInducingElementImpl resynthesized, | 370 PropertyInducingElementImpl resynthesized, |
| 371 PropertyInducingElementImpl original, | 371 PropertyInducingElementImpl original, |
| 372 String desc) { | 372 String desc) { |
| 373 compareVariableElements(resynthesized, original, desc); | 373 compareVariableElements(resynthesized, original, desc); |
| 374 compareTypes(resynthesized.propagatedType, original.propagatedType, desc); |
| 374 if (original.getter == null) { | 375 if (original.getter == null) { |
| 375 expect(resynthesized.getter, isNull); | 376 expect(resynthesized.getter, isNull); |
| 376 } else { | 377 } else { |
| 377 expect(resynthesized.getter, isNotNull); | 378 expect(resynthesized.getter, isNotNull); |
| 378 expect(resynthesized.getter.location, original.getter.location); | 379 expect(resynthesized.getter.location, original.getter.location); |
| 379 } | 380 } |
| 380 if (original.setter == null) { | 381 if (original.setter == null) { |
| 381 expect(resynthesized.setter, isNull); | 382 expect(resynthesized.setter, isNull); |
| 382 } else { | 383 } else { |
| 383 expect(resynthesized.setter, isNotNull); | 384 expect(resynthesized.setter, isNotNull); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 expect(resynthesized.uriEnd, original.uriEnd, reason: desc); | 481 expect(resynthesized.uriEnd, original.uriEnd, reason: desc); |
| 481 } | 482 } |
| 482 | 483 |
| 483 void compareVariableElements(VariableElementImpl resynthesized, | 484 void compareVariableElements(VariableElementImpl resynthesized, |
| 484 VariableElementImpl original, String desc) { | 485 VariableElementImpl original, String desc) { |
| 485 compareElements(resynthesized, original, desc); | 486 compareElements(resynthesized, original, desc); |
| 486 compareTypes(resynthesized.type, original.type, desc); | 487 compareTypes(resynthesized.type, original.type, desc); |
| 487 // TODO(paulberry): test initializer | 488 // TODO(paulberry): test initializer |
| 488 } | 489 } |
| 489 | 490 |
| 491 fail_field_propagatedType_const_noDep() { |
| 492 checkLibrary(''' |
| 493 class C { |
| 494 static const x = 0; |
| 495 }'''); |
| 496 } |
| 497 |
| 498 fail_field_propagatedType_final_dep_inLib() { |
| 499 addNamedSource('/a.dart', 'final a = 1;'); |
| 500 checkLibrary(''' |
| 501 import "a.dart"; |
| 502 class C { |
| 503 final b = a / 2; |
| 504 }'''); |
| 505 } |
| 506 |
| 507 fail_field_propagatedType_final_dep_inPart() { |
| 508 addNamedSource('/a.dart', 'part of lib; final a = 1;'); |
| 509 checkLibrary(''' |
| 510 library lib; |
| 511 part "a.dart"; |
| 512 class C { |
| 513 final b = a / 2; |
| 514 }'''); |
| 515 } |
| 516 |
| 517 fail_field_propagatedType_final_noDep_instance() { |
| 518 checkLibrary(''' |
| 519 class C { |
| 520 final x = 0; |
| 521 }'''); |
| 522 } |
| 523 |
| 524 fail_field_propagatedType_final_noDep_static() { |
| 525 checkLibrary(''' |
| 526 class C { |
| 527 static final x = 0; |
| 528 }'''); |
| 529 } |
| 530 |
| 490 fail_library_hasExtUri() { | 531 fail_library_hasExtUri() { |
| 491 checkLibrary('import "dart-ext:doesNotExist.dart";'); | 532 checkLibrary('import "dart-ext:doesNotExist.dart";'); |
| 492 } | 533 } |
| 493 | 534 |
| 535 fail_variable_propagatedType_const_noDep() { |
| 536 checkLibrary('const i = 0;'); |
| 537 } |
| 538 |
| 539 fail_variable_propagatedType_final_dep_inLib() { |
| 540 addNamedSource('/a.dart', 'final a = 1;'); |
| 541 checkLibrary('import "a.dart"; final b = a / 2;'); |
| 542 } |
| 543 |
| 544 fail_variable_propagatedType_final_dep_inPart() { |
| 545 addNamedSource('/a.dart', 'part of lib; final a = 1;'); |
| 546 checkLibrary('library lib; part "a.dart"; final b = a / 2;'); |
| 547 } |
| 548 |
| 549 fail_variable_propagatedType_final_noDep() { |
| 550 checkLibrary('final i = 0;'); |
| 551 } |
| 552 |
| 494 LibraryElementImpl resynthesizeLibrary( | 553 LibraryElementImpl resynthesizeLibrary( |
| 495 Source source, LibraryElementImpl original, bool allowErrors, | 554 Source source, LibraryElementImpl original, bool allowErrors, |
| 496 {int resynthesisCount: 1}) { | 555 {int resynthesisCount: 1}) { |
| 497 if (!allowErrors) { | 556 if (!allowErrors) { |
| 498 assertNoErrors(source); | 557 assertNoErrors(source); |
| 499 } | 558 } |
| 500 String uri = source.uri.toString(); | 559 String uri = source.uri.toString(); |
| 501 addLibrary('dart:core'); | 560 addLibrary('dart:core'); |
| 502 return resynthesizeLibraryElement(uri, original, | 561 return resynthesizeLibraryElement(uri, original, |
| 503 resynthesisCount: resynthesisCount); | 562 resynthesisCount: resynthesisCount); |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 } | 1446 } |
| 1388 | 1447 |
| 1389 test_variable_implicit_type() { | 1448 test_variable_implicit_type() { |
| 1390 checkLibrary('var x;'); | 1449 checkLibrary('var x;'); |
| 1391 } | 1450 } |
| 1392 | 1451 |
| 1393 test_variables() { | 1452 test_variables() { |
| 1394 checkLibrary('int i; int j;'); | 1453 checkLibrary('int i; int j;'); |
| 1395 } | 1454 } |
| 1396 } | 1455 } |
| OLD | NEW |