Skip to content
Snippets Groups Projects
compareArray.js 710 B
Newer Older
  • Learn to ignore specific revisions
  • 
    //-----------------------------------------------------------------------------
    
    function compareArray(a, b) {
      if (b.length !== a.length) {
        return false;
      }
    
      for (var i = 0; i < a.length; i++) {
        if (b[i] !== a[i]) {
          return false;
    
    assert.compareArray = function(actual, expected, message) {
      if (compareArray(actual, expected)) return;
    
    
      if (message === undefined) {
        message = '';
      } else {
        message += ' ';
      }
    
      message += 'Expected SameValue(«' + String(actual) + '», «' + String(expected) + '») to be true';
    
      $ERROR(`${message}${message === undefined ? '' : ' '}Expected the arrays [${actual}] to have the same contents as [${expected}]`);
    }