<commit_before>require('should');
var parser = require('../lib/parser'),
    sinon = require('sinon'),
    fs = require('fs'),
    resumer = require('resumer');

function spySplitter(expectedCount, done) {
    var callback = sinon.spy(),
        splitter = new parser.SDFSplitter(callback);

    splitter.on('finish', function () {
        (callback.callCount).should.be.exactly(expectedCount);

        done();
    });

    return splitter;
}

describe('streaming', function () {
    describe('splitter', function () {
        it('should be able to open a stream on the fixtures (single)', function (done) {
            var splitter = spySplitter(1, done);

            fs.createReadStream('test/fixtures/single.sdf')
                .pipe(splitter);
        });
        it('should be able to open a stream on the fixtures (double)', function (done) {
            var splitter = spySplitter(2, done);

            fs.createReadStream('test/fixtures/double.sdf')
                .pipe(splitter);
        });
        it('should be able to open a stream on the fixtures (many)', function (done) {
            var splitter = spySplitter(55, done);

            fs.createReadStream('test/fixtures/first-55.sdf')
                .pipe(splitter);
        });
        it('should pass the molfile contents to the callback', function (done) {
            var callback = sinon.spy(),
                splitter = new parser.SDFSplitter(callback);

            splitter.on('finish', function () {
                callback.calledWithExactly('foo\n');
                callback.calledWithExactly('bar\n');
                callback.calledWithExactly('bletch\n');
                done();
            });

            resumer().queue('foo\n$$$$\nbar\n$$$$\nbletch\n$$$$').end()
                .pipe(splitter);
        });
    });
});
<commit_msg>test: add test of DOS fixture<commit_after>require('should');
var parser = require('../lib/parser'),
    sinon = require('sinon'),
    fs = require('fs'),
    resumer = require('resumer');

function spySplitter(expectedCount, done) {
    var callback = sinon.spy(),
        splitter = new parser.SDFSplitter(callback);

    splitter.on('finish', function () {
        (callback.callCount).should.be.exactly(expectedCount);

        done();
    });

    return splitter;
}

describe('streaming', function () {
    describe('splitter', function () {
        it('should be able to open a stream on the fixtures (single)', function (done) {
            var splitter = spySplitter(1, done);

            fs.createReadStream('test/fixtures/single.sdf')
                .pipe(splitter);
        });
        it('should be able to open a stream on the fixtures (double)', function (done) {
            var splitter = spySplitter(2, done);

            fs.createReadStream('test/fixtures/double.sdf')
                .pipe(splitter);
        });
        it('should be able to open a stream on the DOS fixtures (double)', function (done) {
            var splitter = spySplitter(2, done);

            fs.createReadStream('test/fixtures/double-dos.sdf')
                .pipe(splitter);
        });
        it('should be able to open a stream on the fixtures (many)', function (done) {
            var splitter = spySplitter(55, done);

            fs.createReadStream('test/fixtures/first-55.sdf')
                .pipe(splitter);
        });
        it('should pass the molfile contents to the callback', function (done) {
            var callback = sinon.spy(),
                splitter = new parser.SDFSplitter(callback);

            splitter.on('finish', function () {
                callback.calledWithExactly('foo\n');
                callback.calledWithExactly('bar\n');
                callback.calledWithExactly('bletch\n');
                done();
            });

            resumer().queue('foo\n$$$$\nbar\n$$$$\nbletch\n$$$$').end()
                .pipe(splitter);
        });
    });
});

{'fraction_non_alphanumeric': 0.1450050968399592, 'fraction_numerical': 0.003312945973496432, 'mean_word_length': 2.1101426307448494, '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': '4773919', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1074, 'n_words': 245}