<commit_before>/*
 *  test_queue.js
 *
 *  <NAME>
 *  IOTDB
 *  2016-01-17
 */

"use strict";

var assert = require("assert")
var _ = require("../helpers")

var iotdb = require("../iotdb");

describe('test_queue', function() {
    describe('constructor', function() {
        it('no arguments', function() {
            var queue = new iotdb.Queue();

            assert.strictEqual(queue.name, "unnamed-queue");
            assert.strictEqual(queue.qn, 1);
        });
        it('with name', function() {
            var queue = new iotdb.Queue("my-queue");

            assert.strictEqual(queue.name, "my-queue");
            assert.strictEqual(queue.qn, 1);
        });
        it('with name and paramd', function() {
            var queue = new iotdb.Queue("my-queue", {
                qn: 4,
            });

            assert.strictEqual(queue.name, "my-queue");
            assert.strictEqual(queue.qn, 4);
        });
    });
    describe('add', function() {
        it('simple', function(done) {
            var queue = new iotdb.Queue();
            queue.add({
                run: function(_queue, _qitem) {
                    _queue.finished(_qitem);
                    done();
                },
            });
        });
        it('simple with coda', function(done) {
            var queue = new iotdb.Queue();
            queue.add({
                run: function(_queue, _qitem) {
                    _queue.finished(_qitem);
                },
                coda: function() {
                    done();
                },
            });
        });
        it('multiples', function(done) {
            var queue = new iotdb.Queue();
            var ran_first = false;
            var ran_second = false;
            queue.add({
                run: function(_queue, _qitem) {
                    assert.ok(!ran_first);
                    assert.ok(!ran_second);

                    ran_first = true;
                    _queue.finished(_qitem);
                },
            });
            queue.add({<commit_msg>more tests<commit_after>/*
 *  test_queue.js
 *
 *  <NAME>
 *  IOTDB
 *  2016-01-17
 */

"use strict";

var assert = require("assert")
var _ = require("../helpers")

var iotdb = require("../iotdb");

describe('test_queue', function() {
    describe('constructor', function() {
        it('no arguments', function() {
            var queue = new iotdb.Queue();

            assert.strictEqual(queue.name, "unnamed-queue");
            assert.strictEqual(queue.qn, 1);
        });
        it('with name', function() {
            var queue = new iotdb.Queue("my-queue");

            assert.strictEqual(queue.name, "my-queue");
            assert.strictEqual(queue.qn, 1);
        });
        it('with name and paramd', function() {
            var queue = new iotdb.Queue("my-queue", {
                qn: 4,
            });

            assert.strictEqual(queue.name, "my-queue");
            assert.strictEqual(queue.qn, 4);
        });
    });
    describe('add', function() {
        it('simple', function(done) {
            var queue = new iotdb.Queue();
            queue.add({
                run: function(_queue, _qitem) {
                    _queue.finished(_qitem);
                    done();
                },
            });
        });
        it('simple with coda', function(done) {
            var queue = new iotdb.Queue();
            queue.add({
                run: function(_queue, _qitem) {
                    _queue.finished(_qitem);
                },
                coda: function() {
                    done();
                },
            });
        });
        it('simple with coda and exception', function(done) {
            var queue = new iotdb.Queue();
            queue.add({
                run: function(_queue, _qitem) {
                    throw new Error("coda should still get called");
                },
                coda: function() {
                    done();
                },
            });
        });
        it('multiples', function(done) {
            var queue = new iotdb.Queue();
            var ran_first = false;
            var ran_second = false;
            queue.add({
                run: function(_queue, _qitem) {
                    assert.ok(!ran_first);
                    assert.ok(!ran_second);

                    ran_first = true;
                    _queue.finished(_qitem);
                },
            });
            queue.add({
{'fraction_non_alphanumeric': 0.1396598030438675, 'fraction_numerical': 0.005371530886302597, 'mean_word_length': 1.2824310520939735, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '192121', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1185, 'n_words': 240}