packages feed

hslua-module-system 1.0.2 → 1.0.3

raw patch · 4 files changed

+54/−11 lines, 4 filesdep ~hslua-coredep ~tasty-luaPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hslua-core, tasty-lua

API changes (from Hackage documentation)

+ HsLua.Module.System: cputime :: LuaError e => DocumentedFunction e

Files

CHANGELOG.md view
@@ -2,6 +2,13 @@  `hslua-module-system` uses [PVP Versioning][]. +## hslua-module-system-1.0.3++Released 2023-02-14.++-   Added new function `cputime` and field `cputime_precision`,+    e.g. for benchmarking.+ ## hslua-module-system-1.0.2  Released 2022-02-19.@@ -10,7 +17,7 @@  ## hslua-module-system-1.0.1 -Released 29-01-2022.+Released 2022-01-29.  -   Relaxed upper bound of hslua-core, hslua-marshalling, and     hslua-packaging, allowing their respective version 2.1.
hslua-module-system.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.2 name:                hslua-module-system-version:             1.0.2+version:             1.0.3 synopsis:            Lua module wrapper around Haskell's System module.  description:         Provides access to system information and@@ -19,14 +19,13 @@ category:            Foreign extra-source-files:  CHANGELOG.md                    , test/test-system.lua-tested-with:         GHC == 8.0.2-                   , GHC == 8.2.2-                   , GHC == 8.4.4+tested-with:         GHC == 8.4.4                    , GHC == 8.6.5                    , GHC == 8.8.3                    , GHC == 8.10.7-                   , GHC == 9.0.1-                   , GHC == 9.2.1+                   , GHC == 9.0.2+                   , GHC == 9.2.5+                   , GHC == 9.4.4  source-repository head   type:              git@@ -36,7 +35,7 @@ common common-options   default-language:    Haskell2010   build-depends:       base                 >= 4.8    && < 5-                     , hslua-core           >= 2.1    && < 2.3+                     , hslua-core           >= 2.1    && < 2.4                      , hslua-packaging      >= 2.1    && < 2.3                      , text                 >= 1.2    && < 2.1   default-extensions:  LambdaCase@@ -72,5 +71,5 @@   build-depends:       hslua-module-system                      , tasty                >= 0.11                      , tasty-hunit          >= 0.9-                     , tasty-lua            >= 1.0    && < 1.1+                     , tasty-lua            >= 1.0    && < 1.2                      , text
src/HsLua/Module/System.hs view
@@ -20,9 +20,10 @@   , os    -- ** Functions+  , cputime   , env-  , getwd   , getenv+  , getwd   , ls   , mkdir   , rmdir@@ -47,6 +48,7 @@  import qualified Data.Text as T import qualified HsLua.Core as Lua+import qualified System.CPUTime as CPUTime import qualified System.Directory as Directory import qualified System.Environment as Env import qualified System.Info as Info@@ -60,10 +62,12 @@       [ arch       , compiler_name       , compiler_version+      , cputime_precision       , os       ]   , moduleFunctions =-      [ env+      [ cputime+      , env       , getenv       , getwd       , ls@@ -117,6 +121,18 @@                      versionBranch Info.compilerVersion   } +-- | Field containing the smallest measurable difference in CPU time.+cputime_precision :: Field e+cputime_precision = Field+  { fieldName = "cputime_precision"+  , fieldDescription = T.unlines+      [ "The smallest measurable difference in CPU time that the"+      , "implementation can record, and is given as an integral number of"+      , "picoseconds."+      ]+  , fieldPushValue = pushIntegral CPUTime.cpuTimePrecision+  }+ -- | Field containing the operating system on which the program is -- running. os :: Field e@@ -130,6 +146,18 @@ -- -- Functions --++-- | Access the CPU time, e.g. for benchmarking.+cputime :: LuaError e => DocumentedFunction e+cputime = defun "cputime"+  ### ioToLua CPUTime.getCPUTime+  =#> functionResult pushIntegral "integer" "CPU time in picoseconds"+  #? T.unlines+     [ "Returns the number of picoseconds CPU time used by the current"+     , "program. The precision of this result may vary in different"+     , "versions and on different platforms. See also the field"+     , "`cputime_precision`."+     ]  -- | Retrieve the entire environment env :: LuaError e => DocumentedFunction e
test/test-system.lua view
@@ -43,8 +43,17 @@     test('compiler_version', function ()       assert.are_equal(type(system.compiler_version), 'table')     end),+    test('cputime_precision', function ()+      assert.are_equal(type(system.cputime_precision), 'number')+    end),     test('os', function ()       assert.are_equal(type(system.os), 'string')+    end),+  },++  group 'cputime' {+    test('returns a number', function ()+      assert.are_equal(type(system.cputime()), 'number')     end),   },