on master help sign in
Add lens tests
commit483aebf0249a2b71d970b0f6eaff4a343df4aab5 authorDenis Redozubov <denis.redozubov@gmail.com> dateWed 23 Aug 2017, 12:24 (9 years ago) parente93ff8f
1 file changed+10−4
test/LensSpec.hs+10−4
test/LensSpec.hs+10−4
@@ -33,14 +33,20 @@ exampleData = ReprObject objectData
3333
3434spec :: Spec
3535spec = do
36+ let
37+ newFooVal = FieldRepr $ ReprArray [ReprNumber 15]
38+ fooProxy = Proxy @"foo"
3639 it "gets the field from an object" $ do
37− fget (Proxy :: Proxy "foo") objectData == arrayField
38− -- it "sets the object field" $ do
39− -- fset (FieldRepr :: FieldRepr '("foo", ArrayField))
40+ fget fooProxy objectData == arrayField
41+ it "sets the object field" $ do
42+ fget fooProxy (fput newFooVal objectData) == newFooVal
4043
4144 describe "(using lens library) " $ do
4245 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
4450
4551main :: IO ()
4652main = hspec spec