def test_empty(self): vm = VM() vm.push(10) stack.new(vm) vm.dup0() stack.isempty(vm) self.assertTrue(vm.stack[0]) vm.pop() stack.push(vm) stack.isempty(vm) self.assertFalse(vm.stack[0])
def test_compress_aux(self): vm = VM() vm.aux_stack.items = list(range(93)) stack_manip.compress_aux(vm) vm2 = VM() stack.new(vm2) for i in range(93): vm2.push(i) stack.push(vm2) self.assertEqual(vm.stack[:], vm2.stack[:])
def test_simple(self): vm = VM() stack.new(vm) for val in range(200): vm.push(val) vm.swap1() stack.push(vm) for val in range(199, -1, -1): stack.pop(vm) self.assertEqual(vm.stack[0], val) vm.pop()