<commit_before>import test from 'tape';

import rfx from '../../source/index';

test('rfx', nest => {
  nest.test('...predicate rtype, dev env, onError & invalid args', assert => {
    assert.plan(4);

    process.env.NODE_ENV = 'development';

    rfx({
      type (input) {
        assert.pass('should type check');

        return typeof input === 'boolean';
      },
      fn () {
        assert.pass('should call fn');
      },
      onError ({ args, options }) {
        assert.test(' - onError signature', a => {
          const actual = {
            hasArgs: args.length === 3,
            hasOptions: options
          };
          const expected = {
            hasArgs: true,
            hasOptions: options
          };

          a.deepEqual(actual, expected,
            'should pass args to onError');
          a.end();
        });

        assert.pass('should call onError');
      }
    })('foo', 'bar', 'baz');
  });

  nest.test('...predicate rtype, prod env, onError & invalid args', assert => {
    assert.plan(1);

    process.env.NODE_ENV = 'production';

    rfx({
      type (input) {
        assert.fail('should not type check');

        return typeof input === 'boolean';
      },
      fn () {
        assert.pass('should call fn');
      },
      onError () {
        assert.fail('should not call onError');
      }
    })('foo', 'bar', 'baz');
  });

  nest.test('...predicate rtype, dev env, & no args', assert => {
    process.env.NODE_ENV = 'development';

    rfx({
      type () {
        assert.pass('should call typecheck function');
        assert.end();
      },
      fn () {}
    })();
  });

  nest.test('...with fn return', assert => {
    const fx = rfx({
      fn () {
        return 'a';
      }
    });

    const actual = fx();
    const expected = 'a';

    assert.equal(actual, expected,
      'should pass return value from function');

    assert.end();
  });
});<commit_msg>Specify “rfx with meta data”<commit_after>import test from 'tape';

import rfx from '../../source/index';

test('rfx', nest => {
  nest.test('...predicate rtype, dev env, onError & invalid args', assert => {
    assert.plan(4);

    process.env.NODE_ENV = 'development';

    rfx({
      type (input) {
        assert.pass('should type check');

        return typeof input === 'boolean';
      },
      fn () {
        assert.pass('should call fn');
      },
      onError ({ args, options }) {
        assert.test(' - onError signature', a => {
          const actual = {
            hasArgs: args.length === 3,
            hasOptions: options
          };
          const expected = {
            hasArgs: true,
            hasOptions: options
          };

          a.deepEqual(actual, expected,
            'should pass args to onError');
          a.end();
        });

        assert.pass('should call onError');
      }
    })('foo', 'bar', 'baz');
  });

  nest.test('...predicate rtype, prod env, onError & invalid args', assert => {
    assert.plan(1);

    process.env.NODE_ENV = 'production';

    rfx({
      type (input) {
        assert.fail('should not type check');

        return typeof input === 'boolean';
      },
      fn () {
        assert.pass('should call fn');
      },
      onError () {
        assert.fail('should not call onError');
      }
    })('foo', 'bar', 'baz');
  });

  nest.test('...predicate rtype, dev env, & no args', assert => {
    process.env.NODE_ENV = 'development';

    rfx({
      type () {
        assert.pass('should call typecheck function');
        assert.end();
      },
      fn () {}
    })();
  });

  nest.test('...with fn return', assert => {
    const fx = rfx({
      fn () {
        return 'a';
      }
    });

    const actual = fx();
    const expected = 'a';

    assert.equal(actual, expected,
      'should pass return value from function');

    assert.end();
  });

  nest.test('...with meta data', assert => {
    const myNamespace = {};
    const fx = rfx({
      myNamespace,
      fn: () => null
    });

    const actual = fx.myNamespace;
    const expected = myNamespace;

    assert.equal(actual, expected,
      'should attach extra properties to the interface');

    assert.end();
  });
});
{'fraction_non_alphanumeric': 0.16710244830045162, 'fraction_numerical': 0.0014261944378416924, 'mean_word_length': 1.8451656524678837, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '889622', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1235, 'n_words': 322}