You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 4, 2020. It is now read-only.
Since we know that all StrMap objects have prototype Object, we know
they have no additional enumerable keys, so hasOwnProperty checks are
unnecessary. Add efficient JS implementations for keys and values. Add
standard Monoid and Monad fold functions, and use them internally.
Minor other changes to eliminate unnecessary function layers and
variables. Fix and update tests.
<?> ("k1: " ++ show k1 ++ ", v1: " ++ show v1 ++ ", k2: " ++ show k2 ++ ", v2: " ++ show v2)
77
66
78
67
trace "Lookup from empty"
79
68
quickCheck $ \k ->M.lookup k (M.empty ::M.StrMapNumber) == Nothing
80
69
81
70
trace "Lookup from singleton"
82
-
quickCheck $ \k v ->M.lookup (k ::SmallKey) (M.singleton k (v ::Number)) == Just v
71
+
quickCheck $ \k v ->M.lookup k (M.singleton k (v ::Number)) == Just v
83
72
84
73
trace "Random lookup"
85
74
quickCheck' 5000 $ \instrs k v ->
@@ -94,16 +83,19 @@ strMapTests = do
94
83
trace "toList . fromList = id"
95
84
quickCheck $ \arr ->let f x = M.toList (M.fromList x)
96
85
arr' = runTestTuple <$> arr
97
-
in f (f arr') == f (arr' :: [TupleSmallKeyNumber]) <?> show arr
86
+
in f (f arr') == f (arr' :: [TupleStringNumber]) <?> show arr
98
87
99
88
trace "fromList . toList = id"
100
89
quickCheck $ \m ->let f m = M.fromList (M.toList m) in
101
90
M.toList (f m) == M.toList (m ::M.StrMapNumber) <?> show m
102
91
103
92
trace "Lookup from union"
104
-
quickCheck $ \m1 m2 k ->M.lookup (smallKey k) (M.union m1 m2) == (caseM.lookup k m1 of
93
+
quickCheck $ \m1 m2 k ->M.lookup k (M.union m1 m2) == (caseM.lookup k m1 of
105
94
Nothing->M.lookup k m2
106
95
Just v ->Just (number v)) <?> ("m1: " ++ show m1 ++ ", m2: " ++ show m2 ++ ", k: " ++ show k ++ ", v1: " ++ show (M.lookup k m1) ++ ", v2: " ++ show (M.lookup k m2) ++ ", union: " ++ show (M.union m1 m2))
0 commit comments