Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #85 from matthewleon/simpler-test-instances
Browse files Browse the repository at this point in the history
use derived instances in tests
  • Loading branch information
garyb authored Mar 27, 2017
2 parents 2c0a3a5 + 957b073 commit 001ad45
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions test/Test/Data/Map.purs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ instance arbTestMap :: (Eq k, Ord k, Arbitrary k, Arbitrary v) => Arbitrary (Tes
arbitrary = TestMap <<< (M.fromFoldable :: List (Tuple k v) -> M.Map k v) <$> arbitrary

data SmallKey = A | B | C | D | E | F | G | H | I | J
derive instance eqSmallKey :: Eq SmallKey
derive instance ordSmallKey :: Ord SmallKey

instance showSmallKey :: Show SmallKey where
show A = "A"
Expand All @@ -36,34 +38,6 @@ instance showSmallKey :: Show SmallKey where
show I = "I"
show J = "J"

instance eqSmallKey :: Eq SmallKey where
eq A A = true
eq B B = true
eq C C = true
eq D D = true
eq E E = true
eq F F = true
eq G G = true
eq H H = true
eq I I = true
eq J J = true
eq _ _ = false

smallKeyToInt :: SmallKey -> Int
smallKeyToInt A = 0
smallKeyToInt B = 1
smallKeyToInt C = 2
smallKeyToInt D = 3
smallKeyToInt E = 4
smallKeyToInt F = 5
smallKeyToInt G = 6
smallKeyToInt H = 7
smallKeyToInt I = 8
smallKeyToInt J = 9

instance ordSmallKey :: Ord SmallKey where
compare = compare `on` smallKeyToInt

instance arbSmallKey :: Arbitrary SmallKey where
arbitrary = do
n <- arbitrary
Expand Down

0 comments on commit 001ad45

Please sign in to comment.