def test_normalize(): # this should be 0 z = Z.cons(pos=Nat(1), neg=Nat(1)) # we normalize it assert z.normalize() == Z(0) z = Z.cons(pos=Nat(1), neg=Nat(0)) assert z.normalize() == Z(1) z = Z.cons(pos=Nat(0), neg=Nat(1)) assert z.normalize() == Z(-1)
def test_generator(): # because the Z.zero == Z.cons(pos=Nat(0), neg=Nat(0)) assert Z.zero()._generator == Z.cons assert Z.cons(pos=Nat(0), neg=Nat(0))._generator == Z.cons
def test_constructor(): assert Z(0) == Z.cons(pos=Nat(0), neg=Nat(0)) assert Z(1) == Z.cons(pos=Nat(1), neg=Nat(0)) assert Z(-1) == Z.cons(pos=Nat(0), neg=Nat(1))