<commit_before>var assert = require('chai').assert,
    escape = require('./index');

suite('escape-latex', function () {
    test('should escape # correctly', function () {
        assert.equal("Hashtag \\#yolo is all the rage these days \\#twitter",
            escape("Hashtag #yolo is all the rage these days #twitter"));
    });
    test('should escape $ correctly', function () {
        assert.equal("\\$2 is greater than \\$1",
            escape("$2 is greater than $1"));
    });
    test('should escape % correctly', function () {
        assert.equal("100\\% is 20\\% point greater than 80\\%",
            escape("100% is 20% point greater than 80%"));
    });
    test('should escape & correctly', function () {
        assert.equal("Me \\& you \\& a dog named Boo",
            escape("Me & you & a dog named Boo"));
    });
    test('should escape backlash correctly', function () {
        assert.equal("C:\\textbackslash{} is a good place to format",
            escape("C:\\ is a good place to format"));
    });
    test('should escape { correctly', function () {
        assert.equal("This \\{ does not have an matching bracket",
            escape("This { does not have an matching bracket"));
    });
    test('should escape } correctly', function () {
        assert.equal("There is no opening bracket for this \\}",
            escape("There is no opening bracket for this }"));
    });
    test('should escape ^ correctly', function () {
        assert.equal("2\\textasciicircum{}2\\textasciicircum{}2\\textasciicircum{}2 = 256",
            escape("2^2^2^2 = 256"));
    });
    test('should escape _ correctly', function () {
        assert.equal("\\_ is a shortcut to Underscore, e.g., \\_.each()",
            escape("_ is a shortcut to Underscore, e.g., _.each()"));
    });
    test('should escape ~ correctly', function () {
        assert.equal("pi \\textasciitilde{} 3.1416",
            escape("pi ~ 3.1416"));
    });
    test('should escape – (en-dash) correctly', function () {
        assert.equal("en dash \\-- is cool",
            escape("en dash – is cool"));
    });
    test('should escape — (em-dash) correctly', function () {
        assert.equal("em dash \\--- is cooler",
            escape("em dash — is cooler"));
    });
    test('should not escape - (hyphen)', function () {
        assert.equal("hyphen - is the best",
            escape("hyphen - is the best"));
    });
    test('stack overflow test', function () {
        // The original algorithm of this library uses recursions to escape
        // the string, which is prone to stack overflow if the input string
        // contains a lot of characters that need to be escaped. This test
        // ensures that we won't run into it in the future.
        var numChars = 100000;
        var str = Array(numChars).join("\\");
        var escapedStr = Array(numChars).join("\\textbackslash{}")
        assert.equal(escapedStr, escape(str));
    });
    test('composite test 1', function () {
        assert.equal("These \\{\\} should be escaped, as well as this \\textbackslash{} character",
            escape("These {} should be escaped, as well as this \\ character"));
    });
});
<commit_msg>A couple more edge case tests<commit_after>var assert = require('chai').assert,
    escape = require('./index');

suite('escape-latex', function () {
    test('should escape empty string correctly', function () {
        assert.equal("", escape(""));
    })
    test('should escape casted string correctly', function () {
        assert.equal("1", escape(1));
    })
    test('should escape # correctly', function () {
        assert.equal("Hashtag \\#yolo is all the rage these days \\#twitter",
            escape("Hashtag #yolo is all the rage these days #twitter"));
    });
    test('should escape $ correctly', function () {
        assert.equal("\\$2 is greater than \\$1",
            escape("$2 is greater than $1"));
    });
    test('should escape % correctly', function () {
        assert.equal("100\\% is 20\\% point greater than 80\\%",
            escape("100% is 20% point greater than 80%"));
    });
    test('should escape & correctly', function () {
        assert.equal("Me \\& you \\& a dog named Boo",
            escape("Me & you & a dog named Boo"));
    });
    test('should escape backlash correctly', function () {
        assert.equal("C:\\textbackslash{} is a good place to format",
            escape("C:\\ is a good place to format"));
    });
    test('should escape { correctly', function () {
        assert.equal("This \\{ does not have an matching bracket",
            escape("This { does not have an matching bracket"));
    });
    test('should escape } correctly', function () {
        assert.equal("There is no opening bracket for this \\}",
            escape("There is no opening bracket for this }"));
    });
    test('should escape ^ correctly', function () {
        assert.equal("2\\textasciicircum{}2\\textasciicircum{}2\\textasciicircum{}2 = 256",
            escape("2^2^2^2 = 256"));
    });
    test('should escape _ correctly', function () {
        assert.equal("\\_ is a shortcut to Underscore, e.g., \\_.each()",
            escape("_ is a shortcut to Underscore, e.g., _.each()"));
    });
    test('should escape ~ correctly', function () {
        assert.equal("pi \\textasciitilde{} 3.1416",
            escape("pi ~ 3.1416"));
    });
    test('should escape – (en-dash) correctly', function () {
        assert.equal("en dash \\-- is cool",
            escape("en dash – is cool"));
    });
    test('should escape — (em-dash) correctly', function () {
        assert.equal("em dash \\--- is cooler",
            escape("em dash — is cooler"));
    });
    test('should not escape - (hyphen)', function () {
        assert.equal("hyphen - is the best",
            escape("hyphen - is the best"));
    });
    test('stack overflow test', function () {
        // The original algorithm of this library uses recursions to escape
        // the string, which is prone to stack overflow if the input string
        // contains a lot of characters that need to be escaped. This test
        // ensures that we won't run into it in the future.
        var numChars = 100000;
        var str = Array(numChars).join("\\");
        var escapedStr = Array(numChars).join("\\textbackslash{}")
        assert.equal(escapedStr, escape(str));
    });
    test('composite test 1', function () {
        assert.equal("These \\{\\} should be escaped, as well as this \\textbackslash{} character",
            escape("These {} should be escaped, as well as this \\ character"));
    });
});

{'fraction_non_alphanumeric': 0.16187753873928087, 'fraction_numerical': 0.015044380923724988, 'mean_word_length': 2.3849287169042768, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3117791', 'n_tokens_mistral': 1881, 'n_tokens_neox': 1776, 'n_words': 609}