<commit_before>var purely = {
    throwAssertionError: function(msg) {
        // throws TypeError as there isn't a built-in assertion error type
        throw TypeError('AssertionError: ' + msg);

        /*
            // Safer alternative?
            throw {
                name: 'TypeError',
                message: 'AssertionError: ' + msg
            };
        */
    },

    contains: function(item, arr) {
        var found = false;

        for (var i = 0; i < arr.length; i++) {
            if (arr[i] === item) {
                found = true;
                break;
            }
        }

        return found;
    },


    assertEqual: function(x, y) {
        // jshint -W018
        if (!(x === y)) {
            purely.throwAssertionError((x && x.toString()) + ' === ' + (y && y.toString()));
        }
    },

    assertNotEqual: function(x, y) {
        // jshint -W018
        if (!(x !== y)) {
            purely.throwAssertionError((x && x.toString()) + ' !== ' + (y && y.toString()));
        }
    },


    assertGreater: function(x, y) {
        // jshint -W018
        if (!(x > y)) {
            purely.throwAssertionError((x && x.toString()) + ' > ' + (y && y.toString()));
        }
    },

    assertGreaterEqual: function(x, y) {
        // jshint -W018
        if (!(x >= y)) {
            purely.throwAssertionError((x && x.toString()) + ' >= ' + (y && y.toString()));
        }
    },

    assertLess: function(x, y) {
        // jshint -W018
        if (!(x < y)) {
            purely.throwAssertionError((x && x.toString()) + ' < ' + (y && y.toString()));
        }
    },

    assertLessEqual: function(x, y) {
        // jshint -W018
        if (!(x <= y)) {
            purely.throwAssertionError((x && x.toString()) + ' <= ' + (y && y.toString()));
        }
    },


    assertIn: function(item, arr) {
        var found = purely.contains(item, arr);

        if (!found) {
            purely.throwAssertionError((item && item.toString()) + ' not in ' + (arr && arr.toString()));
        }
    },

    assertNotIn: function(item, arr) {
        var found = purely.contains(item, arr);

        if (found) {
            purely.throwAssertionError((item && item.toString()) + ' in ' + (arr && arr.toString()));
        }
    },


    assertRaises: function(exceptionName, func) {
        var thrown = false;

        try {
            func();
        } catch (e) {
            if (e.name === exceptionName) {
                thrown = true;
            }
        }

        if (!thrown) {
            purely.throwAssertionError(exceptionName + ' not thrown');
        }
    },

    assertRaisesAssertion: function(func) {
        var thrown = false;

        try {
            func();
        } catch (e) {
            if ((e.name === 'TypeError') && (/^AssertionError: /.test(e.message))) {
                thrown = true;
            }
        }

        if (!thrown) {
            purely.throwAssertionError('AssertionError not thrown');
        }
    }
};<commit_msg>follow standard convention of returning an object<commit_after>var purely = (function() {

    /*
     * Helper functions
     */

    var throwAssertionError = function(msg) {
        // throws TypeError as there isn't a built-in assertion error type
        throw TypeError('AssertionError: ' + msg);

        /*
            // Safer alternative?
            throw {
                name: 'TypeError',
                message: 'AssertionError: ' + msg
            };
        */
    };

    var contains = function(item, arr) {
        var found = false;

        for (var i = 0; i < arr.length; i++) {
            if (arr[i] === item) {
                found = true;
                break;
            }
        }

        return found;
    };


    /*
     * Public API
     */

    return {

        assertEqual: function(x, y) {
            // jshint -W018
            if (!(x === y)) {
                throwAssertionError((x && x.toString()) + ' === ' + (y && y.toString()));
            }
        },

        assertNotEqual: function(x, y) {
            // jshint -W018
            if (!(x !== y)) {
                throwAssertionError((x && x.toString()) + ' !== ' + (y && y.toString()));
            }
        },


        assertGreater: function(x, y) {
            // jshint -W018
            if (!(x > y)) {
                throwAssertionError((x && x.toString()) + ' > ' + (y && y.toString()));
            }
        },

        assertGreaterEqual: function(x, y) {
            // jshint -W018
            if (!(x >= y)) {
                throwAssertionError((x && x.toString()) + ' >= ' + (y && y.toString()));
            }
        },

        assertLess: function(x, y) {
            // jshint -W018
            if (!(x < y)) {
                throwAssertionError((x && x.toString()) + ' < ' + (y && y.toString()));
            }
        },

        assertLessEqual: function(x, y) {
            // jshint -W018
            if (!(x <= y)) {
                throwAssertionError((x && x.toString()) + ' <= ' + (y && y.toString()));
            }
        },


        assertIn: function(item, arr) {
            var found = contains(item, arr);

            if (!found) {
                throwAssertionError((item && item.toString()) + ' not in ' + (arr && arr.toString()));
            }
        },

        assertNotIn: function(item, arr) {
            var found = contains(item, arr);

            if (found) {
                throwAssertionError((item && item.toString()) + ' in ' + (arr && arr.toString()));
            }
        },


        assertRaises: function(exceptionName, func) {
            var thrown = false;

            try {
                func();
            } catch (e) {
                if (e.name === exceptionName) {
                    thrown = true;
                }
            }

            if (!thrown) {
                throwAssertionError(exceptionName + ' not thrown');
            }
        },

        assertRaisesAssertion: function(func) {
            var thrown = false;

            try {
                func();
            } catch (e) {
                if ((e.name === 'TypeError') && (/^AssertionError: /.test(e.message))) {
                    thrown = true;
                }
            }

            if (!thrown) {
                throwAssertionError('AssertionError not thrown');
            }
        }

    };

})();
{'fraction_non_alphanumeric': 0.15934323690383112, 'fraction_numerical': 0.005942142298670836, 'mean_word_length': 1.285101822079314, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '3267979', 'n_tokens_mistral': 1899, 'n_tokens_neox': 1797, 'n_words': 390}