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

Commit 001ad45

Browse files
authored
Merge pull request #85 from matthewleon/simpler-test-instances
use derived instances in tests
2 parents 2c0a3a5 + 957b073 commit 001ad45

File tree

1 file changed

+2
-28
lines changed

1 file changed

+2
-28
lines changed

test/Test/Data/Map.purs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ instance arbTestMap :: (Eq k, Ord k, Arbitrary k, Arbitrary v) => Arbitrary (Tes
2323
arbitrary = TestMap <<< (M.fromFoldable :: List (Tuple k v) -> M.Map k v) <$> arbitrary
2424

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

2729
instance showSmallKey :: Show SmallKey where
2830
show A = "A"
@@ -36,34 +38,6 @@ instance showSmallKey :: Show SmallKey where
3638
show I = "I"
3739
show J = "J"
3840

39-
instance eqSmallKey :: Eq SmallKey where
40-
eq A A = true
41-
eq B B = true
42-
eq C C = true
43-
eq D D = true
44-
eq E E = true
45-
eq F F = true
46-
eq G G = true
47-
eq H H = true
48-
eq I I = true
49-
eq J J = true
50-
eq _ _ = false
51-
52-
smallKeyToInt :: SmallKey -> Int
53-
smallKeyToInt A = 0
54-
smallKeyToInt B = 1
55-
smallKeyToInt C = 2
56-
smallKeyToInt D = 3
57-
smallKeyToInt E = 4
58-
smallKeyToInt F = 5
59-
smallKeyToInt G = 6
60-
smallKeyToInt H = 7
61-
smallKeyToInt I = 8
62-
smallKeyToInt J = 9
63-
64-
instance ordSmallKey :: Ord SmallKey where
65-
compare = compare `on` smallKeyToInt
66-
6741
instance arbSmallKey :: Arbitrary SmallKey where
6842
arbitrary = do
6943
n <- arbitrary

0 commit comments

Comments
 (0)