<commit_before>"use strict";

var fs   = require("fs"),

    o         = require("ospec"),
    disparity = require("disparity"),
    
    transforms = fs.readdirSync("./transforms");

function noop() { }

o.spec("mithril-codemod", () => {
    transforms.forEach((t) => o(t, () => {
        var fn    = require(`../transforms/${t}/`),
            input = `./transforms/${t}/_input.js`,
            result, diff;
        
        result = fn({
            path   : input,
            source : fs.readFileSync(input, "utf8")
        }, {
            jscodeshift : require("jscodeshift"),
            
            stats : noop
        });

        diff = disparity.unified(fs.readFileSync(`./transforms/${t}/_output.js`, "utf8"), result, {
            paths : [
                `/transforms/${t}/_input.js (transformed)`,
                `./transforms/${t}/_output.js`
            ]
        });

        o(diff).equals("")(`\n${diff}`);
    }));
});


o.run();
<commit_msg>Tests trim input to disparity (just in case)<commit_after>"use strict";

var fs   = require("fs"),

    o         = require("ospec"),
    disparity = require("disparity"),
    
    transforms = fs.readdirSync("./transforms");

function noop() { }

o.spec("mithril-codemod", () => {
    transforms.forEach((t) => o(t, () => {
        var fn    = require(`../transforms/${t}/`),
            input = `./transforms/${t}/_input.js`,
            result, diff;
        
        result = fn({
            path   : input,
            source : fs.readFileSync(input, "utf8")
        }, {
            jscodeshift : require("jscodeshift"),
            
            stats : noop
        });

        diff = disparity.unified(fs.readFileSync(`./transforms/${t}/_output.js`, "utf8").trim(), result.trim(), {
            paths : [
                `/transforms/${t}/_input.js (transformed)`,
                `./transforms/${t}/_output.js`
            ]
        });

        o(diff).equals("")(`\n${diff}`);
    }));
});


o.run();

{'fraction_non_alphanumeric': 0.19667170953101362, 'fraction_numerical': 0.002017145738779627, 'mean_word_length': 1.681081081081081, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '6666665', 'n_tokens_mistral': 639, 'n_tokens_neox': 632, 'n_words': 95}