babashka/test-resources/lib_tests/version_clj/compare_test.cljc
Lee Read 5d9027fe0a
Added lib tests for version-clj (#569)
The version-clj project uses `.cljx` so I hand-transcribed them to `.cljc`.

Tests are from from version-clj v1.0.2:
https://github.com/xsc/version-clj/tree/clojars-0.1.2

Added `version-clj.via-use-test` to verify loading version-clj via `use`.

Verification via: `./script/run_lib_tests`, I observed version-clj tests:
1. failing for `bb` native v0.2.0
2. passing for `./bb` native built from master
3. passing for `lein bb` from master

This should be the final change that closes #565.
2020-09-09 23:03:15 +02:00

59 lines
2.1 KiB
Clojure

(ns version-clj.compare-test
(:require [clojure.test :refer [deftest are]]
[version-clj.compare :refer [version-compare]]))
(deftest t-version-compare
(are [v0 v1 r] (= (version-compare v0 v1) r)
;; Numeric Comparison
"1.0.0" "1.0.0" 0
"1.0.0" "1.0" 0
"1.0.1" "1.0" 1
"1.0.0" "1.0.1" -1
"1.0.0" "0.9.2" 1
"0.9.2" "0.9.3" -1
"0.9.2" "0.9.1" 1
"0.9.5" "0.9.13" -1
"10.2.0.3.0" "11.2.0.3.0" -1
"10.2.0.3.0" "5.2.0.3.0" 1
"1.0.0-SNAPSHOT" "1.0.1-SNAPSHOT" -1
"1.0.0-alpha" "1.0.1-beta" -1
"1.1-dolphin" "1.1.1-cobra" -1
;; Lexical Comparison
"1.0-alpaca" "1.0-bermuda" -1
"1.0-alpaca" "1.0-alpaci" -1
"1.0-dolphin" "1.0-cobra" 1
;; Qualifier Comparison
"1.0.0-alpha" "1.0.0-beta" -1
"1.0.0-beta" "1.0.0-alpha" 1
"1.0.0-alpaca" "1.0.0-beta" -1
"1.0.0-final" "1.0.0-milestone" 1
;; Qualifier/Numeric Comparison
"1.0.0-alpha1" "1.0.0-alpha2" -1
"1.0.0-alpha5" "1.0.0-alpha23" -1
"1.0-RC5" "1.0-RC20" -1
"1.0-RC11" "1.0-RC6" 1
;; Releases are newer than SNAPSHOTs
"1.0.0" "1.0.0-SNAPSHOT" 1
"1.0.0-SNAPSHOT" "1.0.0-SNAPSHOT" 0
"1.0.0-SNAPSHOT" "1.0.0" -1
;; Releases are newer than qualified versions
"1.0.0" "1.0.0-alpha5" 1
"1.0.0-alpha5" "1.0.0" -1
;; SNAPSHOTS are newer than qualified versions
"1.0.0-SNAPSHOT" "1.0.0-RC1" 1
"1.0.0-SNAPSHOT" "1.0.1-RC1" -1
;; Some other Formats
"9.1-901.jdbc4" "9.1-901.jdbc3" 1
"9.1-901-1.jdbc4" "9.1-901.jdbc4" 1
;; Some more zero-extension Tests
"1-SNAPSHOT" "1.0-SNAPSHOT" 0
"1-alpha" "1-alpha0" 0
))