diff options
author | Damien George <damien.p.george@gmail.com> | 2015-04-04 23:16:22 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-04-04 23:16:22 +0100 |
commit | 97abe22963af5b62656cef5a46c195215f75f7d2 (patch) | |
tree | 40929dd2cac2ee1e03af4edd5d3fb870f9ac989f /tests/float/complex1.py | |
parent | 9dd36404646f857c4f250537bac0d9a8ad041d25 (diff) | |
download | micropython-97abe22963af5b62656cef5a46c195215f75f7d2.tar.gz micropython-97abe22963af5b62656cef5a46c195215f75f7d2.zip |
tests: Add tests to exercise lexer; and some more complex number tests.
Diffstat (limited to 'tests/float/complex1.py')
-rw-r--r-- | tests/float/complex1.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/float/complex1.py b/tests/float/complex1.py index 2fb95c6908..2395271090 100644 --- a/tests/float/complex1.py +++ b/tests/float/complex1.py @@ -25,10 +25,17 @@ print(1j - 2j) print(1j * 2) print(1j * 2j) print(1j / 2) +print((1j / 2j).real) print(1j / (1 + 2j)) +ans = 0j ** 0; print("%.5g %.5g" % (ans.real, ans.imag)) +ans = 0j ** 0j; print("%.5g %.5g" % (ans.real, ans.imag)) ans = 1j ** 2.5; print("%.5g %.5g" % (ans.real, ans.imag)) ans = 1j ** 2.5j; print("%.5g %.5g" % (ans.real, ans.imag)) +# comparison +print(1j == 1) +print(1j == 1j) + # builtin abs print(abs(1j)) print("%.5g" % abs(1j + 2)) @@ -44,3 +51,33 @@ try: 1j + [] except TypeError: print("TypeError") + +# unsupported unary op +try: + ~(1j) +except TypeError: + print("TypeError") + +# unsupported binary op +try: + 1j // 2 +except TypeError: + print("TypeError") + +# unsupported binary op +try: + 1j < 2j +except TypeError: + print("TypeError") + +# zero division +try: + 1j / 0 +except ZeroDivisionError: + print("ZeroDivisionError") + +# zero division via power +try: + 0j ** 1j +except ZeroDivisionError: + print("ZeroDivisionError") |