urbit-hob

Haskell utilities for phonetic base wrangling.
Log | Files | Refs | README | LICENSE

commit 9ebd76e8935d50e2ce569d72b4e48e44f1bb4997
parent a56281d05effa1124256b48e8fa9bc231a9af7f8
Author: Jared Tobin <jared@jtobin.io>
Date:   Thu, 12 Sep 2019 14:51:34 -0230

tests: add failing case for tail . feis

See #2.

Diffstat:
Mtest/Ob.hs | 2++
Mtest/Ob/Tests/Property.hs | 8+++++++-
Mtest/Ob/Tests/Small.hs | 5+++++
Atest/Ob/Tests/Unit.hs | 15+++++++++++++++
Murbit-hob.cabal | 1+
5 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/test/Ob.hs b/test/Ob.hs @@ -3,6 +3,7 @@ module Main where import qualified Ob.Tests.Small as S import qualified Ob.Tests.Med as M import qualified Ob.Tests.Property as P +import qualified Ob.Tests.Unit as U import Test.Hspec main :: IO () @@ -11,3 +12,4 @@ main = context "small input space" S.tests context "medium input space" M.tests context "32-bit input space" P.tests + context "unit tests" U.tests diff --git a/test/Ob/Tests/Property.hs b/test/Ob/Tests/Property.hs @@ -9,8 +9,14 @@ import Test.QuickCheck import qualified Urbit.Ob.Ob as Ob tests :: Spec -tests = +tests = do + describe "feis" $ + modifyMaxSuccess (const 1000) $ + it "inverts tail" $ + property $ \x -> Ob.feis (Ob.tail x) == x + describe "tail" $ modifyMaxSuccess (const 1000) $ it "inverts feis" $ property $ \x -> Ob.tail (Ob.feis x) == x + diff --git a/test/Ob/Tests/Small.hs b/test/Ob/Tests/Small.hs @@ -34,6 +34,7 @@ tests = do let emm = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] perm = fmap feis emm inv = fmap tail perm + rinv = fmap feis inv distincts = nub perm describe "feis" $ do @@ -43,6 +44,10 @@ tests = do it "permutes successfully" $ foldl' (\acc x -> x `elem` emm && acc) True perm `shouldBe` True + describe "feis" $ + it "inverts tail" $ + rinv `shouldBe` perm + describe "tail" $ it "inverts feis" $ emm `shouldBe` inv diff --git a/test/Ob/Tests/Unit.hs b/test/Ob/Tests/Unit.hs @@ -0,0 +1,15 @@ + +module Ob.Tests.Unit ( + tests + ) where + +import Test.Hspec +import qualified Urbit.Ob.Ob as Ob + +tests :: Spec +tests = + describe "tail . feis" $ + context "when applied to 2052065766" $ + it "should be the identity function" $ + Ob.tail (Ob.feis 2052065766) `shouldBe` 2052065766 + diff --git a/urbit-hob.cabal b/urbit-hob.cabal @@ -72,6 +72,7 @@ Test-suite ob Ob.Tests.Small Ob.Tests.Med Ob.Tests.Property + Ob.Tests.Unit default-language: Haskell2010 ghc-options: -rtsopts