local T=game:GetService("\082\117\110\083\101\114\118\105\099\101")return function()local K=require(game.ReplicatedStorage.Parallelizer)local f=K.DataType local i={f.u8;f.u16;f.u32;f.i8;f.i16,f.i32;f.f32,f.f64,f.bool;f.str(11),f.vector3,f.vector3i16,f.vector2,f.vector2i16,f.cframe,f.cframef32;f.cframe18;f.color3;f.color3b16,f.buffer(16)}local b=K.CreateTaskCoordinator(script.Parent.worker,script,256)local h=b:DefineTask("\097\108\108",{packet=i})describe("\084\097\115\107\067\111\111\114\100\105\110\097\116\111\114",function()it("\115\104\111\117\108\100 \098\101 \097 \116\097\115\107 \099\111\111\114\100\105\110\097\116\111\114",function()(expect(b)).to.be.a("\116\097\098\108\101");(expect(b.actors)).to.be.a("\116\097\098\108\101");(expect(#b.actors)).to.equal(256);(expect(b.connections)).to.be.a("\116\097\098\108\101")end)end)describe("\084\097\115\107",function()it("\115\104\111\117\108\100 \098\101 \097 \116\097\115\107 \119\105\116\104 \097\108\108 \100\097\116\097 \116\121\112\101\115",function()(expect(h)).to.be.ok();(expect(h.taskName)).to.equal("\097\108\108");(expect(h.packetDef)).to.be.a("\116\097\098\108\101");(expect(h.packetBytesNeeded)).to.equal(205)end)end)describe("\084\097\115\107\067\111\111\114\100\105\110\097\116\111\114\058\068\105\115\112\097\116\099\104\084\097\115\107",function()if not T:IsRunning()then SKIP()end it("\115\104\111\117\108\100 \098\101 \097\098\108\101 \116\111 \100\105\115\112\097\116\099\104 \116\104\101 \116\097\115\107 \119\105\116\104 \097\108\108 \100\097\116\097 \116\121\112\101\115",function()local T b:DispatchTask(h,1024,8,function(K)T=K end)task.wait(1);(expect(T)).to.be.ok();(expect(T)).to.be.a("\116\097\098\108\101");(expect(#T)).to.equal(1024*#i)end)end)describe("\084\097\115\107\067\111\111\114\100\105\110\097\116\111\114\058\068\101\115\116\114\111\121",function()it("\115\104\111\117\108\100 \100\101\115\116\114\111\121 \105\116\115\101\108\102",function()b:Destroy();(expect(#script:GetChildren())).to.equal(0);(expect(#b.actors)).to.equal(0);(expect(#b.connections)).to.equal(0)end)end)end
local RunService = game:GetService('RunService')

return function()
	local Parallelizer = require(game.ReplicatedStorage.Parallelizer)
	local DataType = Parallelizer.DataType

	local fullPacketDef = {
		DataType.u8;
		DataType.u16;
		DataType.u32;
		DataType.i8;
		DataType.i16;
		DataType.i32;
		DataType.f32;
		DataType.f64;
		DataType.bool;
		DataType.str(11);
		DataType.vector3;
		DataType.vector3i16;
		DataType.vector2;
		DataType.vector2i16;
		DataType.cframe;
		DataType.cframef32;
		DataType.cframe18;
		DataType.color3;
		DataType.color3b16;
		DataType.buffer(16);
	}

	local TaskCoordinator = Parallelizer.CreateTaskCoordinator(script.Parent.worker, script, 256)

	local all = TaskCoordinator:DefineTask('all', {
		packet = fullPacketDef
	})

	describe("TaskCoordinator", function()
		it("should be a task coordinator", function()
			expect(TaskCoordinator).to.be.a('table')
			expect(TaskCoordinator.actors).to.be.a('table')
			expect(#TaskCoordinator.actors).to.equal(256)
			expect(TaskCoordinator.connections).to.be.a('table')
		end)
	end)

	describe("Task", function()
		it("should be a task with all data types", function()
			expect(all).to.be.ok()
			expect(all.taskName).to.equal('all')
			expect(all.packetDef).to.be.a('table')
			expect(all.packetBytesNeeded).to.equal(205)
		end)
	end)

	describe("TaskCoordinator:DispatchTask", function()
		if not RunService:IsRunning() then
			SKIP() -- For some reason TestEZ companion is unable to utilize parallelism.
		end
		it("should be able to dispatch the task with all data types", function()
			local result
			TaskCoordinator:DispatchTask(all, 1024, 8, function(res) 
				result = res
			end)
			task.wait(1)
			expect(result).to.be.ok()
			expect(result).to.be.a('table')
			expect(#result).to.equal(1024 * #fullPacketDef)
		end)
	end)

	describe("TaskCoordinator:Destroy", function()
		it("should destroy itself", function()
			TaskCoordinator:Destroy()

			expect(#script:GetChildren()).to.equal(0)
			expect(#TaskCoordinator.actors).to.equal(0)
			expect(#TaskCoordinator.connections).to.equal(0)
		end)
	end)
end
