From c049731eab86f342611534c5d06874f0d9a70c5b Mon Sep 17 00:00:00 2001 From: Johannes Emerich Date: Thu, 7 Dec 2023 12:10:28 +0100 Subject: [PATCH] Add elm-verify-examples setup and examples Closes #6. --- .gitignore | 2 ++ src/Semver.elm | 18 +++++++++++++++++- tests/elm-verify-examples.json | 4 ++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/elm-verify-examples.json diff --git a/.gitignore b/.gitignore index 8b631e7..b826acd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ elm-stuff # elm-repl generated files repl-temp-* +# elm-verify-examples +tests/VerifyExamples diff --git a/src/Semver.elm b/src/Semver.elm index 6d8e57b..5b9360d 100644 --- a/src/Semver.elm +++ b/src/Semver.elm @@ -133,6 +133,10 @@ compare versionA versionB = {-| Shorthand for determining whether `versionA` precedes `versionB`. + + lessThan (version 1 0 0 [] []) (version 2 0 0 [] []) + --> True + -} lessThan : Version -> Version -> Bool lessThan versionA versionB = @@ -140,6 +144,10 @@ lessThan versionA versionB = {-| Shorthand for determining whether `versionA` is preceded by `versionB`. + + greaterThan (version 2 0 0 [] []) (version 1 0 0 [] []) + --> True + -} greaterThan : Version -> Version -> Bool greaterThan versionA versionB = @@ -152,9 +160,14 @@ greaterThan versionA versionB = {-| Produce a version's string representation. + v : Version + v = version 3 2 1 [ "foo", "qux" ] [ "bar" ] + + print v --> "3.2.1-foo.qux+bar" + The output format is such that - v |> print |> parse == Just v + parse (print v) --> Just v -} print : Version -> String @@ -184,6 +197,9 @@ Parsing fails if the string is not legal according to Semver 2.0.0. Does not accept loose syntax or prefixes ('v') to the version string. + parse "3.2.1-foo.qux+bar" + --> Just (version 3 2 1 [ "foo", "qux" ] [ "bar" ]) + -} parse : String -> Maybe Version parse versionString = diff --git a/tests/elm-verify-examples.json b/tests/elm-verify-examples.json new file mode 100644 index 0000000..31fc355 --- /dev/null +++ b/tests/elm-verify-examples.json @@ -0,0 +1,4 @@ +{ + "root": "../src", + "tests": ["Semver"] +}