<commit_before>/**
 * grunt-responsive-images
 * https://github.com/andismith/grunt-responsive-images
 *
 * Copyright (c) 2013 andismith
 * Licensed under the MIT license.
 *
 * Test suite for Grunt Responsive Images
 *
 * @author <NAME> (http://twitter.com/andismith)
 * @version 1.0
 */


/*
  ======== A Handy Little Nodeunit Reference ========
  https://github.com/caolan/nodeunit

  Test methods:
    test.expect(numAssertions)
    test.done()
  Test assertions:
    test.ok(value, [message])
    test.equal(actual, expected, [message])
    test.notEqual(actual, expected, [message])
    test.deepEqual(actual, expected, [message])
    test.notDeepEqual(actual, expected, [message])
    test.strictEqual(actual, expected, [message])
    test.notStrictEqual(actual, expected, [message])
    test.throws(block, [error], [message])
    test.doesNotThrow(block, [error], [message])
    test.ifError(value)
*/

(function() {
  'use strict';

  var async = require('async'),
    grunt = require('grunt'),
    im = require('node-imagemagick'),
    q = require('q');

  /**
   * Compare the created image against the expected image.
   *
   * @private
   * @param   {string}  filename  The name of the file
   * @param   {string}  actual    The actual file path
   * @param   {string}  expected  The expected file path
   * @return  {object}  promise   Either resolved rejected with an error message.
   */
  var compareImageProperties = function(filename, actualPath, expectedPath) {
    var deferred = q.defer();
    
    // load created image
    im.identify(actualPath + filename, function(error, actualProp) {
      if (error) {
        deferred.reject('Failed to load actual (created) image "' + actualPath + filename + '"');
      } else {
        // load expected image
        im.identify(expectedPath + filename, function(error, expectedProp) {
          if (error) {
            deferred.reject('Failed to load expected image "' + expectedPath + filename + '"');
          } else {
            // check if we have a match
            if ((actualProp.compression === expectedProp.compression) &&
              (actualProp.width === expectedProp.width) &&
              (actualProp.height === expectedProp.height) &&
              (actualProp.quality === expectedProp.quality) &&
              (actualProp.filesize === expectedProp.filesize)) {
              deferred.resolve(true);
            } else {
              deferred.reject(filename + ': ' +
                'actual image (' + actualProp.compression + ' ' + actualProp.width + 'x' + actualProp.height +
                ' - Q:' + actualProp.quality + ' - ' + actualProp.filesize +
                ') and ' +
                'expected image (' + expectedProp.compression + ' ' + expectedProp.width + 'x' + expectedProp.height +
                ' - Q:' + expectedProp.quality + ' - ' + expectedProp.filesize +
                ') should match');<commit_msg>Fix to get Travis-CI passing (hopefully)<commit_after>/**
 * grunt-responsive-images
 * https://github.com/andismith/grunt-responsive-images
 *
 * Copyright (c) 2013 andismith
 * Licensed under the MIT license.
 *
 * Test suite for Grunt Responsive Images
 *
 * @author <NAME> (http://twitter.com/andismith)
 * @version 1.0
 */


/*
  ======== A Handy Little Nodeunit Reference ========
  https://github.com/caolan/nodeunit

  Test methods:
    test.expect(numAssertions)
    test.done()
  Test assertions:
    test.ok(value, [message])
    test.equal(actual, expected, [message])
    test.notEqual(actual, expected, [message])
    test.deepEqual(actual, expected, [message])
    test.notDeepEqual(actual, expected, [message])
    test.strictEqual(actual, expected, [message])
    test.notStrictEqual(actual, expected, [message])
    test.throws(block, [error], [message])
    test.doesNotThrow(block, [error], [message])
    test.ifError(value)
*/

(function() {
  'use strict';

  var async = require('async'),
    grunt = require('grunt'),
    im = require('node-imagemagick'),
    q = require('q');

  /**
   * Compare the created image against the expected image.
   *
   * @private
   * @param   {string}  filename  The name of the file
   * @param   {string}  actual    The actual file path
   * @param   {string}  expected  The expected file path
   * @return  {object}  promise   Either resolved rejected with an error message.
   */
  var compareImageProperties = function(filename, actualPath, expectedPath) {
    var deferred = q.defer();
    
    // load created image
    im.identify(actualPath + filename, function(error, actualProp) {
      if (error) {
        deferred.reject('Failed to load actual (created) image "' + actualPath + filename + '"');
      } else {
        // load expected image
        im.identify(expectedPath + filename, function(error, expectedProp) {
          if (error) {
            deferred.reject('Failed to load expected image "' + expectedPath + filename + '"');
          } else {
            // check if we have a match
            if ((actualProp.compression === expectedProp.compression) &&
              (actualProp.width === expectedProp.width) &&
              (actualProp.height === expectedProp.height) &&
              (actualProp.quality === expectedProp.quality)) {
              deferred.resolve(true);
            } else {
              deferred.reject(filename + ': ' +
                'actual image (' + actualProp.compression + ' ' + actualProp.width +
                'x' + actualProp.height + ' - Q:' + actualProp.quality
                ') and ' +
                'expected image (' + expectedProp.compression + ' ' + expectedProp.width +
                'x' + expectedProp.height + ' - Q:' + expectedProp.quality
                ') should match');
{'fraction_non_alphanumeric': 0.13672828740844087, 'fraction_numerical': 0.0020927799093128706, 'mean_word_length': 2.5510835913312695, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5913438', 'n_tokens_mistral': 1647, 'n_tokens_neox': 1595, 'n_words': 398}