packages feed

hslua-module-version 1.0.2 → 1.0.3

raw patch · 5 files changed

+37/−5 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -2,6 +2,16 @@  `hslua-module-version` uses [PVP Versioning][]. +## hslua-module-version-1.0.3++Released 2022-09-01.++-   Allow equality checks with non-version values: A *Version*+    value can now be compared with any value. Previously,+    comparing a version with a value that cannot be interpreted as+    a Version would result in an error, violating the principle of+    least surprise.+ ## hslua-module-version-1.0.2  Released 2022-02-19.
LICENSE view
@@ -1,4 +1,4 @@-Copyright © 1994-2020 Lua.org, PUC-Rio.+Copyright © 1994-2022 Lua.org, PUC-Rio. Copyright © 2007-2012 Gracjan Polak Copyright © 2012-2015 Ömer Sinan Ağacan Copyright © 2016-2022 Albert Krewinkel
hslua-module-version.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.2 name:                hslua-module-version-version:             1.0.2+version:             1.0.3 synopsis:            Lua module to work with version specifiers. description:         Wrapper for the Data.Version.Version Haskell type. homepage:            https://hslua.org/@@ -21,8 +21,8 @@                    , GHC == 8.6.5                    , GHC == 8.8.4                    , GHC == 8.10.7-                   , GHC == 9.0.1-                   , GHC == 9.2.1+                   , GHC == 9.0.2+                   , GHC == 9.2.3  source-repository head   type:                git
src/HsLua/Module/Version.hs view
@@ -21,6 +21,7 @@ where  import Prelude hiding (error)+import Control.Applicative (optional) import Data.Maybe (fromMaybe) import Data.Version   ( Version, makeVersion, parseVersion, showVersion, versionBranch )@@ -58,7 +59,11 @@ -- | Type definition of Lua Version values. typeVersion :: LuaError e => DocumentedTypeWithList e Version Int typeVersion = deftype' "Version"-  [ operation Eq $ versionComparison (==) "true iff v1 == v2"+  [ operation Eq $ lambda+      ### liftPure2 (\a b -> fromMaybe False ((==) <$> a <*> b))+      <#> parameter (optional . peekVersionFuzzy) "Version" "a" ""+      <#> parameter (optional . peekVersionFuzzy) "Version" "b" ""+      =#> boolResult "true iff v1 == v2"   , operation Le $ versionComparison (<=) "true iff v1 <= v2"   , operation Lt $ versionComparison (<)  "true iff v1 < v2"   , operation Len $ lambda
test/test-version.lua view
@@ -53,6 +53,23 @@       assert.is_truthy(Version '8' < '9.1')       assert.is_falsy(Version '8.8' < '8.7')     end),+    test('equality test works with value not usable as a version', function ()+      assert.is_falsy(Version '8' == function() end)+    end),+    test('other comparisons fail if one value is not a version', function ()+      assert.error_matches(+        function () return Version '8' < (function() end) end,+        'could not peek Version'+      )+      assert.error_matches(+        function () return Version '8' <= (function() end) end,+        'could not peek Version'+      )+      assert.error_matches(+        function () return Version '8' > (function() end) end,+        'could not peek Version'+      )+    end)   },    group 'conversion to string' {