@@ -25,6 +25,8 @@ export function main() {
2525 }
2626
2727 function assertTestClassParameters ( parameters ) {
28+ expect ( parameters . length ) . toBe ( 4 ) ;
29+
2830 expect ( parameters [ 0 ] . length ) . toBe ( 2 ) ;
2931 expect ( parameters [ 0 ] [ 0 ] ) . toEqual ( P1 ) ;
3032 expect ( parameters [ 0 ] [ 1 ] ) . toBeAnInstanceOf ( ParamDec ) ;
@@ -48,20 +50,30 @@ export function main() {
4850 assertTestClassParameters ( rc . parameters ( TestClass ) ) ;
4951 } ) ;
5052
51- // Mocking in the tests below is needed because the test runs through Traceur.
52- // After the switch to TS the setup will have to change, where the direct key
53- // access will be mocked, and the tests below will be direct.
54- it ( 'can read out class annotations though Reflect APIs' , ( ) => {
55- if ( IS_DARTIUM ) return ;
56- mockReflect ( mockDataForTestClassDec , TestClassDec ) ;
57- assertTestClassAnnotations ( rc . annotations ( TestClassDec ) ) ;
53+ it ( 'can read out parameter annotations through parameters key for types only class' , ( ) => {
54+ expect ( rc . parameters ( TestClassTypesOnly ) ) . toEqual ( [ [ P1 ] , [ P2 ] ] ) ;
5855 } ) ;
5956
60- it ( 'can read out parameter annotations though Reflect APIs' , ( ) => {
61- if ( IS_DARTIUM ) return ;
62- mockReflect ( mockDataForTestClassDec , TestClassDec ) ;
63- assertTestClassParameters ( rc . parameters ( TestClassDec ) ) ;
64- } ) ;
57+
58+ if ( ! IS_DARTIUM ) {
59+ // Mocking in the tests below is needed because the test runs through Traceur.
60+ // After the switch to TS the setup will have to change, where the direct key
61+ // access will be mocked, and the tests below will be direct.
62+ it ( 'can read out class annotations though Reflect APIs' , ( ) => {
63+ mockReflect ( mockDataForTestClassDec , TestClassDec ) ;
64+ assertTestClassAnnotations ( rc . annotations ( TestClassDec ) ) ;
65+ } ) ;
66+
67+ it ( 'can read out parameter annotations though Reflect APIs' , ( ) => {
68+ mockReflect ( mockDataForTestClassDec , TestClassDec ) ;
69+ assertTestClassParameters ( rc . parameters ( TestClassDec ) ) ;
70+ } ) ;
71+
72+ it ( 'can read out parameter annotations though Reflect APIs for types only class' , ( ) => {
73+ mockReflect ( mockDataForTestClassTypesOnly , TestClassTypesOnlyDec ) ;
74+ expect ( rc . parameters ( TestClassTypesOnlyDec ) ) . toEqual ( [ [ P1 ] , [ P2 ] ] ) ;
75+ } ) ;
76+ }
6577 } ) ;
6678}
6779
@@ -97,3 +109,16 @@ var mockDataForTestClassDec = {
97109 'design:paramtypes' : [ P1 , P2 , Object , Object ]
98110} ;
99111class TestClassDec { }
112+
113+
114+ class TestClassTypesOnly {
115+ constructor ( a : P1 , b : P2 ) { }
116+ }
117+
118+ // Mocking the data stored in global.Reflect as if TS was compiling TestClass above.
119+ var mockDataForTestClassTypesOnly = {
120+ 'annotations' : null ,
121+ 'parameters' : null ,
122+ 'design:paramtypes' : [ P1 , P2 ]
123+ } ;
124+ class TestClassTypesOnlyDec { }
0 commit comments