def test_or_else(self): self.assertEqual(EMPTY.or_else(1), 1) self.assertIsNone(Optional(None).or_else(10)) self.assertEqual(Optional(10).or_else(1), 10)
def test_present(self): self.assertFalse(EMPTY.present()) self.assertTrue(Optional(None).present()) self.assertTrue(Optional(1).present())
def test_get1(self): self.assertIsNone(Optional(None).get()) self.assertEqual(Optional(1).get(), 1)
def test_EMPTY(self): self.assertNotEqual(EMPTY, Optional(None)) self.assertNotEqual(Optional(None), EMPTY) self.assertNotEqual(EMPTY, Optional(1)) self.assertNotEqual(Optional(1), EMPTY)