Exemplo n.º 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(""))))
Exemplo n.º 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 = a.descr_intersection(space, [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 = a.descr_intersection(space, [d, c, b])
        assert space.is_true(
            self.space.eq(result, W_SetObject(space, self.space.wrap(""))))
Exemplo n.º 3
0
 def test_intersection(self):
     s1 = W_SetObject(self.space, self.wrapped([1, 2, 3, 4, 5]))
     s2 = W_SetObject(self.space, self.wrapped([4, 5, "six", "seven"]))
     s3 = s1.intersect(s2)
     skip(
         "for now intersection with ObjectStrategy always results in another ObjectStrategy"
     )
     assert s3.strategy is self.space.fromcache(IntegerSetStrategy)
Exemplo n.º 4
0
 def test_intersection(self):
     s1 = W_SetObject(self.space, self.wrapped([1, 2, 3, 4, 5]))
     s2 = W_SetObject(self.space, self.wrapped([4, 5, "six", "seven"]))
     s3 = s1.intersect(s2)
     skip("for now intersection with ObjectStrategy always results in another ObjectStrategy")
     assert s3.strategy is self.space.fromcache(IntegerSetStrategy)