license import '../../dist/zone-node' ; const testClosureFunction = ( ) => { const logs = [ ] ; const testZoneSpec = { name : 'closure' , properties : { } , onFork : ( parentZoneDelegate , currentZone , targetZone , zoneSpec ) => { return parentZoneDelegate . fork ( targetZone , zoneSpec ) ; } , onIntercept : ( parentZoneDelegate , currentZone , targetZone , delegate , source ) => { return parentZoneDelegate . intercept ( targetZone , delegate , source ) ; } , onInvoke : function ( parentZoneDelegate , currentZone , targetZone , delegate , applyThis ? , applyArgs ? , source ? ) { return parentZoneDelegate . invoke ( targetZone , delegate , applyThis , applyArgs , source ) ; } , onHandleError : function ( parentZoneDelegate , currentZone , targetZone , error ) { return parentZoneDelegate . handleError ( targetZone , error ) ; } , onScheduleTask : function ( parentZoneDelegate , currentZone , targetZone , task ) { return parentZoneDelegate . scheduleTask ( targetZone , task ) ; } , onInvokeTask : function ( parentZoneDelegate , currentZone , targetZone , task , applyThis ? , applyArgs ? ) { return parentZoneDelegate . invokeTask ( targetZone , task , applyThis , applyArgs ) ; } , onCancelTask : function ( parentZoneDelegate , currentZone , targetZone , task ) { return parentZoneDelegate . cancelTask ( targetZone , task ) ; } , onHasTask : function ( delegate , current , target , hasTaskState ) { return delegate . hasTask ( target , hasTaskState ) ; } } ; const testZone = Zone . current . fork ( testZoneSpec ) ; testZone . runGuarded ( ( ) => { testZone . run ( ( ) => { const properties = testZoneSpec . properties ; properties ! [ 'key' ] = 'value' ; const keyZone = Zone . current . getZoneWith ( 'key' ) ; logs . push ( 'current' + Zone . current . name ) ; logs . push ( 'parent' + Zone . current . parent ! . name ) ; logs . push ( 'getZoneWith' + keyZone ! . name ) ; logs . push ( 'get' + keyZone ! . get ( 'key' ) ) ; logs . push ( 'root' + Zone . root . name ) ; Object . keys ( ( Zone as any ) . prototype ) . forEach ( key => { logs . push ( key ) ; } ) ; Object . keys ( testZoneSpec ) . forEach ( key => { logs . push ( key ) ; } ) ; const task = Zone . current . scheduleMicroTask ( 'testTask' , ( ) => { } , undefined , ( ) => { } ) ; Object . keys ( task ) . forEach ( key => { logs . push ( key ) ; } ) ; } ) ; } ) ; const expectedResult = [ 'currentclosure' , 'parent<root>' , 'getZoneWithclosure' , 'getvalue' , 'root<root>' , 'parent' , 'name' , 'get' , 'getZoneWith' , 'fork' , 'wrap' , 'run' , 'runGuarded' , 'runTask' , 'scheduleTask' , 'scheduleMicroTask' , 'scheduleMacroTask' , 'scheduleEventTask' , 'cancelTask' , '_updateTaskCount' , 'name' , 'properties' , 'onFork' , 'onIntercept' , 'onInvoke' , 'onHandleError' , 'onScheduleTask' , 'onInvokeTask' , 'onCancelTask' , 'onHasTask' , '_zone' , 'runCount' , '_zoneDelegates' , '_state' , 'type' , 'source' , 'data' , 'scheduleFn' , 'cancelFn' , 'callback' , 'invoke' ] ; let result = true ; for ( let i = 0 ; i < expectedResult . length ; i ++ ) { if ( expectedResult [ i ] !== logs [ i ] ) { console . log ( 'Not Equals' , expectedResult [ i ] , logs [ i ] ) ; result = false ; } } process [ 'exit' ] ( result ? 0 : 1 ) ; } ; process [ 'on' ] ( 'uncaughtException' , ( err ) => { process [ 'exit' ] ( 1 ) ; } ) ; testClosureFunction ( ) ;