@@ -620,12 +620,135 @@ class MyComponent {
620
620
errorListener.assertNoErrors ();
621
621
}
622
622
623
+ void test_outputs_streamIsOk () {
624
+ String code = r'''
625
+ import '/angular2/angular2.dart';
626
+ import 'dart:async';
627
+
628
+ @Component(
629
+ selector: 'my-component',
630
+ template: '<p></p>')
631
+ class MyComponent {
632
+ @Output()
633
+ Stream<int> myOutput;
634
+ }
635
+ ''' ;
636
+ Source source = newSource ('/test.dart' , code);
637
+ LibrarySpecificUnit target = new LibrarySpecificUnit (source, source);
638
+ computeResult (target, DIRECTIVES_IN_UNIT );
639
+ expect (task, new isInstanceOf <BuildUnitDirectivesTask >());
640
+ // validate
641
+ List <AbstractDirective > directives = outputs[DIRECTIVES_IN_UNIT ];
642
+ Component component = directives.single;
643
+ List <OutputElement > compOutputs = component.outputs;
644
+ expect (compOutputs, hasLength (1 ));
645
+ {
646
+ OutputElement output = compOutputs[0 ];
647
+ expect (output.eventType, isNotNull);
648
+ expect (output.eventType.toString (), equals ("int" ));
649
+ }
650
+ }
651
+
652
+ void test_outputs_extendStreamIsOk () {
653
+ String code = r'''
654
+ import '/angular2/angular2.dart';
655
+ import 'dart:async';
656
+
657
+ abstract class MyStream<T> implements Stream<T> { }
658
+
659
+ @Component(
660
+ selector: 'my-component',
661
+ template: '<p></p>')
662
+ class MyComponent {
663
+ @Output()
664
+ MyStream<int> myOutput;
665
+ }
666
+ ''' ;
667
+ Source source = newSource ('/test.dart' , code);
668
+ LibrarySpecificUnit target = new LibrarySpecificUnit (source, source);
669
+ computeResult (target, DIRECTIVES_IN_UNIT );
670
+ expect (task, new isInstanceOf <BuildUnitDirectivesTask >());
671
+ // validate
672
+ List <AbstractDirective > directives = outputs[DIRECTIVES_IN_UNIT ];
673
+ Component component = directives.single;
674
+ List <OutputElement > compOutputs = component.outputs;
675
+ expect (compOutputs, hasLength (1 ));
676
+ {
677
+ OutputElement output = compOutputs[0 ];
678
+ expect (output.eventType, isNotNull);
679
+ expect (output.eventType.toString (), equals ("int" ));
680
+ }
681
+ }
682
+
683
+ void test_outputs_extendStreamSpecializedIsOk () {
684
+ String code = r'''
685
+ import '/angular2/angular2.dart';
686
+ import 'dart:async';
687
+
688
+ class MyStream extends Stream<int> { }
689
+
690
+ @Component(
691
+ selector: 'my-component',
692
+ template: '<p></p>')
693
+ class MyComponent {
694
+ @Output()
695
+ MyStream myOutput;
696
+ }
697
+ ''' ;
698
+ Source source = newSource ('/test.dart' , code);
699
+ LibrarySpecificUnit target = new LibrarySpecificUnit (source, source);
700
+ computeResult (target, DIRECTIVES_IN_UNIT );
701
+ expect (task, new isInstanceOf <BuildUnitDirectivesTask >());
702
+ // validate
703
+ List <AbstractDirective > directives = outputs[DIRECTIVES_IN_UNIT ];
704
+ Component component = directives.single;
705
+ List <OutputElement > compOutputs = component.outputs;
706
+ expect (compOutputs, hasLength (1 ));
707
+ {
708
+ OutputElement output = compOutputs[0 ];
709
+ expect (output.eventType, isNotNull);
710
+ expect (output.eventType.toString (), equals ("int" ));
711
+ }
712
+ }
713
+
714
+ void test_outputs_extendStreamUntypedIsOk () {
715
+ String code = r'''
716
+ import '/angular2/angular2.dart';
717
+ import 'dart:async';
718
+
719
+ class MyStream extends Stream { }
720
+
721
+ @Component(
722
+ selector: 'my-component',
723
+ template: '<p></p>')
724
+ class MyComponent {
725
+ @Output()
726
+ MyStream myOutput;
727
+ }
728
+ ''' ;
729
+ Source source = newSource ('/test.dart' , code);
730
+ LibrarySpecificUnit target = new LibrarySpecificUnit (source, source);
731
+ computeResult (target, DIRECTIVES_IN_UNIT );
732
+ expect (task, new isInstanceOf <BuildUnitDirectivesTask >());
733
+ // validate
734
+ List <AbstractDirective > directives = outputs[DIRECTIVES_IN_UNIT ];
735
+ Component component = directives.single;
736
+ List <OutputElement > compOutputs = component.outputs;
737
+ expect (compOutputs, hasLength (1 ));
738
+ {
739
+ OutputElement output = compOutputs[0 ];
740
+ expect (output.eventType, isNotNull);
741
+ expect (output.eventType.toString (), equals ("dynamic" ));
742
+ }
743
+ }
744
+
623
745
void test_outputs_notEventEmitterTypeError () {
624
746
String code = r'''
625
747
import '/angular2/angular2.dart';
626
748
627
749
@Component(
628
750
selector: 'my-component',
751
+ template: '<p></p>')
629
752
class MyComponent {
630
753
@Output()
631
754
int badOutput;
@@ -639,6 +762,34 @@ class MyComponent {
639
762
AngularWarningCode .OUTPUT_MUST_BE_EVENTEMITTER , code, "badOutput" );
640
763
}
641
764
765
+ void test_outputs_extendStreamNotStreamHasDynamicEventType () {
766
+ String code = r'''
767
+ import '/angular2/angular2.dart';
768
+
769
+ @Component(
770
+ selector: 'my-component',
771
+ template: '<p></p>')
772
+ class MyComponent {
773
+ @Output()
774
+ int badOutput;
775
+ }
776
+ ''' ;
777
+ Source source = newSource ('/test.dart' , code);
778
+ LibrarySpecificUnit target = new LibrarySpecificUnit (source, source);
779
+ computeResult (target, DIRECTIVES_IN_UNIT );
780
+ expect (task, new isInstanceOf <BuildUnitDirectivesTask >());
781
+ // validate
782
+ List <AbstractDirective > directives = outputs[DIRECTIVES_IN_UNIT ];
783
+ Component component = directives.single;
784
+ List <OutputElement > compOutputs = component.outputs;
785
+ expect (compOutputs, hasLength (1 ));
786
+ {
787
+ OutputElement output = compOutputs[0 ];
788
+ expect (output.eventType, isNotNull);
789
+ expect (output.eventType.toString (), equals ("dynamic" ));
790
+ }
791
+ }
792
+
642
793
void test_noDirectives () {
643
794
Source source = newSource (
644
795
'/test.dart' ,
0 commit comments