Skip to content

Commit

Permalink
Add elm-verify-examples setup and examples
Browse files Browse the repository at this point in the history
Closes #6.
  • Loading branch information
knuton committed Dec 7, 2023
1 parent dc14207 commit c049731
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
elm-stuff
# elm-repl generated files
repl-temp-*
# elm-verify-examples
tests/VerifyExamples
18 changes: 17 additions & 1 deletion src/Semver.elm
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,21 @@ 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 =
compare versionA versionB == LT


{-| 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 =
Expand All @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
4 changes: 4 additions & 0 deletions tests/elm-verify-examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"root": "../src",
"tests": ["Semver"]
}

0 comments on commit c049731

Please sign in to comment.