def test_create_list_from_set(self): from pypy.objspace.std.setobject import W_SetObject from pypy.objspace.std.setobject import _initialize_set space = self.space w = space.wrap w_l = W_ListObject(space, [space.wrap(1), space.wrap(2), space.wrap(3)]) w_set = W_SetObject(self.space) _initialize_set(self.space, w_set, w_l) w_set.iter = None # make sure fast path is used w_l2 = W_ListObject(space, []) space.call_method(w_l2, "__init__", w_set) w_l2.sort(False) assert space.eq_w(w_l, w_l2) w_l = W_ListObject(space, [space.wrap("a"), space.wrap("b"), space.wrap("c")]) _initialize_set(self.space, w_set, w_l) space.call_method(w_l2, "__init__", w_set) w_l2.sort(False) assert space.eq_w(w_l, w_l2)
def test_create_list_from_set(self): from pypy.objspace.std.setobject import W_SetObject from pypy.objspace.std.setobject import _initialize_set space = self.space w = space.wrap w_l = W_ListObject( space, [space.wrap(1), space.wrap(2), space.wrap(3)]) w_set = W_SetObject(self.space) _initialize_set(self.space, w_set, w_l) w_set.iter = None # make sure fast path is used w_l2 = W_ListObject(space, []) space.call_method(w_l2, "__init__", w_set) w_l2.sort(False) assert space.eq_w(w_l, w_l2) w_l = W_ListObject(space, [space.wrap("a"), space.wrap("b"), space.wrap("c")]) _initialize_set(self.space, w_set, w_l) space.call_method(w_l2, "__init__", w_set) w_l2.sort(False) assert space.eq_w(w_l, w_l2)
def test_int_or_float_sort(self): space = self.space w_l = W_ListObject(space, [space.wrap(1.2), space.wrap(1), space.wrap(1.0), space.wrap(5)]) w_l.sort(False) assert [(type(x), x) for x in space.unwrap(w_l)] == [ (int, 1), (float, 1.0), (float, 1.2), (int, 5)] w_l.sort(True) assert [(type(x), x) for x in space.unwrap(w_l)] == [ (int, 5), (float, 1.2), (int, 1), (float, 1.0)]