<commit_before>"use strict";

var test = require("tape");

var ObjectPool = require("./object-pool");

test("objects get reused after being returned to pool", function(t) {
	t.plan(1);

	var pool = new ObjectPool(function() {
		return {};
	});

	var a = pool.alloc();
	var b = pool.alloc();
	pool.free(a);
	var c = pool.alloc();

	t.equal(a, c);
});

test("allocated objects match result of factory function", function(t) {
	t.plan(5);

	function factory() {
		return {
			a: 1,
			b: {
				c: "hello world"
			},
			d: [3, 2, 1]
		};
	}

	var pool = new ObjectPool(factory);

	var allocated = pool.alloc();
	var factoryResult = factory();

	t.equal(allocated.a, factoryResult.a);
	t.equal(allocated.b.c, factoryResult.b.c);
	for (var i = 0; i < 3; i++) {
		t.equal(allocated.d[i], factoryResult.d[i]);
	}
});

test("ObjectPool constructor creates number of objects specified", function(t) {
	t.plan(4);

	var size = 3;

	var pool = new ObjectPool(function() {
		return {};
	}, size);<commit_msg>Using tape deepEqual instead of something more complicated.<commit_after>"use strict";

var test = require("tape");

var ObjectPool = require("./object-pool");

test("objects get reused after being returned to pool", function(t) {
	t.plan(1);

	var pool = new ObjectPool(function() {
		return {};
	});

	var a = pool.alloc();
	var b = pool.alloc();
	pool.free(a);
	var c = pool.alloc();

	t.equal(a, c);
});

test("allocated objects match result of factory function", function(t) {
	t.plan(1);

	function factory() {
		return {
			a: 1,
			b: {
				c: "hello world"
			},
			d: [3, 2, 1]
		};
	}

	var pool = new ObjectPool(factory);

	var allocated = pool.alloc();
	var factoryResult = factory();

	t.deepEqual(allocated, factoryResult);
});

test("ObjectPool constructor creates number of objects specified", function(t) {
	t.plan(4);

	var size = 3;

	var pool = new ObjectPool(function() {
		return {};
	}, size);
{'fraction_non_alphanumeric': 0.17198118139048615, 'fraction_numerical': 0.009409304756926294, 'mean_word_length': 3.7027027027027026, 'pattern_counts': {'":': 0, '<': 4, '<?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': '7022686', 'n_tokens_mistral': 728, 'n_tokens_neox': 668, 'n_words': 191}