@@ -635,36 +635,45 @@ void main() {
635
635
});
636
636
637
637
group ('Parameter' , () {
638
- Class c, f ;
638
+ Class c, fClass ;
639
639
Method isGreaterThan, asyncM, methodWithGenericParam, paramFromExportLib;
640
- Parameter p1 ;
640
+ Parameter intNumber, intCheckOptional ;
641
641
642
642
setUp (() {
643
643
c = exLibrary.classes.firstWhere ((c) => c.name == 'Apple' );
644
- isGreaterThan = c.instanceMethods[2 ]; // isGreaterThan
645
- paramFromExportLib = c.instanceMethods[3 ];
644
+ paramFromExportLib =
645
+ c.instanceMethods.singleWhere ((m) => m.name == 'paramFromExportLib' );
646
+ isGreaterThan =
647
+ c.instanceMethods.singleWhere ((m) => m.name == 'isGreaterThan' );
646
648
asyncM = exLibrary.classes
647
649
.firstWhere ((c) => c.name == 'Dog' ).instanceMethods
648
650
.firstWhere ((m) => m.name == 'foo' );
649
- p1 = isGreaterThan.parameters[1 ]; // {int check:5}
650
- f = exLibrary.classes.firstWhere ((c) => c.name == 'F' );
651
- methodWithGenericParam = f.instanceMethods[0 ];
651
+ intNumber = isGreaterThan.parameters.first;
652
+ intCheckOptional = isGreaterThan.parameters.last;
653
+ fClass = exLibrary.classes.firstWhere ((c) => c.name == 'F' );
654
+ methodWithGenericParam = fClass.instanceMethods
655
+ .singleWhere ((m) => m.name == 'methodWithGenericParam' );
656
+ });
657
+
658
+ test ('has parameters' , () {
659
+ expect (isGreaterThan.parameters, hasLength (2 ));
652
660
});
653
661
654
662
test ('is optional' , () {
655
- expect (p1.isOptional, isTrue);
663
+ expect (intCheckOptional.isOptional, isTrue);
664
+ expect (intNumber.isOptional, isFalse);
656
665
});
657
666
658
667
test ('default value' , () {
659
- expect (p1 .defaultValue, '5' );
668
+ expect (intCheckOptional .defaultValue, '5' );
660
669
});
661
670
662
671
test ('is named' , () {
663
- expect (p1 .isOptionalNamed, isTrue);
672
+ expect (intCheckOptional .isOptionalNamed, isTrue);
664
673
});
665
674
666
675
test ('linkedName' , () {
667
- expect (p1 .modelType.linkedName, 'int' );
676
+ expect (intCheckOptional .modelType.linkedName, 'int' );
668
677
});
669
678
670
679
test ('async return type' , () {
@@ -678,6 +687,7 @@ void main() {
678
687
679
688
test ('param exported in library' , () {
680
689
var param = paramFromExportLib.parameters[0 ];
690
+ expect (param.name, equals ('helper' ));
681
691
expect (param.library.name, equals ('ex' ));
682
692
});
683
693
});
@@ -754,7 +764,9 @@ void main() {
754
764
});
755
765
756
766
test ('methods has the right annotation' , () {
757
- expect (dog.instanceMethods.first.annotations.first, equals ('deprecated' ));
767
+ var m = dog.instanceMethods.singleWhere ((m) => m.name == 'getClassA' );
768
+ expect (m.hasAnnotations, isTrue);
769
+ expect (m.annotations.first, equals ('deprecated' ));
758
770
});
759
771
});
760
772
}
0 commit comments