summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/builtin_round.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-10-31 11:28:50 +0000
committerDamien George <damien.p.george@gmail.com>2014-10-31 11:28:50 +0000
commit1559a978100762efd84666befd134d5975ae8d4b (patch)
treeb5910a620f1532ae722b865c1f71988e3f4d1e1c /tests/basics/builtin_round.py
parentfa73c9cb25f05ffa6df4c5d15cc754885c3415ff (diff)
downloadmicropython-1559a978100762efd84666befd134d5975ae8d4b.tar.gz
micropython-1559a978100762efd84666befd134d5975ae8d4b.zip
py: Add builtin round function.
Addresses issue #934.
Diffstat (limited to 'tests/basics/builtin_round.py')
-rw-r--r--tests/basics/builtin_round.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/basics/builtin_round.py b/tests/basics/builtin_round.py
new file mode 100644
index 0000000000..5ced0c4cd3
--- /dev/null
+++ b/tests/basics/builtin_round.py
@@ -0,0 +1,14 @@
+# test round()
+
+# check basic cases
+tests = [
+ False, True,
+ 0, 1, -1, 10,
+ 0.0, 1.0, 0.1, -0.1, 123.4, 123.6, -123.4, -123.6
+]
+for t in tests:
+ print(round(t))
+
+# check .5 cases
+for i in range(11):
+ print(round((i - 5) / 2))