Ejemplo n.º 1
0
    def test_empty_to_bool(self):
        arr = Array.from_size(1)
        self.assertIsInstance(arr._strategy, _EmptyStrategy)

        arr.set_indexable_field(0, trueObject)
        self.assertIsInstance(arr._strategy, _BoolStrategy)
        self.assertEqual(trueObject, arr.get_indexable_field(0))
Ejemplo n.º 2
0
    def test_empty_to_obj(self):
        arr = Array.from_size(1)
        self.assertIsInstance(arr._strategy, _EmptyStrategy)

        arr.set_indexable_field(0, arr)
        self.assertIsInstance(arr._strategy, _ObjectStrategy)
        self.assertIs(arr, arr.get_indexable_field(0))
Ejemplo n.º 3
0
    def test_empty_to_bool(self):
        arr = Array.from_size(1)
        self.assertIsInstance(arr._strategy, _EmptyStrategy)

        arr.set_indexable_field(0, trueObject)
        self.assertIsInstance(arr._strategy, _BoolStrategy)
        self.assertEqual(trueObject, arr.get_indexable_field(0))
Ejemplo n.º 4
0
    def test_empty_to_obj(self):
        arr = Array.from_size(1)
        self.assertIsInstance(arr._strategy, _EmptyStrategy)

        arr.set_indexable_field(0, arr)
        self.assertIsInstance(arr._strategy, _ObjectStrategy)
        self.assertIs(arr, arr.get_indexable_field(0))
Ejemplo n.º 5
0
    def test_empty_to_int(self):
        arr = Array.from_size(1)
        self.assertIsInstance(arr._strategy, _EmptyStrategy)

        int_obj = Integer(42)

        arr.set_indexable_field(0, int_obj)
        self.assertIsInstance(arr._strategy, _LongStrategy)
        self.assertEqual(42, arr.get_indexable_field(0).get_embedded_integer())
Ejemplo n.º 6
0
    def test_empty_to_int(self):
        arr = Array.from_size(1)
        self.assertIsInstance(arr._strategy, _EmptyStrategy)

        int_obj = Integer(42)

        arr.set_indexable_field(0, int_obj)
        self.assertIsInstance(arr._strategy, _LongStrategy)
        self.assertEqual(42, arr.get_indexable_field(0).get_embedded_integer())
Ejemplo n.º 7
0
    def test_copy_and_extend_partially_empty(self):
        arr = Array.from_size(3)

        int_obj = Integer(42)
        arr.set_indexable_field(0, int_obj)
        self.assertIsInstance(arr._strategy, _PartiallyEmptyStrategy)
        new_arr = arr.copy_and_extend_with(int_obj)

        self.assertIsNot(arr, new_arr)
        self.assertEqual(4, new_arr.get_number_of_indexable_fields())
        self.assertIsInstance(new_arr._strategy, _PartiallyEmptyStrategy)
Ejemplo n.º 8
0
    def test_copy_and_extend_partially_empty(self):
        arr = Array.from_size(3)

        int_obj = Integer(42)
        arr.set_indexable_field(0, int_obj)
        self.assertIsInstance(arr._strategy, _PartiallyEmptyStrategy)
        new_arr = arr.copy_and_extend_with(int_obj)

        self.assertIsNot(arr, new_arr)
        self.assertEqual(4, new_arr.get_number_of_indexable_fields())
        self.assertIsInstance(new_arr._strategy, _PartiallyEmptyStrategy)
Ejemplo n.º 9
0
 def test_empty_array(self):
     arr = Array.from_size(0)
     self.assertIsInstance(arr._strategy, _EmptyStrategy)
Ejemplo n.º 10
0
 def new_array_with_length(self, length):
     return Array.from_size(length)
Ejemplo n.º 11
0
 def new_array_with_length(self, length):
     return Array.from_size(length)
Ejemplo n.º 12
0
 def test_empty_array(self):
     arr = Array.from_size(0)
     self.assertIsInstance(arr._strategy, _EmptyStrategy)