<commit_before>(function () {
    'use strict';
    /*jshint expr: true*/

    var EventEmitter = require('events').EventEmitter,
        EEX = require('../EventEmitterEx'),
        emitter;

    beforeEach(function () {
        emitter = new EEX();
    });

    describe('EventEmitterEx', function () {

        describe('#startAsync()', function () {

            it('should throw exception on non-function arguments', function () {
                expect(function () {
                    EEX.startAsync(42);
                }).to.throw(TypeError, /Argument must be a function/);
            });

            it('should call function with a new emitter', function (done) {
                var eexResult = EEX.startAsync(function (eex) {
                    eex.should.be.equal(eexResult);
                    done();
                });
                eexResult.should.be.instanceOf(EEX);
            });

        });

        describe('#emitAsync()', function () {

            it('should call emit() asynchronously', function (done) {
                var spyEnd = sinon.spy();

                emitter
                    .on('error', done)
                    .on('end1', spyEnd)
                    .on('end', function () {
                        spyEnd.calledWithExactly(1, 2, 3).should.be.true;
                        done();
                    })
                    .emitAsync('end1', 1, 2, 3)
                    .emitAsync('end')
                    .should.be.equal(emitter);

                spyEnd.callCount.should.be.equal(0);
            });

            it('should return self', function (done) {
                emitter
                    .on('error', done)
                    .on('end', done)
                    .emitAsync('end').should.be.equal(emitter);
            });

        });

        describe('#startPipeline()', function () {

            it('should call emitAsync() with "end" event type', function () {
                var A = 42, B = 17, mockEmitter = sinon.mock(emitter);

                mockEmitter
                    .expects('emitAsync')
                    .withExactArgs('end', A, B);

                emitter.startPipeline(A, B);
            });

            it('should return self', function () {
                var mockEmitter = sinon.mock(emitter);

                mockEmitter
                    .expects('emitAsync')
                    .withExactArgs('end')
                    .returnsThis();

                emitter.startPipeline().should.be.equal(emitter);
            });

        });

        describe('#pipeExcept()', function () {

            var i = 0;
            [EventEmitter, EEX].forEach(function (SourceType) {
                i++;
                var source;

                beforeEach(function () {
                    source = new SourceType();
                });

                it('should return self #' + i, function () {
                    emitter.pipeExcept(source).should.be.equal(emitter);
                });

                it('should call corresponding callbacks on original emitter #' + i, function () {
                    var spyA = sinon.spy(),
                        spyError1 = sinon.spy(),<commit_msg>Invalid type test<commit_after>(function () {
    'use strict';
    /*jshint expr: true*/

    var EventEmitter = require('events').EventEmitter,
        EEX = require('../EventEmitterEx'),
        emitter;

    beforeEach(function () {
        emitter = new EEX();
    });

    describe('EventEmitterEx', function () {

        describe('#startAsync()', function () {

            it('should throw exception on non-function arguments', function () {
                expect(function () {
                    EEX.startAsync(42);
                }).to.throw(TypeError, /Argument must be a function/);
            });

            it('should call function with a new emitter', function (done) {
                var eexResult = EEX.startAsync(function (eex) {
                    eex.should.be.equal(eexResult);
                    done();
                });
                eexResult.should.be.instanceOf(EEX);
            });

        });

        describe('#emitAsync()', function () {

            it('should call emit() asynchronously', function (done) {
                var spyEnd = sinon.spy();

                emitter
                    .on('error', done)
                    .on('end1', spyEnd)
                    .on('end', function () {
                        spyEnd.calledWithExactly(1, 2, 3).should.be.true;
                        done();
                    })
                    .emitAsync('end1', 1, 2, 3)
                    .emitAsync('end')
                    .should.be.equal(emitter);

                spyEnd.callCount.should.be.equal(0);
            });

            it('should return self', function (done) {
                emitter
                    .on('error', done)
                    .on('end', done)
                    .emitAsync('end').should.be.equal(emitter);
            });

        });

        describe('#startPipeline()', function () {

            it('should call emitAsync() with "end" event type', function () {
                var A = 42, B = 17, mockEmitter = sinon.mock(emitter);

                mockEmitter
                    .expects('emitAsync')
                    .withExactArgs('end', A, B);

                emitter.startPipeline(A, B);
            });

            it('should return self', function () {
                var mockEmitter = sinon.mock(emitter);

                mockEmitter
                    .expects('emitAsync')
                    .withExactArgs('end')
                    .returnsThis();

                emitter.startPipeline().should.be.equal(emitter);
            });

        });

        describe('#pipeExcept()', function () {

            it('should throw on invalid argument', function () {
                expect(function () {
                    emitter.pipeExcept({});
                }).to.throw(TypeError, /Expecting EventEmitter or EventEmitterEx/);
            });

            var i = 0;
            [EventEmitter, EEX].forEach(function (SourceType) {
                i++;
                var source;

                beforeEach(function () {
                    source = new SourceType();
                });

                it('should return self #' + i, function () {
                    emitter.pipeExcept(source).should.be.equal(emitter);
                });

                it('should call corresponding callbacks on original emitter #' + i, function () {
                    var spyA = sinon.spy(),
                        spyError1 = sinon.spy(),
{'fraction_non_alphanumeric': 0.129526671675432, 'fraction_numerical': 0.005108940646130729, 'mean_word_length': 1.2463719203509955, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7432338', 'n_tokens_mistral': 1761, 'n_tokens_neox': 1576, 'n_words': 338}