packages feed

hslua-module-system 0.1.0 → 0.1.0.1

raw patch · 2 files changed

+63/−1 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

hslua-module-system.cabal view
@@ -1,5 +1,5 @@ name:                hslua-module-system-version:             0.1.0+version:             0.1.0.1 synopsis:            Lua module wrapper around Haskell's System module.  description:         Provides access to system information and functionality@@ -18,6 +18,7 @@ category:            Foreign build-type:          Simple extra-source-files:  CHANGELOG.md+                     test/system-module-tests.lua cabal-version:       >=1.10  source-repository head
+ test/system-module-tests.lua view
@@ -0,0 +1,61 @@+--+-- Tests for the hstext module+--+local system = require 'system'++local token = 'Banana'+function write_read_token (tmpdir)+  local filename = tmpdir .. '/foo.txt'+  local fh = io.open(filename, 'w')+  fh:write(token .. '\n')+  fh:close()+  return io.open(filename):read '*l'+end++-- with_tmpdir+assert(system.with_tmpdir('.', 'foo', write_read_token) == token)+assert(system.with_tmpdir('foo', write_read_token) == token)++-- tmpdirname+assert(type(system.tmpdirname()) == 'string', "tmpdirname should return a string")++-- env+assert(type(system.env()) == 'table')++-- ls+assert(type(system.ls('.')) == 'table')+assert(#system.ls('.') == #system.ls())+-- ls should fail when called on files or non-existent directories+assert(pcall(system.ls, 'thisdoesnotexist') == false)+assert(pcall(system.ls, 'README.md') == false)++-- currentdir+assert(type(system.currentdir()) == 'string')+-- pwd is an alias for currentdir+assert(system.currentdir() == system.pwd())+++-- Complex scripts+function in_tmpdir (callback)+  local orig_dir = system.currentdir()+  return system.with_tmpdir(+    'hello',+    function (tmpdir)+      system.chdir(tmpdir)+      local result = callback(tmpdir)+      system.chdir(orig_dir)+      return result+    end+  )+end++function create_then_count_files ()+  io.open('README.org', 'w'):close()+  return #system.ls '.'+end++assert(in_tmpdir(create_then_count_files) == 1, 'Number of files should be 1')++system.setenv('TESTING', token)+assert(system.getenv 'TESTING' == token,+       'setting and getting env var is inconsistent')