def testLogic(self):
    
        x = 0 or None
        self.assertEqual(x, None, "0 or None should be None not %s" % repr(x) )

        x = None and None
        self.assertEqual(x, None, "None or None should be None not %s" % repr(x) )

        x = False or None
        self.assertEqual(x, None, "False or None should be None not %s" % repr(x) )

        self.assertTrue((1 or 2) is 1, "(1 or 2) is 1")
        self.assertTrue((0 or 2) is 2, "(0 or 2) is 2")
        self.assertTrue((False or 0) is 0, "(False or 0) is 0")
        self.assertTrue((0 or False) is False, "(0 or False) is False")
        self.assertTrue((0 and 2) is 0, "(0 and 2) is 0")
        self.assertTrue((1 and 2) is 2, "(1 and 2) is 2")
        self.assertTrue((2 and 1) is 1, "(2 and 1) is 1")
        self.assertTrue(([] and 2) == [], "([] and 2) == []")
        try:
            self.assertTrue(({} and 2) == {}, "({} and 2) == {}")
        except:
            self.fail("Unexpected error on '({} and 2) == {}'")
        try:
            self.assertTrue((0 or False or {} or []) == [], "((0 or False or {} or []) == []")
        except:
            self.fail("Unexpected error on '(0 or False or {} or []) == []'")
        f = None
        try:
            self.assertTrue((f and f.test()) == None, "(f and f.test()) == None")
        except:
            self.fail("Unexpected error on '(f and f.test()) == None'")

        self.assertTrue(bool(None) is False, "bool(None) is False")
        self.assertTrue(bool(False) is False, "bool(False) is False")
        self.assertTrue(bool(0) is False, "bool(0) is False")
        self.assertTrue(bool(0.0) is False, "bool(0.0) is False")
        self.assertTrue(bool('') is False, "bool('') is False")
        self.assertTrue(bool([]) is False, "bool('') is False")
        self.assertTrue(bool({}) is False, "bool('') is False")

        self.assertTrue(not None is True, "not None is True")
        self.assertTrue(not False is True, "not False is True")
        self.assertTrue(not 0 is True, "not 0 is True")
        self.assertTrue(not 0.0 is True, "not 0.0 is True")
        self.assertTrue(not '' is True, "not '' is True")
        self.assertTrue(not [] is True, "not '' is True")
        self.assertTrue(not {} is True, "not '' is True")

        self.assertTrue(bool(1) is True, "bool('') is True")
        self.assertTrue(bool(1.0) is True, "bool('') is True")
        self.assertTrue(bool('a') is True, "bool('') is True")
        self.assertTrue(bool([1]) is True, "bool('') is True")
        self.assertTrue(bool({'a':1}) is True, "bool('') is True")

        self.assertTrue(not 1 is False, "not '' is False")
        self.assertTrue(not 1.0 is False, "not '' is False")
        self.assertTrue(not 'a' is False, "not '' is False")
        self.assertTrue(not [1] is False, "not '' is False")
        self.assertTrue(not {'a':1} is False, "not '' is False")


        d = {'hello': 5}
        d2 = d or {}
        try:
            tst = d == d2
            self.assertTrue(tst, "#297 -non-empty object or {} should return the object")
        except __HOLE__:
            self.fail("#297 TypeError should not have been thrown")
            

        d = {}
        d2 = d or 5
        try:
            tst = d2 == 5
            self.assertTrue(tst, "#297 'empty object or 5' should return 5")
        except TypeError:
            self.fail("#297 TypeError should not have been thrown")
dataset/ETHPy150Open anandology/pyjamas/examples/libtest/BoolTest.py/BoolTest.testLogic