Test gmpy2MPY2 Addition
===================

Test all code in the file gmpy2_add.c.

>>> import gmpy2 as gmpy2
>>> from gmpy2 import mpz, xmpz, mpq, mpfr, mpc
>>> from decimal import Decimal as D
>>> from fractions import Fraction as F
>>> a = mpz(123)
>>> b = mpz(456)
>>> c = 12345678901234567890

Test integer operations
-----------------------

>>> a+1
mpz(124)
>>> a+(-1)
mpz(122)
>>> 1+a
mpz(124)
>>> (-1)+a
mpz(122)

>>> print(a+c)
12345678901234568013
>>> print(c+a)
12345678901234568013
>>> print(a+(-c))
-12345678901234567767
>>> print((-c)+a)
-12345678901234567767

>>> a+b
mpz(579)
>>> b+a
mpz(579)
>>> a+(-b)
mpz(-333)
>>> (-b)+a
mpz(-333)

>>> ctx=gmpy2.context()
>>> ctx.add(a,b) == a+b
True
>>> ctx.add(c,c) == c+c
True
>>> ctx.add(1, 1)
mpz(2)
>>> ctx.add(a, 1)
mpz(124)
>>> ctx.add(1, a)
mpz(124)
>>> ctx.add(a, mpq(0))
mpq(123,1)
>>> ctx.add(a, mpfr(0))
mpfr('123.0')
>>> ctx.add(a, mpc(0))
mpc('123.0+0.0j')
>>> ctx.add(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ** message detail varies **
>>> ctx.add(1,2,3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ** message detail varies **

>>> gmpy2.add(1,1)
mpz(2)

>>> a+'b'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ** message detail varies **
>>> 'b'+a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ** message detail varies **

Test rational operations
------------------------

>>> mpq(1,2) + F(3,2)
mpq(2,1)
>>> F(1,2) + mpq(3,2)
mpq(2,1)
>>> mpq(1,2) + mpq(3,2)
mpq(2,1)
>>> mpq(1,2) + 0
mpq(1,2)
>>> mpq(1,2) + mpz(1)
mpq(3,2)
>>> mpq(1,2) + (-1)
mpq(-1,2)
>>> 1 + mpq(1,2)
mpq(3,2)
>>> mpz(1) + mpq(1,2)
mpq(3,2)
>>> mpq(1,2) + mpz(1)
mpq(3,2)
>>> mpq(1,1) + mpc(0)
mpc('1.0+0.0j')
>>> mpc(0) + mpq(1,1)
mpc('1.0+0.0j')

>>> ctx=gmpy2.context()
>>> ctx.add(mpq(1,2), mpq(3,2))
mpq(2,1)
>>> ctx.add(mpq(1,2), F(3,2))
mpq(2,1)
>>> ctx.add(F(1,2), mpq(3,2))
mpq(2,1)
>>> ctx.add(F(1,2), F(3,2))
mpq(2,1)
>>> ctx.add(1,'a')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ** message detail varies **

>>> mpq(1,2) + 'a'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ** message detail varies **
>>> 'a' + mpq(1,2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ** message detail varies **

Test real operations
--------------------

>>> mpfr(1) + 1
mpfr('2.0')
>>> 1 + mpfr(1)
mpfr('2.0')
>>> mpfr(1) + mpz(1)
mpfr('2.0')
>>> mpz(1) + mpfr(1)
mpfr('2.0')
>>> mpfr(1) + mpfr(1)
mpfr('2.0')
>>> mpfr(1) + mpq(1,1)
mpfr('2.0')
>>> mpq(1,1) + mpfr(1)
mpfr('2.0')
>>> mpfr(1) + F(1,1)
mpfr('2.0')
>>> F(1,1) + mpfr(1)
mpfr('2.0')
>>> mpfr(1) + 1.0
mpfr('2.0')
>>> 1.0 + mpfr(1)
mpfr('2.0')
>>> mpfr(0) + (1 << 100) == mpfr('1p100', base=2)
True
>>> (1 << 100) + mpfr(0) == mpfr('1p100', base=2)
True

Test complex operations
-----------------------
>>> mpc(1,2) + 'a'
Traceback (most recent call last):
  ...
TypeError:
>>> mpfr(1) + mpc(1,2)
mpc('2.0+2.0j')
>>> mpc(1,2) + mpfr(1)
mpc('2.0+2.0j')
>>> mpc(1,2) + 1+0j
mpc('2.0+2.0j')
>>> 1+0j + mpc(1,2)
mpc('2.0+2.0j')
