return function()local O=require(script.Parent.Signal)it("\115\104\111\117\108\100 \099\111\110\115\116\114\117\099\116 \102\114\111\109 \110\111\116\104\105\110\103",function()local Z=O.new();(expect(Z)).to.be.ok()end)it("\115\104\111\117\108\100 \102\105\114\101 \099\111\110\110\101\099\116\101\100 \099\097\108\108\098\097\099\107\115",function()local Z=0 local p="\072\101\108\108\111 \087\111\114\108\100"local j=7 local N=function(O,N)(expect(O)).to.equal(p);(expect(N)).to.equal(j)Z=Z+1 end local T=O.new()local c=T:connect(N)T:fire(p,j);(expect(Z)).to.equal(1)c:disconnect()T:fire(p,j);(expect(Z)).to.equal(1)end)it("\115\104\111\117\108\100 \100\105\115\099\111\110\110\101\099\116 \104\097\110\100\108\101\114\115",function()local Z=function()error("\067\097\108\108\098\097\099\107 \119\097\115 \099\097\108\108\101\100 \097\102\116\101\114 \100\105\115\099\111\110\110\101\099\116\033")end local p=O.new()local j=p:connect(Z)j:disconnect()p:fire()end)it("\115\104\111\117\108\100 \102\105\114\101 \104\097\110\100\108\101\114\115 \105\110 \111\114\100\101\114",function()local Z=O.new()local p=0 local j=0 local N=function()(expect(p)).to.equal(0);(expect(j)).to.equal(0)p=p+1 end local T=function()(expect(p)).to.equal(1);(expect(j)).to.equal(0)j=j+1 end Z:connect(N)Z:connect(T)Z:fire();(expect(p)).to.equal(1);(expect(j)).to.equal(1)end)it("\115\104\111\117\108\100 \099\111\110\116\105\110\117\101 \102\105\114\105\110\103 \100\101\115\112\105\116\101 \109\105\100-\101\118\101\110\116 \100\105\115\099\111\110\110\101\099\116\105\111\110",function()local Z=O.new()local p=0 local j=0 local N N=Z:connect(function()N:disconnect()p=p+1 end)Z:connect(function()j=j+1 end)Z:fire();(expect(p)).to.equal(1);(expect(j)).to.equal(1)end)it("\115\104\111\117\108\100 \115\107\105\112 \108\105\115\116\101\110\101\114\115 \116\104\097\116 \119\101\114\101 \100\105\115\099\111\110\110\101\099\116\101\100 \100\117\114\105\110\103 \101\118\101\110\116 \101\118\097\108\117\097\116\105\111\110",function()local Z=O.new()local p=0 local j=0 local N Z:connect(function()p=p+1 N:disconnect()end)N=Z:connect(function()j=j+1 end)Z:fire();(expect(p)).to.equal(1);(expect(j)).to.equal(0)end)end
return function()
	local Signal = require(script.Parent.Signal)

	it("should construct from nothing", function()
		local signal = Signal.new()

		expect(signal).to.be.ok()
	end)

	it("should fire connected callbacks", function()
		local callCount = 0
		local value1 = "Hello World"
		local value2 = 7

		local callback = function(arg1, arg2)
			expect(arg1).to.equal(value1)
			expect(arg2).to.equal(value2)
			callCount = callCount + 1
		end

		local signal = Signal.new()

		local connection = signal:connect(callback)
		signal:fire(value1, value2)

		expect(callCount).to.equal(1)

		connection:disconnect()
		signal:fire(value1, value2)

		expect(callCount).to.equal(1)
	end)

	it("should disconnect handlers", function()
		local callback = function()
			error("Callback was called after disconnect!")
		end

		local signal = Signal.new()

		local connection = signal:connect(callback)
		connection:disconnect()

		signal:fire()
	end)

	it("should fire handlers in order", function()
		local signal = Signal.new()
		local x = 0
		local y = 0

		local callback1 = function()
			expect(x).to.equal(0)
			expect(y).to.equal(0)
			x = x + 1
		end

		local callback2 = function()
			expect(x).to.equal(1)
			expect(y).to.equal(0)
			y = y + 1
		end

		signal:connect(callback1)
		signal:connect(callback2)
		signal:fire()

		expect(x).to.equal(1)
		expect(y).to.equal(1)
	end)

	it("should continue firing despite mid-event disconnection", function()
		local signal = Signal.new()
		local countA = 0
		local countB = 0

		local connectionA
		connectionA = signal:connect(function()
			connectionA:disconnect()
			countA = countA + 1
		end)

		signal:connect(function()
			countB = countB + 1
		end)

		signal:fire()

		expect(countA).to.equal(1)
		expect(countB).to.equal(1)
	end)

	it("should skip listeners that were disconnected during event evaluation", function()
		local signal = Signal.new()
		local countA = 0
		local countB = 0

		local connectionB

		signal:connect(function()
			countA = countA + 1
			connectionB:disconnect()
		end)

		connectionB = signal:connect(function()
			countB = countB + 1
		end)

		signal:fire()

		expect(countA).to.equal(1)
		expect(countB).to.equal(0)
	end)
end