packages feed

tasty-lua 0.2.0 → 0.2.0.1

raw patch · 2 files changed

+67/−1 lines, 2 files

Files

tasty-lua.cabal view
@@ -1,5 +1,5 @@ name:                tasty-lua-version:             0.2.0+version:             0.2.0.1 synopsis:            Write tests in Lua, integrate into tasty. description:         Allow users to define tasty tests from Lua. homepage:            https://github.com/hslua/tasty-lua@@ -12,6 +12,7 @@ build-type:          Simple extra-source-files:  CHANGELOG.md                    , tasty.lua+                   , test/test-tasty.lua cabal-version:       >=1.10 tested-with:         GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5 
+ test/test-tasty.lua view
@@ -0,0 +1,65 @@+local tasty = require 'tasty'++local assert = tasty.assert+local test = tasty.test_case+local group = tasty.test_group++return {+  group 'assertors'  {+    group 'error_matches' {+      test('succeeds if error matches', function ()+        assert.error_matches(+          function () error 'Futurama' end,+          'tura'+        )+      end),+      test('fails if function succeeds', function ()+        local success = pcall(assert.error_matches, function () end, '')+        assert.is_falsy(success)+      end)+    },++    group 'is_truthy' {+      test('zero is truthy', function() assert.is_truthy(0) end),+      test('true is truthy', function() assert.is_truthy(true) end),+      test('empty string is truthy', function() assert.is_truthy '' end),+    },++    group 'is_falsy' {+      test('false is falsy', function() assert.is_falsy(false) end),+      test('nil is falsy', function() assert.is_falsy(nil) end),+    },++    group 'is_nil' {+      test('nil is nil', function () assert.is_nil(nil) end)+    },++    group 'are_equal' {+      test('equal strings', function () assert.are_equal('test', 'test') end)+    },++    group 'are_same' {+      test('numbers', function ()+        assert.are_same(1, 1)+      end),+      test('nil', function ()+        assert.are_same(nil, nil)+      end),+      test('table', function ()+        assert.are_same({2, 3, 5, 7}, {2, 3, 5, 7})+      end),+      test('unequal numbers', function ()+        assert.error_matches(+          function () assert.are_same(0, 1) end,+          "expected same values, got 0 and 1"+        )+      end),+      test('tables', function ()+        assert.error_matches(+          function () assert.are_same({}, {1}) end,+          "expected same values, got"+        )+      end),+    },+  },+}