예제 #1
0
    def test_maybe_interface(self):
        maybe = Maybe()
        FunctorLaws.validate(Maybe)
        ApplicativeLaws.validate(Maybe)
        MonadLaws.validate(Maybe)

        self.assertEquals(Maybe.unit(1), Something(1))
        self.assertRaises(NotImplementedError, lambda: maybe.get())
        self.assertRaises(NotImplementedError, lambda: maybe.get_or_else(None))
예제 #2
0
    def test_either_interface(self):
        either = Either()
        FunctorLaws.validate(Either)
        ApplicativeLaws.validate(Either)
        MonadLaws.validate(Either)

        self.assertEqual(Either.unit(2), Success(2))
        self.assertRaises(NotImplementedError, lambda: either.is_error())
        self.assertRaises(NotImplementedError, lambda: either.left())
        self.assertRaises(NotImplementedError, lambda: either.right())
예제 #3
0
 def test_list_interface(self):
     FunctorLaws.validate(List)
     ApplicativeLaws.validate(List)
     MonadLaws.validate(List)