<commit_before>(function() {

    /**
     * Normalizes line endings by removing all \r (carriage return) characters.
     * In IE, newlines in textareas are stored as \r\n instead of just \n, which screws up length calculations.
     * All other browsers automatically remove \r characters when you set the value of the textarea.
     * @returns {string}
     */
    String.prototype.norm = function() {
        return this.replace(/\r/g, '');
    };

    pavlov.specify.extendAssertions({
        isOneOf: function(actual, expected, message) {
            ok(expected.indexOf(actual) !== -1, message);
        }
    });

    pavlov.specify('jQuery Caret Plugin', function() {

        var _e = function(tagName) {
            return document.createElement(tagName);
        };

        var _s = function(obj) {
            return JSON.stringify(obj, null, '    ');
        };

        var _support = {
            normalizesNewlines: (function () {
                var textarea = _e('textarea');
                var text = 'abc\r\ndef';
                textarea.value = text;
                return textarea.value.length === text.length - 1;
            }())
        };

        var $fixture = $('#qunit-fixture');

        var _single = 'abcdefghijklmnop',
            _multi = 'abcdefg\r\nhijklmnop',
            _short = 'abc',
            _long = 'abcdefghijklmnopqrstuvwxyz',
            _empty = '';

        describe('All Plugins', function() {
            var $input, $textarea;

            // befores and afters:

            before(function() {
                $input = $('<input/>').appendTo($fixture);
                $textarea = $('<textarea/>').appendTo($fixture);
            });

            // plugins:

            describe('Caret', function() {
                describe('Get', function() {
                    // Note: Every browser handles automatic caret placement a little differently,
                    // which means our tests need to accommodate both placement strategies
                    // (at the beginning and end of the input/textarea).

                    it("Returns undefined when the jQuery object does not contain an input or textarea element", function() {
                        assert($().caret()).isUndefined();
                        assert($({}).caret()).isUndefined();
                        assert($('<div/>').caret()).isUndefined();
                        assert($([ _e('span'), _e('div'), _e('button') ]).caret()).isUndefined();
                    });

                    describe('<input>', function() {
                        it("Returns the caret position of the first input or textarea element in the jQuery object", function() {
                            var span = _e('span'),
                                div = _e('div'),
                                button = _e('button');

                            // IE throws a hissy fit if the inputs aren't inserted into the DOM before calling
                            // .focus(), .createTextRange(), etc.
                            var input3 = $('<input/>').appendTo($fixture).val('abc').caret(3)[0],
                                input4 = $('<input/>').appendTo($fixture).val('defg').caret(4)[0],
                                input5 = $('<input/>').appendTo($fixture).val('12345').caret(5)[0];

                            assert($([ span, div, button, input3 ]).caret()).equals(3);
                            assert($([ input3, input4, input5 ]).caret()).equals(3);
                            assert($([ input5, input4, input3 ]).caret()).equals(5);
                        });
                    });<commit_msg>Fixed test for IE<commit_after>(function() {

    /**
     * Normalizes line endings by removing all \r (carriage return) characters.
     * In IE, newlines in textareas are stored as \r\n instead of just \n, which screws up length calculations.
     * All other browsers automatically remove \r characters when you set the value of the textarea.
     * @returns {string}
     */
    String.prototype.norm = function() {
        return this.replace(/\r/g, '');
    };

    pavlov.specify.extendAssertions({
        isOneOf: function(actual, expected, message) {
            ok(expected.indexOf(actual) !== -1, message);
        }
    });

    pavlov.specify('jQuery Caret Plugin', function() {

        var _e = function(tagName) {
            return document.createElement(tagName);
        };

        var _s = function(obj) {
            return JSON.stringify(obj, null, '    ');
        };

        var _support = {
            normalizesNewlines: (function () {
                var textarea = _e('textarea');
                var text = 'abc\r\ndef';
                textarea.value = text;
                return textarea.value.length === text.length - 1;
            }())
        };

        var $fixture = $('#qunit-fixture');

        var _single = 'abcdefghijklmnop',
            _multi = 'abcdefg\r\nhijklmnop',
            _short = 'abc',
            _long = 'abcdefghijklmnopqrstuvwxyz',
            _empty = '';

        describe('All Plugins', function() {
            var $input, $textarea;

            // befores and afters:

            before(function() {
                $input = $('<input/>').appendTo($fixture);
                $textarea = $('<textarea/>').appendTo($fixture);
            });

            // plugins:

            describe('Caret', function() {
                describe('Get', function() {
                    // Note: Every browser handles automatic caret placement a little differently,
                    // which means our tests need to accommodate both placement strategies
                    // (at the beginning and end of the input/textarea).

                    it("Returns undefined when the jQuery object does not contain an input or textarea element", function() {
                        assert($().caret()).isUndefined();
                        assert($({}).caret()).isUndefined();
                        assert($('<div/>').caret()).isUndefined();
                        assert($([ _e('span'), _e('div'), _e('button') ]).caret()).isUndefined();
                    });

                    describe('<input>', function() {
                        it("Returns the caret position of the first input or textarea element in the jQuery object", function() {
                            var span = _e('span'),
                                div = _e('div'),
                                button = _e('button');

                            $input.val('abcdef').caret(3);

                            assert($([ span, div, button, $input[0] ]).caret()).equals(3);
                        });
                    });
{'fraction_non_alphanumeric': 0.13624181060154855, 'fraction_numerical': 0.004615842763549732, 'mean_word_length': 1.511967090501122, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3982512', 'n_tokens_mistral': 1753, 'n_tokens_neox': 1635, 'n_words': 445}