From f15dccf2f3529eee7cf89bddcfb9f9acc076f005 Mon Sep 17 00:00:00 2001 From: Andy Davidoff Date: Fri, 8 Nov 2019 21:57:59 -0500 Subject: [PATCH] 1.8.7: version comparison operators --- bump.nim | 6 ++++++ bump.nimble | 2 +- tests/tbump.nim | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bump.nim b/bump.nim index f5b98c0..1873ddb 100644 --- a/bump.nim +++ b/bump.nim @@ -172,6 +172,12 @@ proc isValid*(ver: Version): bool = ## true if the version seems legit result = ver.major > 0 or ver.minor > 0 or ver.patch > 0 +proc `>`*(a, b: Version): bool {.inline.} = + result = a.major > b.major or a.minor > b.minor or a.patch > b.patch + +proc `==`*(a, b: Version): bool {.inline.} = + result = a.major == b.major and a.minor == b.minor and a.patch == b.patch + proc parseVersion*(nimble: string): Option[Version] = ## try to parse a version from any line in a .nimble; ## safe to use at compile-time diff --git a/bump.nimble b/bump.nimble index dc1626d..b405edd 100644 --- a/bump.nimble +++ b/bump.nimble @@ -1,4 +1,4 @@ -version = "1.8.6" +version = "1.8.7" author = "disruptek" description = "a tiny tool to bump nimble versions" license = "MIT" diff --git a/tests/tbump.nim b/tests/tbump.nim index a7e98b2..8149989 100644 --- a/tests/tbump.nim +++ b/tests/tbump.nim @@ -134,3 +134,11 @@ suite "bump": check randoR.found.get.package == "red" check randoB.found.isSome check randoB.found.get.package == "blue" + + test "version comparison": + check ver123 < ver155 + check ver170 > ver123 + check ver170 != (1'u, 2'u, 3'u) + check ver170 == (1'u, 7'u, 0'u) + check ver170 <= (1'u, 7'u, 0'u) + check ver170 >= (1'u, 7'u, 0'u)