forked from rojo-rbx/rojo
Check for compatible updates in plugin (#832)
This commit is contained in:
@@ -3,6 +3,7 @@ return function()
|
||||
|
||||
it("should compare equal versions", function()
|
||||
expect(Version.compare({ 1, 2, 3 }, { 1, 2, 3 })).to.equal(0)
|
||||
expect(Version.compare({ 1, 2, 3, "rc1" }, { 1, 2, 3, "rc1" })).to.equal(0)
|
||||
expect(Version.compare({ 0, 4, 0 }, { 0, 4 })).to.equal(0)
|
||||
expect(Version.compare({ 0, 0, 123 }, { 0, 0, 123 })).to.equal(0)
|
||||
expect(Version.compare({ 26 }, { 26 })).to.equal(0)
|
||||
@@ -13,6 +14,7 @@ return function()
|
||||
it("should compare newer, older versions", function()
|
||||
expect(Version.compare({ 1 }, { 0 })).to.equal(1)
|
||||
expect(Version.compare({ 1, 1 }, { 1, 0 })).to.equal(1)
|
||||
expect(Version.compare({ 1, 2, 3 }, { 1, 2, 0 })).to.equal(1)
|
||||
end)
|
||||
|
||||
it("should compare different major versions", function()
|
||||
@@ -25,4 +27,37 @@ return function()
|
||||
expect(Version.compare({ 1, 2, 3 }, { 1, 3, 2 })).to.equal(-1)
|
||||
expect(Version.compare({ 50, 1 }, { 50, 2 })).to.equal(-1)
|
||||
end)
|
||||
|
||||
it("should compare different patch versions", function()
|
||||
expect(Version.compare({ 1, 1, 3 }, { 1, 1, 2 })).to.equal(1)
|
||||
expect(Version.compare({ 1, 1, 2 }, { 1, 1, 3 })).to.equal(-1)
|
||||
expect(Version.compare({ 1, 1, 3, "-rc1" }, { 1, 1, 2, "-rc2" })).to.equal(1)
|
||||
expect(Version.compare({ 1, 1, 2, "-rc5" }, { 1, 1, 3, "-alpha" })).to.equal(-1)
|
||||
end)
|
||||
|
||||
it("should compare prerelease tags", function()
|
||||
expect(Version.compare({ 1, 0, 0, "-alpha" }, { 1, 0, 0 })).to.equal(-1)
|
||||
expect(Version.compare({ 1, 0, 0 }, { 1, 0, 0, "-alpha" })).to.equal(1)
|
||||
expect(Version.compare({ 1, 0, 0, "-rc1" }, { 1, 0, 0, "-rc2" })).to.equal(-1)
|
||||
expect(Version.compare({ 1, 0, 0, "-rc2" }, { 1, 0, 0, "-rc1" })).to.equal(1)
|
||||
|
||||
-- Non number prereleases are not compared since that isn't meaningful
|
||||
expect(Version.compare({ 1, 0, 0, "-alpha" }, { 1, 0, 0, "-beta" })).to.equal(0)
|
||||
end)
|
||||
|
||||
it("should parse version from strings", function()
|
||||
local a = Version.parse("v1.0.0")
|
||||
expect(a).to.be.ok()
|
||||
expect(a[1]).to.equal(1)
|
||||
expect(a[2]).to.equal(0)
|
||||
expect(a[3]).to.equal(0)
|
||||
expect(a[4]).to.equal(nil)
|
||||
|
||||
local b = Version.parse("7.3.1-rc1")
|
||||
expect(b).to.be.ok()
|
||||
expect(b[1]).to.equal(7)
|
||||
expect(b[2]).to.equal(3)
|
||||
expect(b[3]).to.equal(1)
|
||||
expect(b[4]).to.equal("-rc1")
|
||||
end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user