@@ -94,6 +94,20 @@ function handlerKind(handler) {
9494 }
9595}
9696
97+ function wideHandlerKind ( handler ) {
98+ if ( handler instanceof UntaggedAnimal || handler instanceof UntaggedCallable ) {
99+ return "other" ;
100+ }
101+ switch ( typeof handler ) {
102+ case "function" :
103+ return "function" ;
104+ case "string" :
105+ return "name" ;
106+ default :
107+ return "other" ;
108+ }
109+ }
110+
97111function objectOrNameKind ( value ) {
98112 if ( value instanceof UntaggedDog ) {
99113 return "dog" ;
@@ -104,54 +118,59 @@ function objectOrNameKind(value) {
104118
105119Mocha . describe ( "Untagged_runtime_annotations_test" , ( ) => {
106120 Mocha . test ( "a subclass case is not taken for its superclass" , ( ) => {
107- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 148 , characters 7-14" , "animal" , describePet ( new UntaggedAnimal ( ) ) ) ;
108- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 149 , characters 7-14" , "dog" , describePet ( new UntaggedDog ( ) ) ) ;
109- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 150 , characters 7-14" , "rex" , "rex" ) ;
121+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 165 , characters 7-14" , "animal" , describePet ( new UntaggedAnimal ( ) ) ) ;
122+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 166 , characters 7-14" , "dog" , describePet ( new UntaggedDog ( ) ) ) ;
123+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 167 , characters 7-14" , "rex" , "rex" ) ;
110124 } ) ;
111125 Mocha . test ( "a superclass case alone excludes the subclass" , ( ) => {
112- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 154 , characters 7-14" , "animal" , onlyAnimal ( new UntaggedAnimal ( ) ) ) ;
113- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 155 , characters 7-14" , "other" , onlyAnimal ( new UntaggedDog ( ) ) ) ;
126+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 171 , characters 7-14" , "animal" , onlyAnimal ( new UntaggedAnimal ( ) ) ) ;
127+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 172 , characters 7-14" , "other" , onlyAnimal ( new UntaggedDog ( ) ) ) ;
114128 } ) ;
115129 Mocha . test ( "declaration order does not matter" , ( ) => {
116- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 159 , characters 7-14" , "dog" , describeReversed ( new UntaggedDog ( ) ) ) ;
117- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 160 , characters 7-14" , "animal" , describeReversed ( new UntaggedAnimal ( ) ) ) ;
130+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 176 , characters 7-14" , "dog" , describeReversed ( new UntaggedDog ( ) ) ) ;
131+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 177 , characters 7-14" , "animal" , describeReversed ( new UntaggedAnimal ( ) ) ) ;
118132 } ) ;
119133 Mocha . test ( "a subclass upcasts to its superclass" , ( ) => {
120134 let animal = new UntaggedDog ( ) ;
121- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 165 , characters 7-14" , "dog" , describePet ( animal ) ) ;
135+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 182 , characters 7-14" , "dog" , describePet ( animal ) ) ;
122136 } ) ;
123137 Mocha . test ( "classes reached through a module alias" , ( ) => {
124- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 169 , characters 7-14" , "animal" , describeAliased ( new UntaggedAnimal ( ) ) ) ;
125- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 170 , characters 7-14" , "dog" , describeAliased ( new UntaggedDog ( ) ) ) ;
138+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 186 , characters 7-14" , "animal" , describeAliased ( new UntaggedAnimal ( ) ) ) ;
139+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 187 , characters 7-14" , "dog" , describeAliased ( new UntaggedDog ( ) ) ) ;
126140 } ) ;
127141 Mocha . test ( "typeOf symbol" , ( ) => {
128- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 174 , characters 7-14" , "symbol" , keyKind ( Symbol . for ( "key" ) ) ) ;
129- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 175 , characters 7-14" , "text" , "text" ) ;
142+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 191 , characters 7-14" , "symbol" , keyKind ( Symbol . for ( "key" ) ) ) ;
143+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 192 , characters 7-14" , "text" , "text" ) ;
130144 } ) ;
131145 Mocha . test ( "typeOf string" , ( ) => {
132- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 179 , characters 7-14" , "id" , "id" ) ;
133- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 180 , characters 7-14" , "index" , "index" ) ;
146+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 196 , characters 7-14" , "id" , "id" ) ;
147+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 197 , characters 7-14" , "index" , "index" ) ;
134148 } ) ;
135149 Mocha . test ( "a class at a dotted path" , ( ) => {
136- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 184 , characters 7-14" , "locale" , localeKind ( new Intl . Locale ( "en" ) ) ) ;
137- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 185 , characters 7-14" , "de" , "de" ) ;
150+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 201 , characters 7-14" , "locale" , localeKind ( new Intl . Locale ( "en" ) ) ) ;
151+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 202 , characters 7-14" , "de" , "de" ) ;
138152 } ) ;
139153 Mocha . test ( "an annotated type is not wrapped in an option" , ( ) => {
140154 let animal = new UntaggedAnimal ( ) ;
141- Test_utils . ok ( "File \"untagged_runtime_annotations_test.res\", line 190 , characters 7-14" , animal === animal ) ;
142- Test_utils . ok ( "File \"untagged_runtime_annotations_test.res\", line 191 , characters 7-14" , animal === animal ) ;
155+ Test_utils . ok ( "File \"untagged_runtime_annotations_test.res\", line 207 , characters 7-14" , animal === animal ) ;
156+ Test_utils . ok ( "File \"untagged_runtime_annotations_test.res\", line 208 , characters 7-14" , animal === animal ) ;
143157 } ) ;
144158 Mocha . test ( "a phantom type hierarchy" , ( ) => {
145- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 195 , characters 7-14" , "animal" , describePhantom ( new UntaggedAnimal ( ) ) ) ;
146- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 196 , characters 7-14" , "dog" , describePhantom ( new UntaggedDog ( ) ) ) ;
159+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 212 , characters 7-14" , "animal" , describePhantom ( new UntaggedAnimal ( ) ) ) ;
160+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 213 , characters 7-14" , "dog" , describePhantom ( new UntaggedDog ( ) ) ) ;
147161 } ) ;
148162 Mocha . test ( "a function case excludes class instances" , ( ) => {
149- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 200, characters 7-14" , "callable" , handlerKind ( new UntaggedCallable ( ) ) ) ;
150- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 201, characters 7-14" , "function" , handlerKind ( x => x ) ) ;
163+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 217, characters 7-14" , "callable" , handlerKind ( new UntaggedCallable ( ) ) ) ;
164+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 218, characters 7-14" , "function" , handlerKind ( x => x ) ) ;
165+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 219, characters 7-14" , "other" , wideHandlerKind ( new UntaggedCallable ( ) ) ) ;
166+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 220, characters 7-14" , "other" , wideHandlerKind ( new UntaggedAnimal ( ) ) ) ;
167+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 221, characters 7-14" , "function" , wideHandlerKind ( x => x ) ) ;
168+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 222, characters 7-14" , "name" , "name" ) ;
169+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 223, characters 7-14" , "other" , "other" ) ;
151170 } ) ;
152171 Mocha . test ( "a class declared over an object type" , ( ) => {
153- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 205 , characters 7-14" , "dog" , objectOrNameKind ( new UntaggedDog ( ) ) ) ;
154- Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 206 , characters 7-14" , "rex" , "rex" ) ;
172+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 227 , characters 7-14" , "dog" , objectOrNameKind ( new UntaggedDog ( ) ) ) ;
173+ Test_utils . eq ( "File \"untagged_runtime_annotations_test.res\", line 228 , characters 7-14" , "rex" , "rex" ) ;
155174 } ) ;
156175} ) ;
157176
@@ -169,6 +188,7 @@ export {
169188 localeKind ,
170189 describePhantom ,
171190 handlerKind ,
191+ wideHandlerKind ,
172192 objectOrNameKind ,
173193}
174194/* Not a pure module */
0 commit comments