From 086a7616ddd1736e064aab70bf5126bf24988a45 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Tue, 3 Mar 2015 16:45:39 +0000
Subject: [PATCH] tests: Add tests for boundmeth; and bignum cmp, unary, float,
 error.

---
 tests/basics/boundmeth1.py    | 24 ++++++++++++++++++++++++
 tests/basics/int_big_cmp.py   | 10 ++++++++++
 tests/basics/int_big_error.py | 18 ++++++++++++++++++
 tests/basics/int_big_unary.py |  8 ++++++++
 tests/float/int_big_float.py  | 13 +++++++++++++
 5 files changed, 73 insertions(+)
 create mode 100644 tests/basics/boundmeth1.py
 create mode 100644 tests/basics/int_big_cmp.py
 create mode 100644 tests/basics/int_big_error.py
 create mode 100644 tests/basics/int_big_unary.py
 create mode 100644 tests/float/int_big_float.py

diff --git a/tests/basics/boundmeth1.py b/tests/basics/boundmeth1.py
new file mode 100644
index 000000000..a72887275
--- /dev/null
+++ b/tests/basics/boundmeth1.py
@@ -0,0 +1,24 @@
+# tests basics of bound methods
+
+# uPy and CPython differ when printing a bound method, so just print the type
+print(type(repr([].append)))
+
+class A:
+    def f(self):
+        return 0
+    def g(self, a):
+        return a
+    def h(self, a, b, c, d, e, f):
+        return a + b + c + d + e + f
+
+# bound method with no extra args
+m = A().f
+print(m())
+
+# bound method with 1 extra arg
+m = A().g
+print(m(1))
+
+# bound method with lots of extra args
+m = A().h
+print(m(1, 2, 3, 4, 5, 6))
diff --git a/tests/basics/int_big_cmp.py b/tests/basics/int_big_cmp.py
new file mode 100644
index 000000000..7cb7412bd
--- /dev/null
+++ b/tests/basics/int_big_cmp.py
@@ -0,0 +1,10 @@
+# test bignum comparisons
+
+i = 1 << 65
+
+print(i == 0)
+print(i != 0)
+print(i < 0)
+print(i > 0)
+print(i <= 0)
+print(i >= 0)
diff --git a/tests/basics/int_big_error.py b/tests/basics/int_big_error.py
new file mode 100644
index 000000000..62ab936f9
--- /dev/null
+++ b/tests/basics/int_big_error.py
@@ -0,0 +1,18 @@
+# test errors operating on bignum
+
+i = 1 << 65
+
+try:
+    i << -1
+except ValueError:
+    print("ValueError")
+
+try:
+    len(i)
+except TypeError:
+    print("TypeError")
+
+try:
+    1 in i
+except TypeError:
+    print("TypeError")
diff --git a/tests/basics/int_big_unary.py b/tests/basics/int_big_unary.py
new file mode 100644
index 000000000..fe6a48ac2
--- /dev/null
+++ b/tests/basics/int_big_unary.py
@@ -0,0 +1,8 @@
+# test bignum unary operations
+
+i = 1 << 65
+
+print(bool(i))
+print(+i)
+print(-i)
+print(~i)
diff --git a/tests/float/int_big_float.py b/tests/float/int_big_float.py
new file mode 100644
index 000000000..a5fb2700f
--- /dev/null
+++ b/tests/float/int_big_float.py
@@ -0,0 +1,13 @@
+# test bignum operation with float/complex
+
+i = 1 << 65
+
+# this should convert to float
+print("%.5g" % (i / 5))
+
+# these should delegate to float
+print("%.5g" % (i * 1.2))
+print("%.5g" % (i / 1.2))
+
+# this should delegate to complex
+print("%.5g" % (i * 1.2j).imag)
-- 
GitLab