From f256cfef4f67c0a79141194b0a28dfa2a21b1110 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 14 Mar 2015 22:56:02 +0000 Subject: [PATCH] tests: Add some more tests for complex numbers and ure module. --- tests/extmod/ure1.py | 6 ++++++ tests/float/complex1.py | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/extmod/ure1.py b/tests/extmod/ure1.py index 1501a5264e..39e84d51ea 100644 --- a/tests/extmod/ure1.py +++ b/tests/extmod/ure1.py @@ -56,3 +56,9 @@ print(m.group(0)) m = re.search("w.r", "hello world") print(m.group(0)) + +m = re.match('a+?', 'ab'); print(m.group(0)) +m = re.match('a*?', 'ab'); print(m.group(0)) +m = re.match('^ab$', 'ab'); print(m.group(0)) +m = re.match('a|b', 'b'); print(m.group(0)) +m = re.match('a|b|c', 'c'); print(m.group(0)) diff --git a/tests/float/complex1.py b/tests/float/complex1.py index 4cf7a25f6d..6cfbff61bc 100644 --- a/tests/float/complex1.py +++ b/tests/float/complex1.py @@ -13,7 +13,7 @@ print(complex(1j, 2j)) # unary ops print(bool(1j)) print(+(1j)) -#print(-(1j)) uPy doesn't print correctly +print(-(1 + 2j)) # binary ops print(1j + 2) @@ -23,10 +23,10 @@ print(1j - 2j) print(1j * 2) print(1j * 2j) print(1j / 2) -#print(1j / 2j) uPy doesn't print correctly -#print(1j ** 2) uPy doesn't print correctly -#print(1j ** 2j) uPy doesn't print correctly +print(1j / (1 + 2j)) +ans = 1j ** 2.5; print("%.5g %.5g" % (ans.real, ans.imag)) +ans = 1j ** 2.5j; print("%.5g %.5g" % (ans.real, ans.imag)) # builtin abs print(abs(1j)) -print(abs(1j + 2)) +print("%.5g" % abs(1j + 2))