urbit/pkg/hs/urbit-king/test/ClayTests.hs
2020-01-23 21:20:43 -08:00

29 lines
698 B
Haskell

module ClayTests (tests) where
import Ur.Noun.Conversions
import Ur.Prelude
import Test.QuickCheck hiding ((.&.))
import Test.Tasty
import Test.Tasty.QuickCheck
import Test.Tasty.TH
instance Arbitrary Knot where
arbitrary = (MkKnot . pack) <$> sublistOf ['a'..'z']
nonEmptyList :: (Arbitrary a) => Gen [a]
nonEmptyList = sized $ \n ->
do k <- choose (1, max 1 n)
vector k
instance Arbitrary Path where
arbitrary = Path <$> nonEmptyList
testPathRoundTrip :: Path -> Property
testPathRoundTrip p =
classify (1 == (length $ unPath p)) "singleton" $
(filePathToPath (pathToFilePath p)) === p
tests = testGroup "Clay"
[ testProperty "Path round trip" $ testPathRoundTrip ]