<commit_before>"use strict";

describe("stream/line", function () {

    it("generates lines out of any stream", function (done) {
        var lineIndex = 0,
            expectedLines = [
                "abcdef",
                "ghijkl",
                "mnopqr",
                "stuvwx",
                "yz"
            ],
            lineStream = new gpf.stream.LineAdapter(),
            outStream = {
                write: function (buffer) {
                    if (buffer !== expectedLines[lineIndex]) {
                        return Promise.reject("No match");
                    }
                    ++lineIndex;
                    return Promise.resolve("No match");
                }
            };
        lineStream.read(outStream)
            .then(function () {
                return lineStream.write("abc");
            })
            .then(function () {
                return lineStream.write("def\n");
            })
            .then(function () {
                return lineStream.write("gh");
            })
            .then(function () {
                return lineStream.write("ijkl\r");
            })
            .then(function () {
                return lineStream.write("\nmnopqr\n");
            })
            .then(function () {
                return lineStream.write("stuvwx\nyz");
            })
            .then(function () {
                return lineStream.write("\n");
            })
            .then(function () {
                done();
            })["catch"](done);

    });

});<commit_msg>Testing the sequences<commit_after>"use strict";

describe("stream/line", function () {

    function _part1 (lineStream) {
        return lineStream.write("abc")
            .then(function () {
                return lineStream.write("def\n");
            })
            .then(function () {
                return lineStream.write("gh");
            })
            .then(function () {
                return lineStream.write("ijkl\r");
            });
    }

    function _part2 (lineStream) {
        return lineStream.write("\nmnopqr\n")
            .then(function () {
                return lineStream.write("stuvwx\nyz");
            });
    }

    function _getOutput () {
        var lineIndex = 0,
            expectedLines = [
                "abcdef",
                "ghijkl",
                "mnopqr",
                "stuvwx",
                "yz"
            ];
        return {
            write: function (buffer) {
                if (buffer !== expectedLines[lineIndex]) {
                    return Promise.reject("No match");
                }
                ++lineIndex;
                return Promise.resolve();
            }
        };
    }

    it("generates lines out of any stream (read first)", function (done) {
        var lineStream = new gpf.stream.LineAdapter();
        lineStream.read(_getOutput())
            .then(function () {
                return _part1(lineStream);
            })
            .then(function () {
                return _part2(lineStream);
            })
            .then(function () {
                return lineStream.endOfStream();
            })
            .then(function () {
                done();
            })["catch"](done);
    });

    it("generates lines out of any stream (write first)", function (done) {
        var lineStream = new gpf.stream.LineAdapter();
        _part1(lineStream)
            .then(function () {
                return _part2(lineStream);
            })
            .then(function () {
                return lineStream.write("\n");
            })
            .then(function () {
                return lineStream.endOfStream();
            })
            .then(function () {
                return lineStream.read(_getOutput());
            })
            .then(function () {
                done();
            })["catch"](done);
    });

    it("generates lines out of any stream (mixed)", function (done) {
        var lineStream = new gpf.stream.LineAdapter();
        _part1(lineStream)
            .then(function () {
                return lineStream.read(_getOutput());
            })
            .then(function () {
                return _part2(lineStream);
            })
            .then(function () {
                return lineStream.endOfStream();
            })
            .then(function () {
                done();
            })["catch"](done);
    });

});
{'fraction_non_alphanumeric': 0.13053297199638664, 'fraction_numerical': 0.002258355916892502, 'mean_word_length': 1.16259765625, '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': '6302089', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1070, 'n_words': 198}