def _set_values_sliced(index, values): """ Given the list of values to set, decompose from words to bytes if necessary and turn into a list of no stop value provided. """ if index.start == None: raise ValueError('Slice must contain a start index') if index.stop is None: values = [values] if index.step is None or index.step == 1: pass elif index.step == 2: values = vm.from_words(values) else: raise ValueError('Invalid step: {}'.format(index.step)) stop = index.stop if index.stop is not None else index.start + index.step if stop - index.start != len(values): raise ValueError('Slice length mismatch') return values
def test_from_words(self): self.assertEquals([0x34, 0x12, 0x78, 0x56], vm.from_words([0x1234, 0x5678]))