<commit_before>mocha.setup({
    ui: "bdd",
    globals: ["console","__fxdriver_unwrapped"],
    timeout: 300000
});
var assert = chai.assert;

function aSquare(x,cb) {
	cb( x * x );
}
function square(a){
	switch(typeof a){
		case "string": 
			throw a;
		case "number":
			return a*a;
	}
}
function sum(a, b) {
	return a + b;
}

function product(a){
	return a[0]*a[1];
}

var buf;
if(typeof Uint8Array !== 'undefined'){
	buf=(new Uint8Array([1,2,3,4,5,6,7,8])).buffer;
}
var single = function(func, data){
	var worker = cw(func);
	return worker.data(data).then(function(a){
		worker.close();
		return a;
	});
};
//cw.URL=true;
describe('cw()', function () {
	describe('Basic', function () {
		it('should work when given a function and data directly', function (done) {
			single(square, 9).then(function (a) { assert.equal(a,81); }).then(done, done);
		});
		it('should work when given a function and data async', function (done) {
			single(aSquare, 9).then(function (a) { assert.equal(a,81); }).then(done, done);
		});
		if(typeof Uint8Array !== 'undefined'&&cw._hasWorker){
			it('should be able to handle an array buffer', function(done){
				function wrapUp(){
					comrade.close();
					done();
				}
				var comrade = cw(function(data,cb){cb(data)});
				comrade.data((new Uint8Array([1,2,3,4,5,6,7,8])).buffer).then(function(a){assert.equal(a.byteLength,8)}).then(wrapUp,wrapUp);<commit_msg>fixted test<commit_after>mocha.setup({
    ui: "bdd",
    globals: ["console","__fxdriver_unwrapped"],
    timeout: 300000
});
var assert = chai.assert;

function aSquare(x,cb) {
	cb( x * x );
}
function square(a){
	switch(typeof a){
		case "string": 
			throw a;
		case "number":
			return a*a;
	}
}
function sum(a, b) {
	return a + b;
}

function product(a){
	return a[0]*a[1];
}

var buf;
if(typeof Uint8Array !== 'undefined'){
	buf=(new Uint8Array([1,2,3,4,5,6,7,8])).buffer;
}
var single = function(func, data){
	var worker = cw(func);
	return worker.data(data).then(function(a){
		worker.close();
		return a;
	});
};
//cw.URL=true;
describe('cw()', function () {
	describe('Basic', function () {
		it('should work when given a function and data directly' , function (done) {
			single(square, 9).then(function (a) { assert.equal(a,81); }).then(done, done);
		});
		it('should work when given a function and data async', function (done) {
			single(aSquare, 9).then(function (a) { assert.equal(a,81); }).then(done, done);
		});
		if(typeof Uint8Array !== 'undefined'&&cw._hasWorker&&typeof window.URL!== 'undefined'){
			it('should be able to handle an array buffer', function(done){
				function wrapUp(){
					comrade.close();
					done();
				}
				var comrade = cw(function(data,cb){cb(data)});
				comrade.data((new Uint8Array([1,2,3,4,5,6,7,8])).buffer).then(function(a){assert.equal(a.byteLength,8)}).then(wrapUp,wrapUp);
{'fraction_non_alphanumeric': 0.19837627956230144, 'fraction_numerical': 0.024708789269325803, 'mean_word_length': 4.5136186770428015, 'pattern_counts': {'":': 4, '<': 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': '2072776', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1068, 'n_words': 234}