return function()local a=require((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):FindFirstChild("\067\111\108\111\114"))local E=a.Color local C=a.Gradient it("\115\104\111\117\108\100 \098\101 \105\109\109\117\116\097\098\108\101",function()(expect(function()C.new=nil end)).to.throw()end)it("\115\104\111\117\108\100 \104\097\118\101 \097 \112\117\098\108\105\099 \065\080\073",function()(expect(C.new)).to.be.a("\102\117\110\099\116\105\111\110");(expect(C.fromColors)).to.be.a("\102\117\110\099\116\105\111\110");(expect(C.fromColorSequence)).to.be.a("\102\117\110\099\116\105\111\110");(expect(C.invert)).to.be.a("\102\117\110\099\116\105\111\110");(expect(C.color)).to.be.a("\102\117\110\099\116\105\111\110");(expect(C.colors)).to.be.a("\102\117\110\099\116\105\111\110");(expect(C.colorSequence)).to.be.a("\102\117\110\099\116\105\111\110")end)describe("\099\111\110\115\116\114\117\099\116\111\114\115",function()it("\115\104\111\117\108\100 \101\110\102\111\114\099\101 \116\105\109\101 \099\111\110\115\116\114\097\105\110\116\115",function()(expect(C.new({{Time=0,Color=E.random()};{Time=1;Color=E.random()}}))).to.be.ok();(expect(function()C.new({{Time=0,Color=E.random()},{Time=1;Color=E.random()},{Time=2,Color=E.random()}})end)).to.throw()end)it("\115\104\111\117\108\100 \101\110\102\111\114\099\101 \115\101\113\117\101\110\116\105\097\108 \107\101\121\112\111\105\110\116 \111\114\100\101\114",function()(expect(C.new({{Time=0,Color=E.random()},{Time=.5,Color=E.random()};{Time=1;Color=E.random()}}))).to.be.ok();(expect(function()C.new({{Time=0;Color=E.random()},{Time=1;Color=E.random()},{Time=.5,Color=E.random()}})end)).to.throw()end)it("\115\104\111\117\108\100 \115\117\112\112\111\114\116 \097 \107\101\121\112\111\105\110\116 \097\114\114\097\121",function()local a=E.new(0,0,0)local s=E.new(.5,.5,.5)local p=E.new(1,1,1);(expect(function()C.new({{Time=0;Color=a}})end)).to.throw();(expect(C.new({{Time=0,Color=a},{Time=.5;Color=s};{Time=1;Color=p}}))).to.be.ok()end)it("\115\104\111\117\108\100 \115\117\112\112\111\114\116 \111\110\101 \111\114 \109\111\114\101 \067\111\108\111\114\115",function()local a=E.new(0,0,0)local s=E.new(.5,.5,.5)local p=E.new(1,1,1);(expect(C.fromColors(a))).to.be.ok();(expect(C.fromColors(a,p))).to.be.ok();(expect(C.fromColors(a,s,p))).to.be.ok();(expect(C.fromColors(a))).to.equal(C.new({{Time=0;Color=a},{Time=1,Color=a}}));(expect(C.fromColors(a,p))).to.equal(C.new({{Time=0;Color=a},{Time=1;Color=p}}));(expect(C.fromColors(a,s,p))).to.equal(C.new({{Time=0,Color=a};{Time=.5;Color=s},{Time=1;Color=p}}))end)it("\115\104\111\117\108\100 \115\117\112\112\111\114\116 \097 \067\111\108\111\114\083\101\113\117\101\110\099\101",function()local a=ColorSequence.new(Color3.new(0,0,0),Color3.new(1,1,1))local s=E.new(0,0,0)local p=E.new(1,1,1);(expect(C.fromColorSequence(a))).to.be.ok();(expect(C.fromColorSequence(a))).to.equal(C.new({{Time=0;Color=s},{Time=1;Color=p}}))end)end)describe("\071\114\097\100\105\101\110\116\115",function()it("\115\104\111\117\108\100 \098\101 \105\109\109\117\116\097\098\108\101",function()local a=C.fromColors(E.new(0,0,0),E.new(1,1,1));(expect(function()a.Keypoints=nil end)).to.throw();(expect(function()a.Keypoints[-1]=true end)).to.throw();(expect(function()a.Keypoints[1].Time=nil end)).to.throw()end)it("\115\104\111\117\108\100 \098\101 \105\110\118\101\114\116\105\098\108\101",function()local a=C.fromColors(E.new(0,0,0),E.new(1,1,1))local s=C.fromColors(E.new(1,1,1),E.new(0,0,0));(expect(a)).never.to.equal(s);(expect(a:invert())).to.equal(s);(expect(s:invert())).to.equal(a)end)it("\115\104\111\117\108\100 \115\117\112\112\111\114\116 \103\101\110\101\114\097\116\105\110\103 \099\111\108\111\114\115",function()local a=C.fromColors(E.new(0,0,0),E.new(1,1,1));(expect(a:color(.5))).to.be.ok();(expect(function()a:color(-1)end)).to.throw();(expect(function()a:color(2)end)).to.throw();(expect(function()local E=10 local C=a:colors(E)for s=1,E,1 do assert(a:color((s-1)/(E-1))==C[s],"\099\111\108\111\114\115 \097\114\101 \110\111\116 \101\113\117\105\100\105\115\116\097\110\116")end end)).never.to.throw()end)it("\115\104\111\117\108\100 \115\117\112\112\111\114\116 \103\101\110\101\114\097\116\105\110\103 \067\111\108\111\114\083\101\113\117\101\110\099\101\115",function()local a=C.fromColors(E.new(0,0,0),E.new(1,1,1));(expect(a:colorSequence())).to.be.ok();(expect(a:colorSequence())).to.equal(ColorSequence.new(Color3.new(0,0,0),Color3.new(1,1,1)));(expect(a:colorSequence(nil,"\088\089\090"))).never.to.equal(ColorSequence.new(Color3.new(0,0,0),Color3.new(1,1,1)))end)end)end
return function()
    local ColorLib = require(game:GetService("ReplicatedStorage"):FindFirstChild("Color"))

    local Color = ColorLib.Color
    local Gradient = ColorLib.Gradient

    it("should be immutable", function()
        expect(function()
            Gradient.new = nil
        end).to.throw()
    end)

    it("should have a public API", function()
        expect(Gradient.new).to.be.a("function")
        expect(Gradient.fromColors).to.be.a("function")
        expect(Gradient.fromColorSequence).to.be.a("function")

        expect(Gradient.invert).to.be.a("function")
        expect(Gradient.color).to.be.a("function")
        expect(Gradient.colors).to.be.a("function")
        expect(Gradient.colorSequence).to.be.a("function")
    end)

    describe("constructors", function()
        it("should enforce time constraints", function()
            expect(Gradient.new({
                {Time = 0, Color = Color.random()},
                {Time = 1, Color = Color.random()},
            })).to.be.ok()

            expect(function()
                Gradient.new({
                    {Time = 0, Color = Color.random()},
                    {Time = 1, Color = Color.random()},
                    {Time = 2, Color = Color.random()}
                })
            end).to.throw()
        end)

        it("should enforce sequential keypoint order", function()
            expect(Gradient.new({
                {Time = 0, Color = Color.random()},
                {Time = 0.5, Color = Color.random()},
                {Time = 1, Color = Color.random()},
            })).to.be.ok()

            expect(function()
                Gradient.new({
                    {Time = 0, Color = Color.random()},
                    {Time = 1, Color = Color.random()},
                    {Time = 0.5, Color = Color.random()}
                })
            end).to.throw()
        end)

        it("should support a keypoint array", function()
            local black = Color.new(0, 0, 0)
            local grey = Color.new(0.5, 0.5, 0.5)
            local white = Color.new(1, 1, 1)

            expect(function()
                Gradient.new({
                    {Time = 0, Color = black}
                })
            end).to.throw()

            expect(Gradient.new({
                {Time = 0, Color = black},
                {Time = 0.5, Color = grey},
                {Time = 1, Color = white}
            })).to.be.ok()
        end)

        it("should support one or more Colors", function()
            local black = Color.new(0, 0, 0)
            local grey = Color.new(0.5, 0.5, 0.5)
            local white = Color.new(1, 1, 1)

            expect(Gradient.fromColors(black)).to.be.ok()
            expect(Gradient.fromColors(black, white)).to.be.ok()
            expect(Gradient.fromColors(black, grey, white)).to.be.ok()

            expect(Gradient.fromColors(black)).to.equal(Gradient.new({
                {Time = 0, Color = black},
                {Time = 1, Color = black}
            }))

            expect(Gradient.fromColors(black, white)).to.equal(Gradient.new({
                {Time = 0, Color = black},
                {Time = 1, Color = white}
            }))

            expect(Gradient.fromColors(black, grey, white)).to.equal(Gradient.new({
                {Time = 0, Color = black},
                {Time = 0.5, Color = grey},
                {Time = 1, Color = white}
            }))
        end)

        it("should support a ColorSequence", function()
            local cs = ColorSequence.new(Color3.new(0, 0, 0), Color3.new(1, 1, 1))
            local black = Color.new(0, 0, 0)
            local white = Color.new(1, 1, 1)

            expect(Gradient.fromColorSequence(cs)).to.be.ok()

            expect(Gradient.fromColorSequence(cs)).to.equal(Gradient.new({
                {Time = 0, Color = black},
                {Time = 1, Color = white}
            }))
        end)
    end)

    describe("Gradients", function()
        it("should be immutable", function()
            local gradient = Gradient.fromColors(Color.new(0, 0, 0), Color.new(1, 1, 1))
            
            expect(function()
                gradient.Keypoints = nil
            end).to.throw()

            expect(function()
                gradient.Keypoints[-1] = true
            end).to.throw()

            expect(function()
                gradient.Keypoints[1].Time = nil
            end).to.throw()
        end)

        it("should be invertible", function()
            local blackToWhite = Gradient.fromColors(Color.new(0, 0, 0), Color.new(1, 1, 1))
            local whiteToBlack = Gradient.fromColors(Color.new(1, 1, 1), Color.new(0, 0, 0))

            expect(blackToWhite).never.to.equal(whiteToBlack)
            expect(blackToWhite:invert()).to.equal(whiteToBlack)
            expect(whiteToBlack:invert()).to.equal(blackToWhite)
        end)

        it("should support generating colors", function()
            local gradient = Gradient.fromColors(Color.new(0, 0, 0), Color.new(1, 1, 1))

            expect(gradient:color(0.5)).to.be.ok()

            expect(function()
                gradient:color(-1)
            end).to.throw()

            expect(function()
                gradient:color(2)
            end).to.throw()

            expect(function()
                local numColors = 10
                local colors = gradient:colors(numColors)

                for i = 1, numColors do
                    assert(gradient:color((i - 1) / (numColors - 1)) == colors[i], "colors are not equidistant")
                end
            end).never.to.throw()
        end)

        it("should support generating ColorSequences", function()
            local gradient = Gradient.fromColors(Color.new(0, 0, 0), Color.new(1, 1, 1))

            expect(gradient:colorSequence()).to.be.ok()
            expect(gradient:colorSequence()).to.equal(ColorSequence.new(Color3.new(0, 0, 0), Color3.new(1, 1, 1)))
            expect(gradient:colorSequence(nil, "XYZ")).never.to.equal(ColorSequence.new(Color3.new(0, 0, 0), Color3.new(1, 1, 1)))
        end)
    end)
end