local v=import("\046\047\086\101\099\116\111\114\051")local function V(v)return{v.X,v.Y;v.Z}end describe("\116\121\112\101\115\046\086\101\099\116\111\114\051",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=v.new()assert.not_nil(S)assert.are.same({0,0,0},V(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\104\114\101\101 \112\097\114\097\109\101\116\101\114\115",function()local S=v.new(1,2,3)assert.not_nil(S)assert.are.same({1,2,3},V(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()v.new(1,2,"\116\101\115\116")end)assert.has.errors(function()v.new(1,"\116\101\115\116",3)end)assert.has.errors(function()v.new("\116\101\115\116",2,3)end)end)it("\115\104\111\117\108\100 \097\100\100 \097\110\111\116\104\101\114 \086\101\099\116\111\114\051",function()local S=v.new(1,50,200)local t=v.new(100,300,500)local i=S+t assert.not_nil(i)assert.are.same({101,350,700},V(i))end)it("\115\104\111\117\108\100 \115\117\098\116\114\097\099\116 \097\110\111\116\104\101\114 \086\101\099\116\111\114\051",function()local S=v.new(1,50,200)local t=v.new(100,300,500)local i=S-t assert.not_nil(i)assert.are.same({-99,-250;-300},V(i))end)it("\115\104\111\117\108\100 \109\117\108\116\105\112\108\121 \098\121 \097\110\111\116\104\101\114 \086\101\099\116\111\114\051",function()local S=v.new(1,50,200)local t=v.new(2,.5,1)local i=S*t assert.not_nil(i)assert.are.same({2;25,200},V(i))end)it("\115\104\111\117\108\100 \109\117\108\116\105\112\108\121 \098\121 \097 \110\117\109\098\101\114",function()local S=v.new(1,50,200)local t=S*3 assert.not_nil(t)assert.are.same({3,150,600},V(t))end)it("\115\104\111\117\108\100 \109\117\108\116\105\112\108\121 \098\121 \097 \110\117\109\098\101\114 \114\101\118\101\114\115\101\100",function()local S=v.new(1,50,200)local t=3*S assert.not_nil(t)assert.are.same({3,150;600},V(t))end)it("\115\104\111\117\108\100 \116\104\114\111\119 \097\110 \101\114\114\111\114 \119\104\101\110 \109\117\108\116\105\112\108\105\101\100 \098\121 \097\110 \105\110\099\111\109\112\097\116\105\098\108\101 \116\121\112\101",function()assert.has.errors(function()return v.new(1,2,3)*nil end)end)it("\115\104\111\117\108\100 \100\105\118\105\100\101 \098\121 \097\110\111\116\104\101\114 \086\101\099\116\111\114\051",function()local S=v.new(1,50,200)local t=v.new(2,1,.5)local i=S/t assert.not_nil(i)assert.are.same({.5;50,400},V(i))end)it("\115\104\111\117\108\100 \100\105\118\105\100\101 \098\121 \097 \110\117\109\098\101\114",function()local S=v.new(1,50,200)local t=S/4 assert.not_nil(t)assert.are.same({.25,12.5;50},V(t))end)it("\115\104\111\117\108\100 \100\105\118\105\100\101 \098\121 \097 \110\117\109\098\101\114 \114\101\118\101\114\115\101\100",function()local S=v.new(1,50,200)local t=4/S assert.not_nil(t)assert.are.same({.25;12.5;50},V(t))end)it("\115\104\111\117\108\100 \116\104\114\111\119 \097\110 \101\114\114\111\114 \119\104\101\110 \100\105\118\105\100\101\100 \098\121 \097\110 \105\110\099\111\109\112\097\116\105\098\108\101 \116\121\112\101",function()assert.has.errors(function()return v.new(1,2,3)/"\097\098\099"end)end)it("\115\104\111\117\108\100 \101\113\117\097\108 \097\110\111\116\104\101\114 \086\101\099\116\111\114\051 \119\105\116\104 \116\104\101 \115\097\109\101 \120 \097\110\100 \121",function()local V=v.new(1,200,400)local S=v.new(1,200,400)assert.equals(V,S)end)it("\115\104\111\117\108\100 \110\111\116 \101\113\117\097\108 \097\110\111\116\104\101\114 \086\101\099\116\111\114\051 \119\105\116\104 \100\105\102\102\101\114\101\110\116 \120\044 \121 \111\114 \122 \118\097\108\117\101\115",function()local V=v.new(1,200,500)local S=v.new(1,200,3)local t=v.new(1,3,500)local i=v.new(100,200,500)assert.not_equals(V,S)assert.not_equals(V,t)assert.not_equals(V,i)end)it("\115\104\111\117\108\100 \116\104\114\111\119 \119\104\101\110 \097\099\099\101\115\115\105\110\103 \097\110 \105\110\118\097\108\105\100 \109\101\109\098\101\114",function()assert.has.errors(function()local V=v.new()V.frobulations=V.frobulations+1 end)end)it("\115\104\111\117\108\100 \104\097\118\101 \097 \115\116\114\105\110\103 \114\101\112\114\101\115\101\110\116\097\116\105\111\110 \111\102 \"\086\101\099\116\111\114\051\"",function()assert.equal(tostring(v),"\086\101\099\116\111\114\051")end)end)
local Vector3 = import("./Vector3")

local function extractValues(v)
	return { v.X, v.Y, v.Z }
end

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

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

	it("should have a constructor with three parameters", function()
		local v = Vector3.new(1, 2, 3)

		assert.not_nil(v)
		assert.are.same({1, 2, 3}, extractValues(v))
	end)

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

		assert.has.errors(function()
			Vector3.new(1, "test", 3)
		end)

		assert.has.errors(function()
			Vector3.new("test", 2, 3)
		end)
	end)

	it("should add another Vector3", function()
		local vectorA = Vector3.new(1, 50, 200)
		local vectorB = Vector3.new(100, 300, 500)
		local v = vectorA + vectorB

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

	it("should subtract another Vector3", function()
		local vectorA = Vector3.new(1, 50, 200)
		local vectorB = Vector3.new(100, 300, 500)
		local v = vectorA - vectorB

		assert.not_nil(v)
		assert.are.same({-99, -250, -300}, extractValues(v))
	end)

	it("should multiply by another Vector3", function()
		local vectorA = Vector3.new(1, 50, 200)
		local vectorB = Vector3.new(2, 0.5, 1)
		local v = vectorA * vectorB

		assert.not_nil(v)
		assert.are.same({2, 25, 200}, extractValues(v))
	end)

	it("should multiply by a number", function()
		local vectorA = Vector3.new(1, 50, 200)
		local v = vectorA * 3

		assert.not_nil(v)
		assert.are.same({3, 150, 600}, extractValues(v))
	end)

	it("should multiply by a number reversed", function()
		local vectorA = Vector3.new(1, 50, 200)
		local v = 3 * vectorA

		assert.not_nil(v)
		assert.are.same({3, 150, 600}, extractValues(v))
	end)

	it("should throw an error when multiplied by an incompatible type", function()
		assert.has.errors(function()
			return Vector3.new(1, 2, 3) * nil
		end)
	end)

	it("should divide by another Vector3", function()
		local vectorA = Vector3.new(1, 50, 200)
		local vectorB = Vector3.new(2, 1, 0.5)
		local v = vectorA / vectorB

		assert.not_nil(v)
		assert.are.same({0.5, 50, 400}, extractValues(v))
	end)

	it("should divide by a number", function()
		local vectorA = Vector3.new(1, 50, 200)
		local v = vectorA / 4

		assert.not_nil(v)
		assert.are.same({0.25, 12.5, 50}, extractValues(v))
	end)

	it("should divide by a number reversed", function()
		local vectorA = Vector3.new(1, 50, 200)
		local v = 4 / vectorA

		assert.not_nil(v)
		assert.are.same({0.25, 12.5, 50}, extractValues(v))
	end)

	it("should throw an error when divided by an incompatible type", function()
		assert.has.errors(function()
			return Vector3.new(1, 2, 3) / "abc"
		end)
	end)

	it("should equal another Vector3 with the same x and y", function()
		local vectorA = Vector3.new(1, 200, 400)
		local vectorB = Vector3.new(1, 200, 400)

		assert.equals(vectorA, vectorB)
	end)

	it("should not equal another Vector3 with different x, y or z values", function()
		local vectorA = Vector3.new(1, 200, 500)
		local vectorB1 = Vector3.new(1, 200, 3)
		local vectorB2 = Vector3.new(1, 3, 500)
		local vectorB3 = Vector3.new(100, 200, 500)

		assert.not_equals(vectorA, vectorB1)
		assert.not_equals(vectorA, vectorB2)
		assert.not_equals(vectorA, vectorB3)
	end)

	it("should throw when accessing an invalid member", function()
		assert.has.errors(function()
			local v = Vector3.new()
			v.frobulations = v.frobulations + 1
		end)
	end)

	it("should have a string representation of \"Vector3\"", function()
		assert.equal(tostring(Vector3), "Vector3")
	end)
end)
