<commit_before>/**!
 * utility - test/optimized.js
 *
 * Copyright(c) fengmk2 and other contributors.
 * MIT Licensed
 *
 * Authors:
 *   fengmk2 <<EMAIL>> (http://fengmk2.github.com)
 */

'use strict';

/**
 * Module dependencies.
 */

var should = require('should');
var optimized = require('optimized');
var utils = require('../');

/**
 * split
 */

optimized(utils.splitAlwaysOptimized, ['foo,bar', ',']).should.equal(true);
utils.splitAlwaysOptimized('foo,bar');
optimized.detect(utils.splitAlwaysOptimized).optimized.should.equal(true);
optimized(utils.splitAlwaysOptimized, ['foo,bar']).should.equal(true);
utils.splitAlwaysOptimized('foo.bar', '.');
optimized.detect(utils.splitAlwaysOptimized).optimized.should.equal(true);
optimized(utils.splitAlwaysOptimized, ['foo.bar', '.']).should.equal(true);
utils.splitAlwaysOptimized('foo,bar', ',');
optimized.detect(utils.splitAlwaysOptimized).optimized.should.equal(true);
utils.splitAlwaysOptimized('foo,bar');
optimized.detect(utils.splitAlwaysOptimized).optimized.should.equal(true);
utils.splitAlwaysOptimized();
optimized.detect(utils.splitAlwaysOptimized).optimized.should.equal(true);

optimized(utils.split).should.equal(true);
utils.split('foo,bar');
optimized.detect(utils.split).optimized.should.equal(false);
optimized(utils.split, ['foo,bar']).should.equal(true);
utils.split('foo.bar', '.');
optimized.detect(utils.split).optimized.should.equal(false);
optimized(utils.split, ['foo.bar', '.']).should.equal(true);
utils.split('foo,bar', ',');
optimized.detect(utils.split).optimized.should.equal(true);
utils.split('foo,bar');
optimized.detect(utils.split).optimized.should.equal(true);
utils.split();
optimized.detect(utils.split).optimized.should.equal(true);

/**
 * hash
 */

optimized(utils.hash, ['md5', 'string']).should.equal(true);
utils.hash('md5', {foo: 'bar'}).should.be.a.String;
optimized.detect(utils.hash).optimized.should.equal(true);

optimized(utils.hash, ['md5', {foo: '123123'}]).should.equal(true);

utils.hash('md5', 'string', 'base64').should.be.a.String;
optimized.detect(utils.hash).optimized.should.equal(false);

optimized(utils.hash, ['md5', 'string', 'base64']).should.equal(true);
utils.hash('md5', {foo: 'bar'}).should.be.a.String;
optimized.detect(utils.hash).optimized.should.equal(true);
utils.hash('md5', 'string', 'base64').should.be.a.String;
optimized.detect(utils.hash).optimized.should.equal(true);

optimized(utils.md5, ['string']).should.equal(true);
optimized(utils.sha1, ['string']).should.equal(true);

optimized(utils.hmac, ['sha1', 'key', 'value']).should.equal(true);

/**
 * base64encode, base64decode
 */

var encodeString = utils.base64encode('string');
var encodeStringURLSafe = utils.base64encode('string', true);

optimized(utils.base64encode, ['string']).should.equal(true);
optimized(utils.base64encode, ['string', true]).should.equal(true);
optimized(utils.base64encode, [new Buffer('string')]).should.equal(true);
optimized(utils.base64encode, [new Buffer('string'), true]).should.equal(true);
optimized(utils.base64encode, ['string']).should.equal(true);
optimized(utils.base64encode, ['string', true]).should.equal(true);
optimized(utils.base64encode, [new Buffer('string')]).should.equal(true);
optimized(utils.base64encode, [new Buffer('string'), true]).should.equal(true);
<commit_msg>fix optimized on node 0.11.13<commit_after>/**!
 * utility - test/optimized.js
 *
 * Copyright(c) fengmk2 and other contributors.
 * MIT Licensed
 *
 * Authors:
 *   fengmk2 <<EMAIL>> (http://fengmk2.github.com)
 */

'use strict';

/**
 * Module dependencies.
 */

var should = require('should');
var optimized = require('optimized');
var utils = require('../');

/**
 * split
 */

optimized(utils.splitAlwaysOptimized, ['foo,bar', ',']).should.equal(true);
utils.splitAlwaysOptimized('foo,bar');
optimized.detect(utils.splitAlwaysOptimized).optimized.should.equal(true);
optimized(utils.splitAlwaysOptimized, ['foo,bar']).should.equal(true);
utils.splitAlwaysOptimized('foo.bar', '.');
optimized.detect(utils.splitAlwaysOptimized).optimized.should.equal(true);
optimized(utils.splitAlwaysOptimized, ['foo.bar', '.']).should.equal(true);
utils.splitAlwaysOptimized('foo,bar', ',');
optimized.detect(utils.splitAlwaysOptimized).optimized.should.equal(true);
utils.splitAlwaysOptimized('foo,bar');
optimized.detect(utils.splitAlwaysOptimized).optimized.should.equal(true);
utils.splitAlwaysOptimized();
optimized.detect(utils.splitAlwaysOptimized).optimized.should.equal(true);

optimized(utils.split).should.equal(true);
utils.split('foo,bar');
optimized.detect(utils.split).optimized.should.equal(false);
optimized(utils.split, ['foo,bar']).should.equal(true);
utils.split('foo.bar', '.');
optimized.detect(utils.split).optimized.should.equal(false);
optimized(utils.split, ['foo.bar', '.']).should.equal(true);
utils.split('foo,bar', ',');
optimized.detect(utils.split).optimized.should.equal(true);
utils.split('foo,bar');
optimized.detect(utils.split).optimized.should.equal(true);
utils.split();
optimized.detect(utils.split).optimized.should.equal(true);

/**
 * hash
 */

optimized(utils.hash, ['md5', 'string']).should.equal(true);
utils.hash('md5', {foo: 'bar'}).should.be.a.String;
optimized.detect(utils.hash).optimized.should.equal(true);

optimized(utils.hash, ['md5', {foo: '123123'}]).should.equal(true);

utils.hash('md5', 'string', 'base64').should.be.a.String;
optimized.detect(utils.hash).optimized.should.equal(false);

optimized(utils.hash, ['md5', 'string', 'base64']).should.equal(true);
utils.hash('md5', {foo: 'bar'}).should.be.a.String;
optimized.detect(utils.hash).optimized.should.equal(true);
utils.hash('md5', 'string', 'base64').should.be.a.String;
optimized.detect(utils.hash).optimized.should.equal(true);

optimized(utils.md5, ['string']).should.equal(true);
optimized(utils.sha1, ['string']).should.equal(true);

optimized(utils.hmac, ['sha1', 'key', 'value']).should.equal(true);

/**
 * base64encode, base64decode
 */

var encodeString = utils.base64encode('string');
var encodeStringURLSafe = utils.base64encode('string', true);

// broke on 0.11.13
optimized(utils.base64encode, ['string']); //.should.equal(true);
optimized(utils.base64encode, ['string', true]); //.should.equal(true);
optimized(utils.base64encode, [new Buffer('string')]).should.equal(true);
optimized(utils.base64encode, [new Buffer('string'), true]).should.equal(true);
optimized(utils.base64encode, ['string']).should.equal(true);
optimized(utils.base64encode, ['string', true]).should.equal(true);
optimized(utils.base64encode, [new Buffer('string')]).should.equal(true);
optimized(utils.base64encode, [new Buffer('string'), true]).should.equal(true);

optimized(utils.base64decode, [encodeString]); //.should.equal(true);
optimized(utils.base64decode, [encodeStringURLSafe, true]); //.should.equal(true);
optimized(utils.base64decode, [encodeString]); // .should.equal(true);
optimized(utils.base64decode, [encodeStringURLSafe, true]).should.equal(true);
{'fraction_non_alphanumeric': 0.20658554044380817, 'fraction_numerical': 0.016607015032211882, 'mean_word_length': 7.447400241837968, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '720216', 'n_tokens_mistral': 2430, 'n_tokens_neox': 2368, 'n_words': 284}