license import { ExecutionContext } from './execution_context' ; import { TensorArray } from './tensor_array' ; let context ; let tensorArray ; describe ( 'ExecutionContext' , ( ) => { beforeEach ( ( ) => { context = new ExecutionContext ( { } , { } , { } ) ; } ) ; it ( 'should initialize' , ( ) => { expect ( context . currentContext ) . toEqual ( [ { id : 0 , frameName : '' , iterationId : 0 } ] ) ; expect ( context . currentContextId ) . toEqual ( '' ) ; } ) ; describe ( 'tensor array' , ( ) => { beforeEach ( ( ) => { tensorArray = new TensorArray ( '' , 'float32' , 10 , [ 1 ] , true , true , true ) ; } ) ; it ( 'should be able to add tensor array' , ( ) => { context . addTensorArray ( tensorArray ) ; expect ( context . getTensorArray ( tensorArray . id ) ) . toBe ( tensorArray ) ; } ) ; it ( 'should be able to read tensor array' , ( ) => { expect ( context . getTensorArray ( tensorArray . id ) ) . toBeUndefined ( ) ; } ) ; } ) ; describe ( 'enterFrame' , ( ) => { it ( 'should add new Frame' , ( ) => { context . enterFrame ( '1' ) ; expect ( context . currentContextId ) . toEqual ( '/1-0' ) ; expect ( context . currentContext ) . toEqual ( [ { id : 0 , frameName : '' , iterationId : 0 } , { id : 1 , frameName : '1' , iterationId : 0 } ] ) ; } ) ; } ) ; describe ( 'exitFrame' , ( ) => { it ( 'should remove Frame' , ( ) => { context . enterFrame ( '1' ) ; context . exitFrame ( ) ; expect ( context . currentContextId ) . toEqual ( '' ) ; expect ( context . currentContext ) . toEqual ( [ { id : 0 , frameName : '' , iterationId : 0 } ] ) ; } ) ; it ( 'should remember previous Frame' , ( ) => { context . enterFrame ( '1' ) ; context . nextIteration ( ) ; context . enterFrame ( '2' ) ; context . exitFrame ( ) ; expect ( context . currentContextId ) . toEqual ( '/1-1' ) ; expect ( context . currentContext ) . toEqual ( [ { id : 0 , frameName : '' , iterationId : 0 } , { id : 2 , frameName : '1' , iterationId : 1 } ] ) ; } ) ; } ) ; describe ( 'nextIteration' , ( ) => { it ( 'should increate iteration' , ( ) => { context . enterFrame ( '1' ) ; context . nextIteration ( ) ; expect ( context . currentContextId ) . toEqual ( '/1-1' ) ; expect ( context . currentContext ) . toEqual ( [ { id : 0 , frameName : '' , iterationId : 0 } , { id : 2 , frameName : '1' , iterationId : 1 } ] ) ; } ) ; } ) ; } ) ;