def test_right(self): expected = 3 zipper = Zipper().insert(1).right with self.assertRaises(ValueError): zipper.value zipper = zipper.insert(expected) self.assertEqual(zipper.value, expected)
def test_left(self): expected = 2 zipper = Zipper().insert(1).left with self.assertRaises(ValueError): zipper.value actual = zipper.insert(expected).value self.assertEqual(actual, expected)
def test_immutability_move_insert(self): z = Zipper().insert(1).right().insert(4).up().left().insert(2).left().insert(3).left() z_2 = z.insert(5) z_3 = z.insert(7) self.assertIs((z.focus is None), True) self.assertEqual(z.up().value(), 3) self.assertNotEqual(z_2.value(), z_3.value())
def test_insert_non_mutating(self): zipper = Zipper() zipper.insert(1) with self.assertRaises(ValueError): zipper.value