module armExplorer { export function keyCount ( arg ) { let count = 0 ; for ( let key in arg ) { if ( arg . hasOwnProperty ( key ) ) { count ++ ; } } return count ; } export function throwIfObjectNotEqual < T > ( expected , actual ) { throwIfNotEqual ( keyCount ( expected ) , keyCount ( actual ) ) ; for ( let key in expected ) { if ( expected . hasOwnProperty ( key ) ) { if ( typeof expected [ key ] === 'object' ) { throwIfObjectNotEqual ( expected [ key ] , actual [ key ] ) ; } else { throwIfNotEqual ( expected [ key ] , actual [ key ] ) ; } } } } export function throwIfArrayNotEqual < T > ( expectedStrings , actualStrings ) { if ( expectedStrings . length != actualStrings . length ) { throw new Error ( "Expected: " + expectedStrings . length + "\nActual: " + actualStrings . length + "\n" ) ; } for ( let i in expectedStrings ) { if ( expectedStrings . hasOwnProperty ( i ) ) { throwIfNotEqual ( expectedStrings [ i ] , actualStrings [ i ] ) ; } } } export function throwIfNotEqual < T > ( expected , actual ) { if ( typeof expected === 'object' ) { throwIfObjectNotEqual ( expected , actual ) ; } else { if ( expected !== actual ) { throw new Error ( "Expected: " + expected + "\nActual: " + actual + "\n" ) ; } } } export function throwIfDefined ( arg ) { if ( typeof arg === 'undefined' ) return ; throw new Error ( "Expected: undefined Actual: " + arg ) ; } export function logSuccess ( callerArg ) { let currentFunction = callerArg . callee . toString ( ) ; console . log ( currentFunction . substr ( 0 , currentFunction . indexOf ( '(' ) ) . replace ( "function" , "TEST" ) + " :PASSED" ) ; } }