<commit_before>require('proof')(5, require('cadence')(prove))

function prove (async, okay) {
    var stream = require('stream')
    var Synchronous = require('../synchronous')
    var Chunk = require('prolific.chunk')
    var abend = require('abend')

    var chunk, previousChecksum, buffer

    var chunks = [ [], [] ]

    var scanned = []

    var through = new stream.PassThrough
    var forward = new stream.PassThrough
    var synchronous = new Synchronous({
        selectConsumer: function (chunk) {
            synchronous.setConsumer(chunk.id, {
                consume: function (chunk, callback) {
                    chunks[+chunk.id].push(chunk)
                    callback()
                }
            })
        },
        scanned: function (bytes) {
            scanned.push(bytes)
        }
    })

    synchronous.listen(through, forward, abend)

    through.write('hello, world\n')

    chunk = new Chunk(0, 0, Buffer.from(''), 1)
    write(through, chunk, 'aaaaaaaa')

    previousChecksum = chunk.checksum
    buffer = Buffer.from('a\n')
    chunk = new Chunk(0, 1, buffer, buffer.length)
    write(through, chunk, previousChecksum)

    chunk = new Chunk(1, 0, Buffer.from(''), 1)
    write(through, chunk, 'aaaaaaaa')

    previousChecksum = chunk.checksum
    buffer = Buffer.from('a\n')
    chunk = new Chunk(1, 1, buffer, buffer.length)
    var consumer
    async(function () {
        write(through, chunk, previousChecksum, async())
    }, function () {
        okay(forward.read().toString(), 'hello, world\n', 'through')

        consumer = {
            chunks: [],
            consume: function (chunk) {
                this.chunks.push(chunk)
            }
        }

        okay(chunks[1].shift().buffer.toString(), 'a\n', 'consumer join')

        previousChecksum = chunk.checksum
        buffer = Buffer.from('b\n')
        chunk = new Chunk(1, 2, buffer, buffer.length)
        write(through, chunk, previousChecksum, async())
    }, function () {
        okay(chunks[1].shift().buffer.toString(), 'b\n', 'consumer consume')
        through.end()
    }, function () {
        okay(scanned.reduce(function (sum, value) {
            return sum + value
        }), 149, 'scanned')
        synchronous.clearConsumer(0)
        synchronous.clearConsumer(1)
        okay(Object.keys(synchronous._consumers), [], 'deleted consumers')
    })

    function write (writable, chunk, previousChecksum, callback) {
        writable.write(chunk.header(previousChecksum))
        writable.write(chunk.buffer, callback)
    }
}<commit_msg>Remove dead code from unit test.<commit_after>require('proof')(5, require('cadence')(prove))

function prove (async, okay) {
    var stream = require('stream')
    var Synchronous = require('../synchronous')
    var Chunk = require('prolific.chunk')
    var abend = require('abend')

    var chunk, previousChecksum, buffer

    var chunks = [ [], [] ]

    var scanned = []

    var through = new stream.PassThrough
    var forward = new stream.PassThrough
    var synchronous = new Synchronous({
        selectConsumer: function (chunk) {
            synchronous.setConsumer(chunk.id, {
                consume: function (chunk, callback) {
                    chunks[+chunk.id].push(chunk)
                    callback()
                }
            })
        },
        scanned: function (bytes) {
            scanned.push(bytes)
        }
    })

    synchronous.listen(through, forward, abend)

    through.write('hello, world\n')

    chunk = new Chunk(0, 0, Buffer.from(''), 1)
    write(through, chunk, 'aaaaaaaa')

    previousChecksum = chunk.checksum
    buffer = Buffer.from('a\n')
    chunk = new Chunk(0, 1, buffer, buffer.length)
    write(through, chunk, previousChecksum)

    chunk = new Chunk(1, 0, Buffer.from(''), 1)
    write(through, chunk, 'aaaaaaaa')

    previousChecksum = chunk.checksum
    buffer = Buffer.from('a\n')
    chunk = new Chunk(1, 1, buffer, buffer.length)
    var consumer
    async(function () {
        write(through, chunk, previousChecksum, async())
    }, function () {
        okay(forward.read().toString(), 'hello, world\n', 'through')

        okay(chunks[1].shift().buffer.toString(), 'a\n', 'consumer join')

        previousChecksum = chunk.checksum
        buffer = Buffer.from('b\n')
        chunk = new Chunk(1, 2, buffer, buffer.length)
        write(through, chunk, previousChecksum, async())
    }, function () {
        okay(chunks[1].shift().buffer.toString(), 'b\n', 'consumer consume')
        through.end()
    }, function () {
        okay(scanned.reduce(function (sum, value) {
            return sum + value
        }), 149, 'scanned')
        synchronous.clearConsumer(0)
        synchronous.clearConsumer(1)
        okay(Object.keys(synchronous._consumers), [], 'deleted consumers')
    })

    function write (writable, chunk, previousChecksum, callback) {
        writable.write(chunk.header(previousChecksum))
        writable.write(chunk.buffer, callback)
    }
}
{'fraction_non_alphanumeric': 0.13989223707842746, 'fraction_numerical': 0.007982438635002993, 'mean_word_length': 2.4517906336088156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '2636720', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1472, 'n_words': 325}