on master help sign in
Add lens tests
483aebfDenis Redozubov
test/LensSpec.hs+10−4
@@ -33,14 +33,20 @@ exampleData = ReprObject objectData
33
33
34spec :: Spec
34spec :: Spec
35spec = do
35spec = do
36+ let
37+ newFooVal = FieldRepr $ ReprArray [ReprNumber 15]
38+ fooProxy = Proxy @"foo"
36 it "gets the field from an object" $ do
39 it "gets the field from an object" $ do
37− fget (Proxy :: Proxy "foo") objectData == arrayField
40+ fget fooProxy objectData == arrayField
38− -- it "sets the object field" $ do
41+ it "sets the object field" $ do
39− -- fset (FieldRepr :: FieldRepr '("foo", ArrayField))
42+ fget fooProxy (fput newFooVal objectData) == newFooVal
40
43
41 describe "(using lens library) " $ do
44 describe "(using lens library) " $ do
42 it "get the field from an object" $ do
45 it "get the field from an object" $ do
43− objectData ^. (flens (Proxy :: Proxy "foo")) == arrayField
46+ objectData ^. flens (Proxy @"foo") == arrayField
47+ it "sets the object field" $ do
48+ set (flens (Proxy @"foo")) newFooVal objectData ^. flens (Proxy @"foo")
49+ == newFooVal
44
50
45main :: IO ()
51main :: IO ()
46main = hspec spec
52main = hspec spec