Chromium Code Reviews| 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 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 expect(o.elementAnnotation, isNull); | 470 expect(o.elementAnnotation, isNull); |
| 471 expect(r.elementAnnotation, isNull); | 471 expect(r.elementAnnotation, isNull); |
| 472 } else { | 472 } else { |
| 473 fail('Not implemented for ${r.runtimeType} vs. ${o.runtimeType}'); | 473 fail('Not implemented for ${r.runtimeType} vs. ${o.runtimeType}'); |
| 474 } | 474 } |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 | 477 |
| 478 void compareConstructorElements(ConstructorElement resynthesized, | 478 void compareConstructorElements(ConstructorElement resynthesized, |
| 479 ConstructorElement original, String desc) { | 479 ConstructorElement original, String desc) { |
| 480 if (original == null && resynthesized == null) { | |
| 481 return; | |
| 482 } | |
| 480 compareExecutableElements(resynthesized, original, desc); | 483 compareExecutableElements(resynthesized, original, desc); |
| 481 if (original.isConst) { | 484 if (original.isConst) { |
| 482 ConstructorElementImpl resynthesizedImpl = | 485 ConstructorElementImpl resynthesizedImpl = |
| 483 getActualElement(resynthesized, desc); | 486 getActualElement(resynthesized, desc); |
| 484 ConstructorElementImpl originalImpl = getActualElement(original, desc); | 487 ConstructorElementImpl originalImpl = getActualElement(original, desc); |
| 485 compareConstAstLists(resynthesizedImpl.constantInitializers, | 488 compareConstAstLists(resynthesizedImpl.constantInitializers, |
| 486 originalImpl.constantInitializers, desc); | 489 originalImpl.constantInitializers, desc); |
| 487 } | 490 } |
| 488 if (original.redirectedConstructor == null) { | 491 if (original.redirectedConstructor == null) { |
| 489 expect(resynthesized.redirectedConstructor, isNull, reason: desc); | 492 expect(resynthesized.redirectedConstructor, isNull, reason: desc); |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1450 class C { | 1453 class C { |
| 1451 const C.named(); | 1454 const C.named(); |
| 1452 } | 1455 } |
| 1453 '''); | 1456 '''); |
| 1454 checkLibrary(r''' | 1457 checkLibrary(r''' |
| 1455 import 'a.dart' as p; | 1458 import 'a.dart' as p; |
| 1456 const V = const p.C.named(); | 1459 const V = const p.C.named(); |
| 1457 '''); | 1460 '''); |
| 1458 } | 1461 } |
| 1459 | 1462 |
| 1463 test_const_invokeConstructor_named_unresolved() { | |
| 1464 checkLibrary( | |
| 1465 r''' | |
| 1466 class C {} | |
| 1467 const V = const C.named(); | |
| 1468 ''', | |
| 1469 allowErrors: true); | |
| 1470 } | |
| 1471 | |
| 1472 test_const_invokeConstructor_named_unresolved2() { | |
| 1473 checkLibrary( | |
| 1474 r''' | |
| 1475 const V = const C.named(); | |
| 1476 ''', | |
| 1477 allowErrors: true); | |
| 1478 } | |
| 1479 | |
|
Paul Berry
2016/02/16 20:44:10
Let's also add tests for cases involving prefixes,
scheglov
2016/02/16 21:48:44
Done.
| |
| 1460 test_const_invokeConstructor_unnamed() { | 1480 test_const_invokeConstructor_unnamed() { |
| 1461 checkLibrary(r''' | 1481 checkLibrary(r''' |
| 1462 class C { | 1482 class C { |
| 1463 const C(); | 1483 const C(); |
| 1464 } | 1484 } |
| 1465 const V = const C(); | 1485 const V = const C(); |
| 1466 '''); | 1486 '''); |
| 1467 } | 1487 } |
| 1468 | 1488 |
| 1469 test_const_invokeConstructor_unnamed_imported() { | 1489 test_const_invokeConstructor_unnamed_imported() { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1487 class C { | 1507 class C { |
| 1488 const C(); | 1508 const C(); |
| 1489 } | 1509 } |
| 1490 '''); | 1510 '''); |
| 1491 checkLibrary(r''' | 1511 checkLibrary(r''' |
| 1492 import 'a.dart' as p; | 1512 import 'a.dart' as p; |
| 1493 const V = const p.C(); | 1513 const V = const p.C(); |
| 1494 '''); | 1514 '''); |
| 1495 } | 1515 } |
| 1496 | 1516 |
| 1517 test_const_invokeConstructor_unnamed_unresolved() { | |
| 1518 checkLibrary( | |
| 1519 r''' | |
| 1520 const V = const C(); | |
| 1521 ''', | |
| 1522 allowErrors: true); | |
| 1523 } | |
| 1524 | |
|
Paul Berry
2016/02/16 20:44:10
Similarly, also test the case:
import 'a.dart' as
scheglov
2016/02/16 21:48:44
Done.
| |
| 1497 test_const_length_ofClassConstField() { | 1525 test_const_length_ofClassConstField() { |
| 1498 checkLibrary(r''' | 1526 checkLibrary(r''' |
| 1499 class C { | 1527 class C { |
| 1500 static const String F = ''; | 1528 static const String F = ''; |
| 1501 } | 1529 } |
| 1502 const int v = C.F.length; | 1530 const int v = C.F.length; |
| 1503 '''); | 1531 '''); |
| 1504 } | 1532 } |
| 1505 | 1533 |
| 1506 test_const_length_ofClassConstField_imported() { | 1534 test_const_length_ofClassConstField_imported() { |
| (...skipping 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3546 fail('Unexpectedly tried to get unlinked summary for $uri'); | 3574 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 3547 } | 3575 } |
| 3548 return serializedUnit; | 3576 return serializedUnit; |
| 3549 } | 3577 } |
| 3550 | 3578 |
| 3551 @override | 3579 @override |
| 3552 bool hasLibrarySummary(String uri) { | 3580 bool hasLibrarySummary(String uri) { |
| 3553 return true; | 3581 return true; |
| 3554 } | 3582 } |
| 3555 } | 3583 } |
| OLD | NEW |