local q=import("\046\047\085\068\105\109")local function Z(q)return{q.Scale,q.Offset}end describe("\116\121\112\101\115\046\085\068\105\109",function()it("\115\104\111\117\108\100 \104\097\118\101 \097\110 \101\109\112\116\121 \099\111\110\115\116\114\117\099\116\111\114",function()local S=q.new()assert.not_nil(S)assert.are.same({0,0},Z(S))end)it("\115\104\111\117\108\100 \104\097\118\101 \097 \099\111\110\115\116\114\117\099\116\111\114 \119\105\116\104 \116\119\111 \112\097\114\097\109\101\116\101\114\115",function()local S=q.new(1,200)assert.not_nil(S)assert.are.same({1;200},Z(S))end)it("\115\104\111\117\108\100 \116\104\114\111\119 \119\104\101\110 \098\097\100 \112\097\114\097\109\115 \097\114\101 \112\097\115\115\101\100 \116\111 \116\104\101 \099\111\110\115\116\114\117\099\116\111\114",function()assert.has.errors(function()q.new(1,"\116\101\115\116")end)assert.has.errors(function()q.new("\116\101\115\116",10)end)end)it("\115\104\111\117\108\100 \097\100\100 \097\110\111\116\104\101\114 \085\068\105\109",function()local S=q.new(1,200)local B=q.new(100,500)local C=S+B assert.not_nil(C)assert.are.same({101,700},Z(C))end)it("\115\104\111\117\108\100 \101\113\117\097\108 \097\110\111\116\104\101\114 \085\068\105\109 \119\105\116\104 \116\104\101 \115\097\109\101 \115\099\097\108\101 \097\110\100 \111\102\102\115\101\116",function()local Z=q.new(1,200)local S=q.new(1,200)assert.equals(Z,S)end)it("\115\104\111\117\108\100 \110\111\116 \101\113\117\097\108 \097\110\111\116\104\101\114 \085\068\105\109 \119\105\116\104 \100\105\102\102\101\114\101\110\116 \115\099\097\108\101 \097\110\100 \111\102\102\115\101\116",function()local Z=q.new(1,200)local S=q.new(1,201)local B=q.new(50,200)local C=q.new(3,7)assert.not_equals(Z,S)assert.not_equals(Z,B)assert.not_equals(Z,C)end)end)
local UDim = import("./UDim")

local function extractValues(udim)
	return { udim.Scale, udim.Offset }
end

describe("types.UDim", function()
	it("should have an empty constructor", function()
		local udim = UDim.new()

		assert.not_nil(udim)
		assert.are.same({0, 0}, extractValues(udim))
	end)

	it("should have a constructor with two parameters", function()
		local udim = UDim.new(1, 200)

		assert.not_nil(udim)
		assert.are.same({1, 200}, extractValues(udim))
	end)

	it("should throw when bad params are passed to the constructor", function()
		assert.has.errors(function()
			UDim.new(1, "test")
		end)

		assert.has.errors(function()
			UDim.new("test", 10)
		end)
	end)

	it("should add another UDim", function()
		local udimA = UDim.new(1, 200)
		local udimB = UDim.new(100, 500)
		local udim = udimA + udimB

		assert.not_nil(udim)
		assert.are.same({101, 700}, extractValues(udim))
	end)

	it("should equal another UDim with the same scale and offset", function()
		local udimA = UDim.new(1, 200)
		local udimB = UDim.new(1, 200)

		assert.equals(udimA, udimB)
	end)

	it("should not equal another UDim with different scale and offset", function()
		local udimA = UDim.new(1, 200)

		local udimB1 = UDim.new(1, 201)
		local udimB2 = UDim.new(50, 200)
		local udimB3 = UDim.new(3, 7)

		assert.not_equals(udimA, udimB1)
		assert.not_equals(udimA, udimB2)
		assert.not_equals(udimA, udimB3)
	end)
end)
