예제 #1
0
 def test_size(self) -> None:
     a = RArray(int_rprimitive, 9)
     assert compute_rtype_size(a) == 9 * PLATFORM_SIZE
     b = RArray(bool_rprimitive, 3)
     assert compute_rtype_size(b) == 3
예제 #2
0
 def test_assign_multi(self) -> None:
     t = RArray(object_rprimitive, 2)
     a = Register(t, 'a')
     self.registers.append(a)
     self.assert_emit(AssignMulti(a, [self.o, self.o2]),
                      """PyObject *cpy_r_a[2] = {cpy_r_o, cpy_r_o2};""")
예제 #3
0
 def test_alignment(self) -> None:
     a = RArray(int_rprimitive, 10)
     assert compute_rtype_alignment(a) == PLATFORM_SIZE
     b = RArray(bool_rprimitive, 55)
     assert compute_rtype_alignment(b) == 1
예제 #4
0
 def test_hash(self) -> None:
     assert hash(RArray(int_rprimitive,
                        10)) == hash(RArray(int_rprimitive, 10))
     assert hash(RArray(bool_rprimitive,
                        5)) == hash(RArray(bool_rprimitive, 5))
예제 #5
0
 def test_eq(self) -> None:
     a = RArray(int_rprimitive, 10)
     assert a == RArray(int_rprimitive, 10)
     assert a != RArray(bool_rprimitive, 10)
     assert a != RArray(int_rprimitive, 9)
예제 #6
0
 def test_str_conversion(self) -> None:
     a = RArray(int_rprimitive, 10)
     assert str(a) == 'int[10]'
     assert repr(a) == '<RArray <RPrimitive builtins.int>[10]>'
예제 #7
0
 def test_basics(self) -> None:
     a = RArray(int_rprimitive, 10)
     assert a.item_type == int_rprimitive
     assert a.length == 10