def test_insert_on_long_tuple(self): foo = PythonList([ 4, 6, 8 ]) get_manager(foo).add_composite_type( UniversalLupleType( [ IntegerType(), IntegerType() ], IntegerType() ) ) foo.insert(0, 2) self.assertEqual(list(foo), [ 2, 4, 6, 8 ])
def test_insert_at_start(self): foo = PythonList([ 4, 6, 8 ]) get_manager(foo).add_composite_type(UniversalListType(IntegerType())) foo.insert(0, 2) self.assertEqual(list(foo), [ 2, 4, 6, 8 ])
def test_sparse_list_inserting(self): foo = PythonList([ 4, 6, 8 ], is_sparse=True) get_manager(foo).add_composite_type(UniversalListType(IntegerType(), is_sparse=True)) foo.insert(4, 12) self.assertEqual(list(foo), [ 4, 6, 8, SPARSE_ELEMENT, 12 ])
def test_insert_with_wrong_type_blocked(self): foo = PythonList([ 4, 6, 8 ]) get_manager(foo).add_composite_type(UniversalListType(IntegerType())) with self.assertRaises(Exception): foo.insert(0, "hello")