Example #1
0
    def test_intersection_order(self):
        # theses tests make sure that intersection is done in the correct order
        # (smallest first)
        space = self.space
        a = W_SetObject(self.space)
        _initialize_set(self.space, a, self.space.wrap("abcdefg"))
        a.intersect = None

        b = W_SetObject(self.space)
        _initialize_set(self.space, b, self.space.wrap("abc"))

        result = set_intersection__Set(space, a, [b])
        assert space.is_true(self.space.eq(result, W_SetObject(space, self.space.wrap("abc"))))

        c = W_SetObject(self.space)
        _initialize_set(self.space, c, self.space.wrap("e"))

        d = W_SetObject(self.space)
        _initialize_set(self.space, d, self.space.wrap("ab"))

        # if ordering works correct we should start with set e
        a.get_storage_copy = None
        b.get_storage_copy = None
        d.get_storage_copy = None

        result = set_intersection__Set(space, a, [d,c,b])
        assert space.is_true(self.space.eq(result, W_SetObject(space, self.space.wrap(""))))
Example #2
0
    def test_intersection_order(self):
        # theses tests make sure that intersection is done in the correct order
        # (smallest first)
        space = self.space
        a = W_SetObject(self.space)
        _initialize_set(self.space, a, self.space.wrap("abcdefg"))
        a.intersect = None

        b = W_SetObject(self.space)
        _initialize_set(self.space, b, self.space.wrap("abc"))

        result = set_intersection__Set(space, a, [b])
        assert space.is_true(self.space.eq(result, W_SetObject(space, self.space.wrap("abc"))))

        c = W_SetObject(self.space)
        _initialize_set(self.space, c, self.space.wrap("e"))

        d = W_SetObject(self.space)
        _initialize_set(self.space, d, self.space.wrap("ab"))

        # if ordering works correct we should start with set e
        a.get_storage_copy = None
        b.get_storage_copy = None
        d.get_storage_copy = None

        result = set_intersection__Set(space, a, [d,c,b])
        assert space.is_true(self.space.eq(result, W_SetObject(space, self.space.wrap(""))))
Example #3
0
 def test_and(self):
     s = W_SetObject(self.space)
     _initialize_set(self.space, s, self.word)
     t0 = W_SetObject(self.space)
     _initialize_set(self.space, t0, self.otherword)
     t1 = W_FrozensetObject(self.space, self.otherword)
     r0 = and__Set_Set(self.space, s, t0)
     r1 = and__Set_Set(self.space, s, t1)
     assert eq__Set_Set(self.space, r0, r1) == self.true
     sr = set_intersection__Set(self.space, s, [self.otherword])
     assert eq__Set_Set(self.space, r0, sr) == self.true
Example #4
0
 def test_and(self):
     s = W_SetObject(self.space)
     _initialize_set(self.space, s, self.word)
     t0 = W_SetObject(self.space)
     _initialize_set(self.space, t0, self.otherword)
     t1 = W_FrozensetObject(self.space, self.otherword)
     r0 = and__Set_Set(self.space, s, t0)
     r1 = and__Set_Set(self.space, s, t1)
     assert eq__Set_Set(self.space, r0, r1) == self.true
     sr = set_intersection__Set(self.space, s, [self.otherword])
     assert eq__Set_Set(self.space, r0, sr) == self.true