summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-08-25 18:18:57 +0100
committerDamien George <damien.p.george@gmail.com>2015-08-29 23:13:28 +0100
commit1d350b8ac6c65bd53115bfdc7511e4028f3c69ac (patch)
treeb4f06dceff7101c8cacdb9e81b0fa30eca4f1735
parenta488c266c34f70ab6bff86b1f31f1d1a343ab1b8 (diff)
downloadmicropython-1d350b8ac6c65bd53115bfdc7511e4028f3c69ac.tar.gz
micropython-1d350b8ac6c65bd53115bfdc7511e4028f3c69ac.zip
tests: Add a few tests for bool, bytearray, float to improve coverage.
-rw-r--r--tests/basics/bool1.py6
-rw-r--r--tests/basics/bytearray1.py3
-rw-r--r--tests/basics/bytearray_add.py4
-rw-r--r--tests/float/float_divmod_relaxed.py6
4 files changed, 19 insertions, 0 deletions
diff --git a/tests/basics/bool1.py b/tests/basics/bool1.py
index 99bd837927..35d9ed8ccc 100644
--- a/tests/basics/bool1.py
+++ b/tests/basics/bool1.py
@@ -9,3 +9,9 @@ print(False or True)
# unary operators
print(+True)
print(-True)
+
+# unsupported unary op
+try:
+ len(False)
+except TypeError:
+ print('TypeError')
diff --git a/tests/basics/bytearray1.py b/tests/basics/bytearray1.py
index 76e7e59753..2e47f17bf9 100644
--- a/tests/basics/bytearray1.py
+++ b/tests/basics/bytearray1.py
@@ -27,4 +27,7 @@ print(bytearray([1]) == b"1")
print(b"1" == bytearray([1]))
print(bytearray() == bytearray())
+# comparison with other type should return False
+print(bytearray() == 1)
+
# TODO: other comparisons
diff --git a/tests/basics/bytearray_add.py b/tests/basics/bytearray_add.py
index 21a386c6e7..a7e2b57374 100644
--- a/tests/basics/bytearray_add.py
+++ b/tests/basics/bytearray_add.py
@@ -12,3 +12,7 @@ print(b)
# extend
b.extend(bytearray(4))
print(b)
+
+# this inplace add tests the code when the buffer doesn't need to be increased
+b = bytearray()
+b += b''
diff --git a/tests/float/float_divmod_relaxed.py b/tests/float/float_divmod_relaxed.py
index 7054d2ca67..a9450fa2c4 100644
--- a/tests/float/float_divmod_relaxed.py
+++ b/tests/float/float_divmod_relaxed.py
@@ -25,3 +25,9 @@ for i in range(25):
for j in range(25):
y = (j - 12.5) / 6
test(x, y)
+
+# test division by zero error
+try:
+ divmod(1.0, 0)
+except ZeroDivisionError:
+ print('ZeroDivisionError')