Add Version() class tests

This commit is contained in:
David Capello 2019-04-21 00:05:21 -03:00
parent b16a07abc7
commit a7bdc39761
2 changed files with 37 additions and 7 deletions

View File

@ -1,7 +0,0 @@
-- Copyright (C) 2018 David Capello
--
-- This file is released under the terms of the MIT license.
-- Read LICENSE.txt for more information.
assert(string.sub(app.version, 1, 1) == "1")
assert(string.sub(app.version, 2, 2) == ".")

37
scripts/version.lua Normal file
View File

@ -0,0 +1,37 @@
-- Copyright (C) 2019 Igara Studio S.A.
-- Copyright (C) 2018 David Capello
--
-- This file is released under the terms of the MIT license.
-- Read LICENSE.txt for more information.
assert(string.sub(tostring(app.version), 1, 1) == "1")
assert(string.sub(tostring(app.version), 2, 2) == ".")
assert(app.version.major == 1)
assert(app.version.minor >= 2)
assert(app.version > Version("1.2.10-beta4"))
assert(Version("1") == Version("1"))
assert(Version("1.1") > Version("1"))
assert(Version("0.1") < Version("0.2"))
assert(Version("1.0.1") > Version("1"))
assert(Version("1.0.1") < Version("1.1"))
assert(Version("1.0.1") == Version("1.0.1"))
assert(Version("1.0.1") ~= Version("1.0.2"))
assert(Version("1.0.1") > Version("1.0.1-beta"))
assert(Version("1.0.1") > Version("1.0.1-dev"))
assert(Version("1.0.1-beta") > Version("1.0.1-alpha"))
assert(Version("1.0.1-beta50") < Version("1.0.1-beta100"))
local v = Version()
assert(v.major == 0)
assert(v.minor == 0)
assert(v.patch == 0)
assert(v.prerelease == "")
assert(v.prereleaseDigit == 0)
v = Version("1.2.10-beta4")
assert(v.major == 1)
assert(v.minor == 2)
assert(v.patch == 10)
assert(v.prerelease == "beta")
assert(v.prereleaseDigit == 4)