Пример #1
0
 def test_array_set_uninitialized_dynamic_instance():
     import pint,ptype
     class blah(parray.type):
         def _object_(self):
             length = 0 if len(self.value) == 0 else (self.value[-1].length+1)%4
             return ptype.clone(pint.uint_t,length=length)
         length = 4
     a = blah()
     a.set((pint.uint8_t().set(2),pint.uint8_t().set(2),pint.uint8_t().set(2),pint.uint8_t().set(2)))
     if sum(x.int() for x in a) == 8:
         raise Success
Пример #2
0
    def test_array_set_uninitialized_dynamic_instance():
        import pint, ptype

        class blah(parray.type):
            def _object_(self):
                length = 0 if len(
                    self.value) == 0 else (self.value[-1].length + 1) % 4
                return ptype.clone(pint.uint_t, length=length)

            length = 4

        a = blah()
        a.set((pint.uint8_t().set(2), pint.uint8_t().set(2),
               pint.uint8_t().set(2), pint.uint8_t().set(2)))
        if sum(x.int() for x in a) == 8:
            raise Success
Пример #3
0
 def test_array_alloc_instance():
     import pint,ptype
     class blah(parray.type):
         _object_ = pint.uint32_t
         length = 4
     a = blah().alloc([pint.uint8_t().set(i) for i in range(4)])
     if all(x.size() == 1 for x in a) and sum(x.int() for x in a) == 6:
         raise Success
Пример #4
0
    def test_array_alloc_instance():
        import pint, ptype

        class blah(parray.type):
            _object_ = pint.uint32_t
            length = 4

        a = blah().alloc([pint.uint8_t().set(i) for i in range(4)])
        if all(x.size() == 1 for x in a) and sum(x.int() for x in a) == 6:
            raise Success