<commit_before>var config = require(__dirname+'/../config.js');
var r = require('rethinkdb');
var assert = require('assert');
var nothing = require(__dirname+'/../lib/index.js');


var connection;

describe('control.js', function(){
    before(function(done) {
        setTimeout(function() { // Delay for nodemon to restart the server
            r.connect(config, function(err, conn) {
                connection = conn;

                r.dbCreate("reqlitetest").run(connection, function(err, result) {
                    // Ignore the error
                    r.db("reqlitetest").tableCreate("control").run(connection, function(err, result) {
                        done();
                    });
                });
            });
        }, 100)
    });

    it('r.error', function(done) {
        r.error("foo").run(connection).then(function(result) {
            done(new Error("Was expecting an error"));
        }).error(function(err) {
            assert(err.message.match(/^foo/));
            done();
        });
    });
    it('r.error - wront type', function(done) {
        r.error(1).run(connection).then(function(result) {
            done(new Error("Was expecting an error"));
        }).error(function(err) {
            assert(err.message.match(/^Expected type STRING but found NUMBER/));
            done();
        });
    });

    it('default', function(done) {
        r.expr({a: 1})('b').default("bar").run(connection).then(function(result) {
            assert.equal(result, "bar");
            done();<commit_msg>Fix the default value test<commit_after>var config = require(__dirname+'/../config.js');
var r = require('rethinkdb');
var assert = require('assert');
var nothing = require(__dirname+'/../lib/index.js');


var connection;

describe('control.js', function(){
    before(function(done) {
        setTimeout(function() { // Delay for nodemon to restart the server
            r.connect(config, function(err, conn) {
                connection = conn;

                r.dbCreate("reqlitetest").run(connection, function(err, result) {
                    // Ignore the error
                    r.db("reqlitetest").tableCreate("control").run(connection, function(err, result) {
                        done();
                    });
                });
            });
        }, 100)
    });

    it('r.error', function(done) {
        r.error("foo").run(connection).then(function(result) {
            done(new Error("Was expecting an error"));
        }).error(function(err) {
            assert(err.message.match(/^foo/));
            done();
        });
    });
    it('r.error - wront type', function(done) {
        r.error(1).run(connection).then(function(result) {
            done(new Error("Was expecting an error"));
        }).error(function(err) {
            assert(err.message.match(/^Expected type STRING but found NUMBER/));
            done();
        });
    });

    it('default', function(done) {
        r.expr({a: 1}).getField('b').default("bar").run(connection).then(function(result) {
            assert.equal(result, "bar");
            done();
{'fraction_non_alphanumeric': 0.16987797045600514, 'fraction_numerical': 0.0032113037893384713, 'mean_word_length': 2.0360623781676415, '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': '3048137', 'n_tokens_mistral': 873, 'n_tokens_neox': 840, 'n_words': 157}