urbit-hob

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

commit e84b86d977e3f47a66264224f59fdb1072a0501e
parent 3b5a1380153c920080bee69775b07ede3cabe14a
Author: Jared Tobin <jared@jtobin.io>
Date:   Fri,  6 Sep 2019 15:16:20 -0230

test: add basic test suite

Diffstat:
Atest/Small.hs | 47+++++++++++++++++++++++++++++++++++++++++++++++
Murbit-hob.cabal | 13+++++++++++++
2 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/test/Small.hs b/test/Small.hs @@ -0,0 +1,47 @@ +module Main where + +import Control.Monad (unless) +import Data.List (nub, foldl') +import Prelude hiding (tail) +import System.Exit (exitSuccess, exitFailure) +import qualified Urbit.Ob.Ob as Ob + +a, b, c :: Int +a = 2 ^ 2 - 1 +b = 2 ^ 2 +c = a * b + +eff j m = + let v0 = [5, 9, 2, 6, 4, 0, 8, 7, 1, 10, 3, 11] + v1 = [2, 1, 0, 3, 10, 4, 9, 5, 7, 11, 6, 8] + v2 = [10, 6, 7, 1, 0, 11, 3, 9, 5, 2, 8, 4] + v3 = [11, 0, 3, 5, 9, 8, 6, 10, 4, 1, 2, 7] + + in case j of + 0 -> v0 !! m + 1 -> v1 !! m + 2 -> v2 !! m + _ -> v3 !! m + +feis = Ob.capFe 4 a b c eff + +tail = Ob.capFen 4 a b c eff + +main :: IO () +main = do + let emm = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] + perm = fmap feis emm + inv = fmap tail perm + distincts = nub perm + + let distinctElems = length distincts == length perm + unless distinctElems exitFailure + + let permuteSuccessful = foldl' (\acc x -> x `elem` emm && acc) True perm + unless permuteSuccessful exitFailure + + let tailInvertsFeis = emm == inv + unless tailInvertsFeis exitFailure + + exitSuccess + diff --git a/urbit-hob.cabal b/urbit-hob.cabal @@ -19,6 +19,8 @@ library default-language: Haskell2010 hs-source-dirs: lib other-modules: Paths_hob + ghc-options: + -Wall -Werror exposed-modules: Urbit.Ob , Urbit.Ob.Co @@ -32,3 +34,14 @@ library , murmur3 >= 1.0 && < 2 , text >= 1.2 && < 2 +Test-suite small + type: exitcode-stdio-1.0 + hs-source-dirs: test + main-is: Small.hs + default-language: Haskell2010 + ghc-options: + -rtsopts + build-depends: + base + , urbit-hob +