<commit_before>"use strict";

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

    describe("gpf.stream.ReadableString", function () {

        it("is accepts only IWritableStream", function () {
            var iReadableStream = new gpf.stream.ReadableString("Hello World"),
                exceptionCaught;
            try {
                iReadableStream.read({});
            } catch (e) {
                exceptionCaught = e;
            }
            assert(exceptionCaught instanceof gpf.Error.InterfaceExpected);
        });

        it("is protected against parallel calls", function () {
            var iWritableStream = {
                    write: function (buffer) {
                        assert("string" === typeof buffer);
                        return new Promise(function () {});
                    }
                },
                iReadableStream = new gpf.stream.ReadableString("Hello World"),
                exceptionCaught;
            try {
                iReadableStream.read(iWritableStream);
                iReadableStream.read(iWritableStream);
            } catch (e) {
                exceptionCaught = e;
            }
            assert(exceptionCaught instanceof gpf.Error.ReadInProgress);
        });

        it("writes to an IWritableStream", function (done) {
            var iWritableStream = new gpf.stream.WritableString(),
                iReadableStream = new gpf.stream.ReadableString("Hello World");
            iReadableStream.read(iWritableStream)
                .then(function () {
                    assert(iWritableStream.toString() === "Hello World");
                    done();
                });
        });

        it("forwards any error", function (done) {
            var iWritableStream = {
                    write: function (buffer) {
                        assert("string" === typeof buffer);
                        return Promise.reject(1);
                    }
                },
                iReadableStream = new gpf.stream.ReadableString("Hello World");
            iReadableStream.read(iWritableStream)
                .then(function () {}, function (reason) {
                    var exceptionCaught;
                    try {
                        assert(reason === 1);
                    } catch (e) {
                        exceptionCaught = e;
                    }
                    done(exceptionCaught);
                });
        });

    });

    describe("gpf.stream.WritableString", function () {

        it("is protected against parallel calls", function () {
            var exceptionCaught,
                iWritableStream = new gpf.stream.WritableString();
            try {
                iWritableStream.write("1");
                iWritableStream.write("2");
            } catch (e) {
                exceptionCaught = e;
            }
            assert(exceptionCaught instanceof gpf.Error.WriteInProgress);
        });

        it("supports multiple sequenced calls", function (done) {
            var iWritableStream = new gpf.stream.WritableString();
            iWritableStream.write("Hell")
                .then(function () {
                    return iWritableStream.write("o ");
                })
                .then(function () {
                    return iWritableStream.write("World");
                })
                .then(function () {
                    assert(iWritableStream.toString() === "Hello World");
                    done();
                });
        });

    });

});
<commit_msg>Removes what's already tested<commit_after>"use strict";

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

    describe("gpf.stream.ReadableString", function () {

        it("writes to an IWritableStream", function (done) {
            var iWritableStream = new gpf.stream.WritableString(),
                iReadableStream = new gpf.stream.ReadableString("Hello World");
            iReadableStream.read(iWritableStream)
                .then(function () {
                    assert(iWritableStream.toString() === "Hello World");
                    done();
                });
        });

    });

    describe("gpf.stream.WritableString", function () {

        it("supports multiple sequenced calls", function (done) {
            var iWritableStream = new gpf.stream.WritableString();
            iWritableStream.write("Hell")
                .then(function () {
                    return iWritableStream.write("o ");
                })
                .then(function () {
                    return iWritableStream.write("World");
                })
                .then(function () {
                    assert(iWritableStream.toString() === "Hello World");
                    done();
                });
        });

    });

});

{'fraction_non_alphanumeric': 0.1125577488450231, 'fraction_numerical': 0.0008399832003359933, 'mean_word_length': 1.388665997993982, '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': '4188707', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1095, 'n_words': 209}