예제 #1
0
 def test_has_instance(self):
     from typecheck import Typeclass
     
     tc = Typeclass(list, tuple)
     
     assert tc.has_instance(list)
     assert tc.has_instance(tuple)
     assert not tc.has_instance(set)
     
     tc.add_instance(set)
     
     assert tc.has_instance(set)
예제 #2
0
    def test_has_instance(self):
        from typecheck import Typeclass

        tc = Typeclass(list, tuple)

        assert tc.has_instance(list)
        assert tc.has_instance(tuple)
        assert not tc.has_instance(set)

        tc.add_instance(set)

        assert tc.has_instance(set)
예제 #3
0
    def test_intersect_1(self):
        # Make sure .intersect works on other Typeclass instances
        from typecheck import Typeclass

        tc_int = Typeclass(int)
        tc_flt = Typeclass(float)

        interface_int = set(tc_int.interface())
        interface_flt = set(tc_flt.interface())
        merged_intfc = interface_int.intersection(interface_flt)

        tc_int.intersect(tc_flt)

        for t in (int, float):
            assert tc_int.has_instance(t)

        for method in merged_intfc:
            assert method in tc_int.interface()
예제 #4
0
 def test_intersect_1(self):
     """
     Make sure .intersect works on other Typeclass instances
     """
     from typecheck import Typeclass
     
     tc_int = Typeclass(int)
     tc_flt = Typeclass(float)
     
     interface_int = set(tc_int.interface())
     interface_flt = set(tc_flt.interface())
     merged_intfc = interface_int.intersection(interface_flt)
     
     tc_int.intersect(tc_flt)
     
     for t in (int, float):
         assert tc_int.has_instance(t)
         
     for method in merged_intfc:
         assert method in tc_int.interface()