@@ -104,6 +104,10 @@ main = defaultMain $ testGroup "map-properties"
104
104
, testCase " argSet" test_argSet
105
105
, testCase " fromSet" test_fromSet
106
106
, testCase " fromArgSet" test_fromArgSet
107
+ , testCase " unsafeSet" test_unsafeSet
108
+ , testCase " unsafeSetA" test_unsafeSetA
109
+ , testCase " unsafeFromSet" test_unsafeFromSet
110
+ , testCase " unsafeFromSetA" test_unsafeFromSetA
107
111
, testCase " toList" test_toList
108
112
, testCase " fromList" test_fromList
109
113
, testCase " fromListWith" test_fromListWith
@@ -252,6 +256,10 @@ main = defaultMain $ testGroup "map-properties"
252
256
, testProperty " argSet" prop_argSet
253
257
, testProperty " fromSet" prop_fromSet
254
258
, testProperty " fromArgSet" prop_fromArgSet
259
+ , testProperty " unsafeSet" prop_unsafeSet
260
+ , testProperty " unsafeSetA" prop_unsafeSetA
261
+ , testProperty " unsafeFromSet" prop_unsafeFromSet
262
+ , testProperty " unsafeFromSetA" prop_unsafeFromSetA
255
263
, testProperty " takeWhileAntitone" prop_takeWhileAntitone
256
264
, testProperty " dropWhileAntitone" prop_dropWhileAntitone
257
265
, testProperty " spanAntitone" prop_spanAntitone
@@ -707,6 +715,26 @@ test_fromArgSet = do
707
715
fromArgSet (Set. fromList [Arg 3 " aaa" , Arg 5 " aaaaa" ]) @?= fromList [(5 ," aaaaa" ), (3 ," aaa" )]
708
716
fromArgSet Set. empty @?= (empty :: IMap )
709
717
718
+ test_unsafeSet :: Assertion
719
+ test_unsafeSet = do
720
+ unsafeSet (,) (fromList [(5 ," a" ), (3 ," b" )]) @?= Set. fromList [(5 ," a" ), (3 ," b" )]
721
+ unsafeSet undefined (empty :: UMap ) @?= (Set. empty :: Set. Set Int )
722
+
723
+ test_unsafeSetA :: Assertion
724
+ test_unsafeSetA = do
725
+ unsafeSetA (\ x y -> Just (x,y)) (fromList [(5 ," a" ), (3 ," b" )]) @?= Just (Set. fromList [(5 ," a" ), (3 ," b" )])
726
+ unsafeSetA undefined (empty :: UMap ) @?= Identity (Set. empty :: Set. Set Int )
727
+
728
+ test_unsafeFromSet :: Assertion
729
+ test_unsafeFromSet = do
730
+ unsafeFromSet (\ k -> (k+ 1 , replicate k ' a' )) (Set. fromList [2 , 4 ]) @?= fromList [(5 ," aaaa" ), (3 ," aa" )]
731
+ unsafeFromSet undefined Set. empty @?= (empty :: IMap )
732
+
733
+ test_unsafeFromSetA :: Assertion
734
+ test_unsafeFromSetA = do
735
+ unsafeFromSetA (\ k -> Just (k+ 1 , replicate k ' a' )) (Set. fromList [2 , 4 ]) @?= Just (fromList [(5 ," aaaa" ), (3 ," aa" )])
736
+ unsafeFromSetA undefined Set. empty @?= Identity (empty :: IMap )
737
+
710
738
----------------------------------------------------------------
711
739
-- Lists
712
740
@@ -1672,6 +1700,26 @@ prop_fromArgSet ys =
1672
1700
let xs = List. nubBy ((==) `on` fst ) ys
1673
1701
in fromArgSet (Set. fromList $ List. map (uncurry Arg ) xs) == fromList xs
1674
1702
1703
+ prop_unsafeSet :: [(Int , Int )] -> Bool
1704
+ prop_unsafeSet ys =
1705
+ let xs = List. nubBy ((==) `on` fst ) ys
1706
+ in unsafeSet (,) (fromList xs) == Set. fromList xs
1707
+
1708
+ prop_unsafeSetA :: [(Int , Int )] -> Bool
1709
+ prop_unsafeSetA ys =
1710
+ let xs = List. nubBy ((==) `on` fst ) ys
1711
+ in unsafeSetA (\ x y -> Identity (x,y)) (fromList xs) == Identity (Set. fromList xs)
1712
+
1713
+ prop_unsafeFromSet :: [(Int , Int )] -> Bool
1714
+ prop_unsafeFromSet ys =
1715
+ let xs = List. nubBy ((==) `on` fst ) ys
1716
+ in unsafeFromSet id (Set. fromList xs) == fromList xs
1717
+
1718
+ prop_unsafeFromSetA :: [(Int , Int )] -> Bool
1719
+ prop_unsafeFromSetA ys =
1720
+ let xs = List. nubBy ((==) `on` fst ) ys
1721
+ in unsafeFromSetA Identity (Set. fromList xs) == Identity (fromList xs)
1722
+
1675
1723
prop_eq :: Map Int A -> Map Int A -> Property
1676
1724
prop_eq m1 m2 = (m1 == m2) === (toList m1 == toList m2)
1677
1725
0 commit comments