test/intl/assert.js
/**
 * Compares two JavaScript values for type and value equality.
 * It checks internals of arrays and objects.
 */
Compares two JavaScript values for type and value equality.
It checks internals of arrays and objects.
Compares two JavaScript values for type and value equality . It checks internals of arrays and objects .
function deepEquals(a, b) {
  if (a === b) {
    if (a === 0) return (1 / a) === (1 / b);
    return true;
  }
  if (typeof a != typeof b) return false;
  if (typeof a == 'number') return isNaN(a) && isNaN(b);
  if (typeof a !== 'object' && typeof a !== 'function') return false;
  var objectClass = classOf(a);
  if (objectClass !== classOf(b)) return false;
  if (objectClass === 'RegExp') {
    return (a.toString() === b.toString());
  }
  if (objectClass === 'Function') return false;
  if (objectClass === 'Array') {
    var elementCount = 0;
    if (a.length != b.length) {
      return false;
    }
    for (var i = 0; i < a.length; i++) {
      if (!deepEquals(a[i], b[i])) return false;
    }
    return true;
  }
  if (objectClass == 'String' || objectClass == 'Number' ||
      objectClass == 'Boolean' || objectClass == 'Date') {
    if (a.valueOf() !== b.valueOf()) return false;
  }
  return deepObjectEquals(a, b);
}
function deepEquals ( a , b ) { if ( a === b ) { if ( a === 0 ) return ( 1 / a ) === ( 1 / b ) ; return true ; } if ( typeof a != typeof b ) return false ; if ( typeof a == 'number' ) return isNaN ( a ) && isNaN ( b ) ; if ( typeof a !== 'object' && typeof a !== 'function' ) return false ; var objectClass = classOf ( a ) ; if ( objectClass !== classOf ( b ) ) return false ; if ( objectClass === 'RegExp' ) { return ( a . toString ( ) === b . toString ( ) ) ; } if ( objectClass === 'Function' ) return false ; if ( objectClass === 'Array' ) { var elementCount = 0 ; if ( a . length != b . length ) { return false ; } for ( var i = 0 ; i < a . length ; i ++ ) { if ( ! deepEquals ( a [ i ] , b [ i ] ) ) return false ; } return true ; } if ( objectClass == 'String' || objectClass == 'Number' || objectClass == 'Boolean' || objectClass == 'Date' ) { if ( a . valueOf ( ) !== b . valueOf ( ) ) return false ; } return deepObjectEquals ( a , b ) ; }
Compares two JavaScript values for type and value equality.
Compares two JavaScript values for type and value equality .
// Check for -0. // Neither a nor b is primitive. // For RegExp, just compare pattern and flags using its toString. // Functions are only identical to themselves.