Skip to content

Commit

Permalink
1.8.7: version comparison operators
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Nov 9, 2019
1 parent f2ed4ee commit f15dccf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions bump.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bump.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.8.6"
version = "1.8.7"
author = "disruptek"
description = "a tiny tool to bump nimble versions"
license = "MIT"
Expand Down
8 changes: 8 additions & 0 deletions tests/tbump.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit f15dccf

Please sign in to comment.