summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/boundmeth1.py24
-rw-r--r--tests/basics/int_big_cmp.py10
-rw-r--r--tests/basics/int_big_error.py18
-rw-r--r--tests/basics/int_big_unary.py8
-rw-r--r--tests/float/int_big_float.py13
5 files changed, 73 insertions, 0 deletions
diff --git a/tests/basics/boundmeth1.py b/tests/basics/boundmeth1.py
new file mode 100644
index 0000000000..a728872755
--- /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 0000000000..7cb7412bdf
--- /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 0000000000..62ab936f96
--- /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 0000000000..fe6a48ac24
--- /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 0000000000..a5fb2700f8
--- /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)