5
5
6
6
import * as assert from 'assert' ;
7
7
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors' ;
8
- import { createDecorator , IInstantiationService , optional , ServicesAccessor } from 'vs/platform/instantiation/common/instantiation' ;
8
+ import { createDecorator , IInstantiationService , ServicesAccessor } from 'vs/platform/instantiation/common/instantiation' ;
9
9
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService' ;
10
10
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection' ;
11
11
@@ -85,18 +85,7 @@ class TargetWithStaticParam {
85
85
}
86
86
}
87
87
88
- class TargetNotOptional {
89
- constructor ( @IService1 service1 : IService1 , @IService2 service2 : IService2 ) {
90
88
91
- }
92
- }
93
- class TargetOptional {
94
- constructor ( @IService1 service1 : IService1 , @optional ( IService2 ) service2 : IService2 ) {
95
- assert . ok ( service1 ) ;
96
- assert . strictEqual ( service1 . c , 1 ) ;
97
- assert . ok ( service2 === undefined ) ;
98
- }
99
- }
100
89
101
90
class DependentServiceTarget {
102
91
constructor ( @IDependentService d : IDependentService ) {
@@ -181,13 +170,6 @@ suite('Instantiation Service', () => {
181
170
let service = new InstantiationService ( collection ) ;
182
171
service . createInstance ( Service1Consumer ) ;
183
172
184
- // no IService2
185
- assert . throws ( ( ) => service . createInstance ( Target2Dep ) ) ;
186
- service . invokeFunction ( function ( a ) {
187
- assert . ok ( a . get ( IService1 ) ) ;
188
- assert . ok ( ! a . get ( IService2 , optional ) ) ;
189
- } ) ;
190
-
191
173
collection . set ( IService2 , new Service2 ( ) ) ;
192
174
193
175
service . createInstance ( Target2Dep ) ;
@@ -197,18 +179,6 @@ suite('Instantiation Service', () => {
197
179
} ) ;
198
180
} ) ;
199
181
200
- test ( '@Param - optional' , function ( ) {
201
- let collection = new ServiceCollection ( [ IService1 , new Service1 ( ) ] ) ;
202
- let service = new InstantiationService ( collection , true ) ;
203
-
204
- service . createInstance ( TargetOptional ) ;
205
- assert . throws ( ( ) => service . createInstance ( TargetNotOptional ) ) ;
206
-
207
- service = new InstantiationService ( collection , false ) ;
208
- service . createInstance ( TargetOptional ) ;
209
- service . createInstance ( TargetNotOptional ) ;
210
- } ) ;
211
-
212
182
// we made this a warning
213
183
// test('@Param - too many args', function () {
214
184
// let service = instantiationService.create(Object.create(null));
@@ -320,7 +290,6 @@ suite('Instantiation Service', () => {
320
290
function test ( accessor : ServicesAccessor ) {
321
291
assert . ok ( accessor . get ( IService1 ) instanceof Service1 ) ;
322
292
assert . throws ( ( ) => accessor . get ( IService2 ) ) ;
323
- assert . strictEqual ( accessor . get ( IService2 , optional ) , undefined ) ;
324
293
return true ;
325
294
}
326
295
assert . strictEqual ( service . invokeFunction ( test ) , true ) ;
0 commit comments