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/source.dart'; | 8 import 'package:analyzer/src/generated/source.dart'; |
9 import 'package:analyzer/src/summary/builder.dart'; | 9 import 'package:analyzer/src/summary/builder.dart'; |
10 import 'package:analyzer/src/summary/format.dart'; | 10 import 'package:analyzer/src/summary/format.dart'; |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 void set b(int i) {} | 526 void set b(int i) {} |
527 void f() {} | 527 void f() {} |
528 int x; | 528 int x; |
529 }'''); | 529 }'''); |
530 } | 530 } |
531 | 531 |
532 test_class_constructor_const() { | 532 test_class_constructor_const() { |
533 checkLibrary('class C { const C(); }'); | 533 checkLibrary('class C { const C(); }'); |
534 } | 534 } |
535 | 535 |
| 536 test_class_constructor_const_external() { |
| 537 checkLibrary('class C { external const C(); }'); |
| 538 } |
| 539 |
536 test_class_constructor_explicit_named() { | 540 test_class_constructor_explicit_named() { |
537 checkLibrary('class C { C.foo(); }'); | 541 checkLibrary('class C { C.foo(); }'); |
538 } | 542 } |
539 | 543 |
540 test_class_constructor_explicit_type_params() { | 544 test_class_constructor_explicit_type_params() { |
541 checkLibrary('class C<T, U> { C(); }'); | 545 checkLibrary('class C<T, U> { C(); }'); |
542 } | 546 } |
543 | 547 |
544 test_class_constructor_explicit_unnamed() { | 548 test_class_constructor_explicit_unnamed() { |
545 checkLibrary('class C { C(); }'); | 549 checkLibrary('class C { C(); }'); |
546 } | 550 } |
547 | 551 |
| 552 test_class_constructor_external() { |
| 553 checkLibrary('class C { external C(); }'); |
| 554 } |
| 555 |
548 test_class_constructor_factory() { | 556 test_class_constructor_factory() { |
549 checkLibrary('class C { factory C() => null; }'); | 557 checkLibrary('class C { factory C() => null; }'); |
550 } | 558 } |
551 | 559 |
552 test_class_constructor_implicit() { | 560 test_class_constructor_implicit() { |
553 checkLibrary('class C {}'); | 561 checkLibrary('class C {}'); |
554 } | 562 } |
555 | 563 |
556 test_class_constructor_implicit_type_params() { | 564 test_class_constructor_implicit_type_params() { |
557 checkLibrary('class C<T, U> {}'); | 565 checkLibrary('class C<T, U> {}'); |
(...skipping 12 matching lines...) Expand all Loading... |
570 } | 578 } |
571 | 579 |
572 test_class_field_static() { | 580 test_class_field_static() { |
573 checkLibrary('class C { static int i; }'); | 581 checkLibrary('class C { static int i; }'); |
574 } | 582 } |
575 | 583 |
576 test_class_fields() { | 584 test_class_fields() { |
577 checkLibrary('class C { int i; int j; }'); | 585 checkLibrary('class C { int i; int j; }'); |
578 } | 586 } |
579 | 587 |
| 588 test_class_getter_external() { |
| 589 checkLibrary('class C { external int get x; }'); |
| 590 } |
| 591 |
580 test_class_getter_static() { | 592 test_class_getter_static() { |
581 checkLibrary('class C { static int get x => null; }'); | 593 checkLibrary('class C { static int get x => null; }'); |
582 } | 594 } |
583 | 595 |
584 test_class_getters() { | 596 test_class_getters() { |
585 checkLibrary('class C { int get x => null; get y => null; }'); | 597 checkLibrary('class C { int get x => null; get y => null; }'); |
586 } | 598 } |
587 | 599 |
588 test_class_interfaces() { | 600 test_class_interfaces() { |
589 checkLibrary('class C implements D, E {} class D {} class E {}'); | 601 checkLibrary('class C implements D, E {} class D {} class E {}'); |
590 } | 602 } |
591 | 603 |
| 604 test_class_method_external() { |
| 605 checkLibrary('class C { external f(); }'); |
| 606 } |
| 607 |
592 test_class_method_params() { | 608 test_class_method_params() { |
593 checkLibrary('class C { f(x, y) {} }'); | 609 checkLibrary('class C { f(x, y) {} }'); |
594 } | 610 } |
595 | 611 |
596 test_class_method_static() { | 612 test_class_method_static() { |
597 checkLibrary('class C { static f() {} }'); | 613 checkLibrary('class C { static f() {} }'); |
598 } | 614 } |
599 | 615 |
600 test_class_methods() { | 616 test_class_methods() { |
601 checkLibrary('class C { f() {} g() {} }'); | 617 checkLibrary('class C { f() {} g() {} }'); |
602 } | 618 } |
603 | 619 |
604 test_class_mixins() { | 620 test_class_mixins() { |
605 checkLibrary('class C extends Object with D, E {} class D {} class E {}'); | 621 checkLibrary('class C extends Object with D, E {} class D {} class E {}'); |
606 } | 622 } |
607 | 623 |
| 624 test_class_setter_external() { |
| 625 checkLibrary('class C { external void set x(int value); }'); |
| 626 } |
| 627 |
608 test_class_setter_static() { | 628 test_class_setter_static() { |
609 checkLibrary('class C { static void set x(int value) {} }'); | 629 checkLibrary('class C { static void set x(int value) {} }'); |
610 } | 630 } |
611 | 631 |
612 test_class_setters() { | 632 test_class_setters() { |
613 checkLibrary('class C { void set x(int value) {} set y(value) {} }'); | 633 checkLibrary('class C { void set x(int value) {} set y(value) {} }'); |
614 } | 634 } |
615 | 635 |
616 test_class_supertype() { | 636 test_class_supertype() { |
617 checkLibrary('class C extends D {} class D {}'); | 637 checkLibrary('class C extends D {} class D {}'); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 addLibrary('dart:async'); | 679 addLibrary('dart:async'); |
660 checkLibrary('export "dart:async" show Future, Stream;'); | 680 checkLibrary('export "dart:async" show Future, Stream;'); |
661 } | 681 } |
662 | 682 |
663 test_exports() { | 683 test_exports() { |
664 addLibrarySource('/a.dart', 'library a;'); | 684 addLibrarySource('/a.dart', 'library a;'); |
665 addLibrarySource('/b.dart', 'library b;'); | 685 addLibrarySource('/b.dart', 'library b;'); |
666 checkLibrary('export "a.dart"; export "b.dart";'); | 686 checkLibrary('export "a.dart"; export "b.dart";'); |
667 } | 687 } |
668 | 688 |
| 689 test_function_external() { |
| 690 checkLibrary('external f();'); |
| 691 } |
| 692 |
669 test_function_parameter_kind_named() { | 693 test_function_parameter_kind_named() { |
670 // TODO(paulberry): also test default value. | 694 // TODO(paulberry): also test default value. |
671 checkLibrary('f({x}) {}'); | 695 checkLibrary('f({x}) {}'); |
672 } | 696 } |
673 | 697 |
674 test_function_parameter_kind_positional() { | 698 test_function_parameter_kind_positional() { |
675 // TODO(paulberry): also test default value. | 699 // TODO(paulberry): also test default value. |
676 checkLibrary('f([x]) {}'); | 700 checkLibrary('f([x]) {}'); |
677 } | 701 } |
678 | 702 |
(...skipping 30 matching lines...) Expand all Loading... |
709 } | 733 } |
710 | 734 |
711 test_function_return_type_void() { | 735 test_function_return_type_void() { |
712 checkLibrary('void f() {}'); | 736 checkLibrary('void f() {}'); |
713 } | 737 } |
714 | 738 |
715 test_functions() { | 739 test_functions() { |
716 checkLibrary('f() {} g() {}'); | 740 checkLibrary('f() {} g() {}'); |
717 } | 741 } |
718 | 742 |
| 743 test_getter_external() { |
| 744 checkLibrary('external int get x;'); |
| 745 } |
| 746 |
719 test_getters() { | 747 test_getters() { |
720 checkLibrary('int get x => null; get y => null;'); | 748 checkLibrary('int get x => null; get y => null;'); |
721 } | 749 } |
722 | 750 |
723 test_import_hide() { | 751 test_import_hide() { |
724 addLibrary('dart:async'); | 752 addLibrary('dart:async'); |
725 checkLibrary('import "dart:async" hide Stream, Completer; Future f;'); | 753 checkLibrary('import "dart:async" hide Stream, Completer; Future f;'); |
726 } | 754 } |
727 | 755 |
728 test_import_multiple_combinators() { | 756 test_import_multiple_combinators() { |
(...skipping 30 matching lines...) Expand all Loading... |
759 } | 787 } |
760 | 788 |
761 test_method_parameter_return_type() { | 789 test_method_parameter_return_type() { |
762 checkLibrary('class C { f(int g()) {} }'); | 790 checkLibrary('class C { f(int g()) {} }'); |
763 } | 791 } |
764 | 792 |
765 test_method_parameter_return_type_void() { | 793 test_method_parameter_return_type_void() { |
766 checkLibrary('class C { f(void g()) {} }'); | 794 checkLibrary('class C { f(void g()) {} }'); |
767 } | 795 } |
768 | 796 |
| 797 test_operator() { |
| 798 checkLibrary('class C { C operator+(C other) => null; }'); |
| 799 } |
| 800 |
| 801 test_operator_external() { |
| 802 checkLibrary('class C { external C operator+(C other); }'); |
| 803 } |
| 804 |
769 test_operator_index() { | 805 test_operator_index() { |
770 checkLibrary('class C { bool operator[](int i) => null; }'); | 806 checkLibrary('class C { bool operator[](int i) => null; }'); |
771 } | 807 } |
772 | 808 |
773 test_operator_index_set() { | 809 test_operator_index_set() { |
774 checkLibrary('class C { void operator[]=(int i, bool v) {} }'); | 810 checkLibrary('class C { void operator[]=(int i, bool v) {} }'); |
775 } | 811 } |
776 | 812 |
777 test_parts() { | 813 test_parts() { |
778 addNamedSource('/a.dart', 'part of my.lib;'); | 814 addNamedSource('/a.dart', 'part of my.lib;'); |
779 addNamedSource('/b.dart', 'part of my.lib;'); | 815 addNamedSource('/b.dart', 'part of my.lib;'); |
780 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); | 816 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); |
781 } | 817 } |
782 | 818 |
| 819 test_setter_external() { |
| 820 checkLibrary('external void set x(int value);'); |
| 821 } |
| 822 |
783 test_setters() { | 823 test_setters() { |
784 checkLibrary('void set x(int value) {} set y(value) {}'); | 824 checkLibrary('void set x(int value) {} set y(value) {}'); |
785 } | 825 } |
786 | 826 |
787 test_type_arguments_explicit() { | 827 test_type_arguments_explicit() { |
788 checkLibrary('Map<String, int> m;'); | 828 checkLibrary('Map<String, int> m;'); |
789 } | 829 } |
790 | 830 |
791 test_type_arguments_implicit() { | 831 test_type_arguments_implicit() { |
792 checkLibrary('Map m;'); | 832 checkLibrary('Map m;'); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 } | 1008 } |
969 | 1009 |
970 test_variable_const() { | 1010 test_variable_const() { |
971 checkLibrary('const int i = 0;'); | 1011 checkLibrary('const int i = 0;'); |
972 } | 1012 } |
973 | 1013 |
974 test_variables() { | 1014 test_variables() { |
975 checkLibrary('int i; int j;'); | 1015 checkLibrary('int i; int j;'); |
976 } | 1016 } |
977 } | 1017 } |
OLD | NEW |