1
1
mirror of https://github.com/urbit/shrub.git synced 2024-12-29 07:03:37 +03:00
shrub/pkg/hs/urbit-king/test/ClayTests.hs

29 lines
704 B
Haskell

module ClayTests (tests) where
import Urbit.Noun.Conversions
import Urbit.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 ]