summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics')
-rw-r--r--tests/basics/float1.py16
-rw-r--r--tests/basics/fun-callstar.py2
-rw-r--r--tests/basics/fun-defargs.py2
-rw-r--r--tests/basics/import-pkg1.py11
-rw-r--r--tests/basics/import-pkg2.py18
-rw-r--r--tests/basics/import-pkg3.py6
-rw-r--r--tests/basics/import-pkg4.py2
-rw-r--r--tests/basics/import-pkg5.py6
-rw-r--r--tests/basics/import1a.py2
-rw-r--r--tests/basics/import1b.py4
-rw-r--r--tests/basics/import2a.py2
-rw-r--r--tests/basics/import3a.py2
-rw-r--r--tests/basics/int-divzero.py5
-rw-r--r--tests/basics/list1.py5
-rw-r--r--tests/basics/math-fun-bool.py12
-rw-r--r--tests/basics/math-fun.py46
-rw-r--r--tests/basics/modulo.py17
-rw-r--r--tests/basics/pkg/__init__.py0
-rw-r--r--tests/basics/pkg/mod.py2
-rw-r--r--tests/basics/pkg2/__init__.py1
-rw-r--r--tests/basics/pkg2/mod1.py1
-rw-r--r--tests/basics/pkg2/mod2.py1
-rw-r--r--tests/basics/pkg3/__init__.py1
-rw-r--r--tests/basics/pkg3/mod1.py2
-rw-r--r--tests/basics/pkg3/mod2.py5
-rw-r--r--tests/basics/pkg3/subpkg1/__init__.py1
-rw-r--r--tests/basics/pkg3/subpkg1/mod1.py2
-rw-r--r--tests/basics/string-format-modulo.py14
-rw-r--r--tests/basics/string-format.py87
-rw-r--r--tests/basics/true-value.py6
-rw-r--r--tests/basics/try-module.py15
-rw-r--r--tests/basics/types1.py6
-rw-r--r--tests/basics/types2.py4
33 files changed, 5 insertions, 301 deletions
diff --git a/tests/basics/float1.py b/tests/basics/float1.py
deleted file mode 100644
index bf1305c3d5..0000000000
--- a/tests/basics/float1.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# basic float
-x = 1 / 2
-print(x)
-
-print(1.0 // 2)
-print(2.0 // 2)
-
-try:
- 1.0 / 0
-except ZeroDivisionError:
- print("ZeroDivisionError")
-
-try:
- 1.0 // 0
-except ZeroDivisionError:
- print("ZeroDivisionError")
diff --git a/tests/basics/fun-callstar.py b/tests/basics/fun-callstar.py
index e19acb3491..255563b26b 100644
--- a/tests/basics/fun-callstar.py
+++ b/tests/basics/fun-callstar.py
@@ -31,5 +31,3 @@ a.foo(1, 2, *[100])
# Iterator
a.foo(*range(3))
-
-print('flush') # so that it works on pyboard...
diff --git a/tests/basics/fun-defargs.py b/tests/basics/fun-defargs.py
index 51516c7363..0666b8c494 100644
--- a/tests/basics/fun-defargs.py
+++ b/tests/basics/fun-defargs.py
@@ -18,5 +18,3 @@ try:
fun2(1, 2, 3, 4)
except TypeError:
print("TypeError")
-
-print('flush') # so that it works on pyboard...
diff --git a/tests/basics/import-pkg1.py b/tests/basics/import-pkg1.py
deleted file mode 100644
index 8cd77af79d..0000000000
--- a/tests/basics/import-pkg1.py
+++ /dev/null
@@ -1,11 +0,0 @@
-import pkg.mod
-
-print(pkg.__name__)
-print(pkg.mod.__name__)
-print(pkg.mod.foo())
-
-# Import 2nd time, must be same module objects
-pkg_ = __import__("pkg.mod")
-print(pkg_ is not pkg.mod)
-print(pkg_ is pkg)
-print(pkg_.mod is pkg.mod)
diff --git a/tests/basics/import-pkg2.py b/tests/basics/import-pkg2.py
deleted file mode 100644
index 2e9f34121b..0000000000
--- a/tests/basics/import-pkg2.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from pkg.mod import foo
-
-try:
- pkg
-except NameError:
- print("NameError")
-try:
- pkg.mod
-except NameError:
- print("NameError")
-print(foo())
-
-# Import few times, must be same module objects
-mod_1 = __import__("pkg.mod", None, None, ("foo",))
-mod_2 = __import__("pkg.mod", None, None, ("foo",))
-print(mod_1 is mod_2)
-print(mod_1.foo is mod_2.foo)
-print(foo is mod_1.foo)
diff --git a/tests/basics/import-pkg3.py b/tests/basics/import-pkg3.py
deleted file mode 100644
index 0ee885b220..0000000000
--- a/tests/basics/import-pkg3.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from pkg import mod
-
-print(mod.foo())
-
-import pkg.mod
-print(mod is pkg.mod)
diff --git a/tests/basics/import-pkg4.py b/tests/basics/import-pkg4.py
deleted file mode 100644
index 90b6f2e0ee..0000000000
--- a/tests/basics/import-pkg4.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# Testing that "recursive" imports (pkg2/__init__.py imports from pkg2) work
-import pkg2
diff --git a/tests/basics/import-pkg5.py b/tests/basics/import-pkg5.py
deleted file mode 100644
index aa74bb45f0..0000000000
--- a/tests/basics/import-pkg5.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# This tests relative imports as used in pkg3
-import pkg3
-import pkg3.mod1
-import pkg3.subpkg1.mod1
-
-pkg3.subpkg1.mod1.foo()
diff --git a/tests/basics/import1a.py b/tests/basics/import1a.py
deleted file mode 100644
index 16b2d4d30f..0000000000
--- a/tests/basics/import1a.py
+++ /dev/null
@@ -1,2 +0,0 @@
-import import1b
-print(import1b.var)
diff --git a/tests/basics/import1b.py b/tests/basics/import1b.py
deleted file mode 100644
index be74eca094..0000000000
--- a/tests/basics/import1b.py
+++ /dev/null
@@ -1,4 +0,0 @@
-var = 123
-
-def throw():
- raise ValueError
diff --git a/tests/basics/import2a.py b/tests/basics/import2a.py
deleted file mode 100644
index ce32b10b1b..0000000000
--- a/tests/basics/import2a.py
+++ /dev/null
@@ -1,2 +0,0 @@
-from import1b import var
-print(var)
diff --git a/tests/basics/import3a.py b/tests/basics/import3a.py
deleted file mode 100644
index 2e9d41f71d..0000000000
--- a/tests/basics/import3a.py
+++ /dev/null
@@ -1,2 +0,0 @@
-from import1b import *
-print(var)
diff --git a/tests/basics/int-divzero.py b/tests/basics/int-divzero.py
index d1fc579321..28ec2a6995 100644
--- a/tests/basics/int-divzero.py
+++ b/tests/basics/int-divzero.py
@@ -1,9 +1,4 @@
try:
- 1 / 0
-except ZeroDivisionError:
- print("ZeroDivisionError")
-
-try:
1 // 0
except ZeroDivisionError:
print("ZeroDivisionError")
diff --git a/tests/basics/list1.py b/tests/basics/list1.py
index a0c8afc4f8..c8317baa3d 100644
--- a/tests/basics/list1.py
+++ b/tests/basics/list1.py
@@ -22,8 +22,3 @@ print(x)
print(x[1:])
print(x[:-1])
print(x[2:3])
-
-try:
- print(x[1.0])
-except TypeError:
- print("TypeError")
diff --git a/tests/basics/math-fun-bool.py b/tests/basics/math-fun-bool.py
deleted file mode 100644
index cf718d4b80..0000000000
--- a/tests/basics/math-fun-bool.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# Test the bool functions from math
-
-from math import isfinite, isnan, isinf
-
-test_values = [1, 0, -1, 1.0, 0.0, -1.0, float('NaN'), float('Inf'),
- -float('NaN'), -float('Inf')]
-
-functions = [isfinite, isnan, isinf]
-
-for val in test_values:
- for f in functions:
- print(f(val))
diff --git a/tests/basics/math-fun.py b/tests/basics/math-fun.py
deleted file mode 100644
index 7a37c58454..0000000000
--- a/tests/basics/math-fun.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# Tests the functions imported from math
-
-from math import *
-
-test_values = [-100., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 100.]
-p_test_values = [0.1, 0.5, 1.23456]
-unit_range_test_values = [-1., -0.75, -0.5, -0.25, 0., 0.25, 0.5, 0.75, 1.]
-
-functions = [('sqrt', sqrt, p_test_values),
- ('exp', exp, test_values),
- ('expm1', expm1, test_values),
- ('log', log, p_test_values),
- ('log2', log2, p_test_values),
- ('log10', log10, p_test_values),
- ('cosh', cosh, test_values),
- ('sinh', sinh, test_values),
- ('tanh', tanh, test_values),
- ('acosh', acosh, [1.0, 5.0, 1.0]),
- ('asinh', asinh, test_values),
- ('atanh', atanh, [-0.99, -0.5, 0.0, 0.5, 0.99]),
- ('cos', cos, test_values),
- ('sin', sin, test_values),
- ('tan', tan, test_values),
- ('acos', acos, unit_range_test_values),
- ('asin', asin, unit_range_test_values),
- ('atan', atan, test_values),
- ('ceil', ceil, test_values),
- ('fabs', fabs, test_values),
- ('floor', floor, test_values),
- #('frexp', frexp, test_values),
- ('trunc', trunc, test_values)
- ]
-
-for function_name, function, test_vals in functions:
- print(function_name)
- for value in test_vals:
- print("{:.7g}".format(function(value)))
-
-binary_functions = [('copysign', copysign, [(23., 42.), (-23., 42.), (23., -42.),
- (-23., -42.), (1., 0.0), (1., -0.0)])
- ]
-
-for function_name, function, test_vals in binary_functions:
- print(function_name)
- for value1, value2 in test_vals:
- print("{:.7g}".format(function(value1, value2)))
diff --git a/tests/basics/modulo.py b/tests/basics/modulo.py
index 4d83db6ec8..c95305d13d 100644
--- a/tests/basics/modulo.py
+++ b/tests/basics/modulo.py
@@ -1,5 +1,6 @@
# check modulo matches python definition
-# This test compiler version
+
+# this tests compiler constant folding
print(123 % 7)
print(-123 % 7)
print(123 % -7)
@@ -20,17 +21,3 @@ print(a % b)
print(a % -b)
print(-a % b)
print(-a % -b)
-
-if False:
- print(1.23456 % 0.7)
- print(-1.23456 % 0.7)
- print(1.23456 % -0.7)
- print(-1.23456 % -0.7)
-
- a = 1.23456
- b = 0.7
- print(a % b)
- print(a % -b)
- print(-a % b)
- print(-a % -b)
-
diff --git a/tests/basics/pkg/__init__.py b/tests/basics/pkg/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/tests/basics/pkg/__init__.py
+++ /dev/null
diff --git a/tests/basics/pkg/mod.py b/tests/basics/pkg/mod.py
deleted file mode 100644
index 9e67bdd291..0000000000
--- a/tests/basics/pkg/mod.py
+++ /dev/null
@@ -1,2 +0,0 @@
-def foo():
- return 42
diff --git a/tests/basics/pkg2/__init__.py b/tests/basics/pkg2/__init__.py
deleted file mode 100644
index 101ac7d400..0000000000
--- a/tests/basics/pkg2/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from pkg2 import mod1
diff --git a/tests/basics/pkg2/mod1.py b/tests/basics/pkg2/mod1.py
deleted file mode 100644
index 03754a45f6..0000000000
--- a/tests/basics/pkg2/mod1.py
+++ /dev/null
@@ -1 +0,0 @@
-from pkg2 import mod2
diff --git a/tests/basics/pkg2/mod2.py b/tests/basics/pkg2/mod2.py
deleted file mode 100644
index 97dadcde46..0000000000
--- a/tests/basics/pkg2/mod2.py
+++ /dev/null
@@ -1 +0,0 @@
-print("in mod2")
diff --git a/tests/basics/pkg3/__init__.py b/tests/basics/pkg3/__init__.py
deleted file mode 100644
index 8b92fa9967..0000000000
--- a/tests/basics/pkg3/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-print("pkg __name__:", __name__)
diff --git a/tests/basics/pkg3/mod1.py b/tests/basics/pkg3/mod1.py
deleted file mode 100644
index 28a0f5bf10..0000000000
--- a/tests/basics/pkg3/mod1.py
+++ /dev/null
@@ -1,2 +0,0 @@
-print("mod1 __name__:", __name__)
-from . import mod2
diff --git a/tests/basics/pkg3/mod2.py b/tests/basics/pkg3/mod2.py
deleted file mode 100644
index 67f43bad52..0000000000
--- a/tests/basics/pkg3/mod2.py
+++ /dev/null
@@ -1,5 +0,0 @@
-print("mod2 __name__:", __name__)
-print("in mod2")
-
-def foo():
- print("mod2.foo()")
diff --git a/tests/basics/pkg3/subpkg1/__init__.py b/tests/basics/pkg3/subpkg1/__init__.py
deleted file mode 100644
index 72b5423958..0000000000
--- a/tests/basics/pkg3/subpkg1/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-print("subpkg1 __name__:", __name__)
diff --git a/tests/basics/pkg3/subpkg1/mod1.py b/tests/basics/pkg3/subpkg1/mod1.py
deleted file mode 100644
index 7a2ae44b54..0000000000
--- a/tests/basics/pkg3/subpkg1/mod1.py
+++ /dev/null
@@ -1,2 +0,0 @@
-print("subpkg1.mod1 __name__:", __name__)
-from ..mod2 import foo
diff --git a/tests/basics/string-format-modulo.py b/tests/basics/string-format-modulo.py
index 8e58be18c8..0e2c1d1096 100644
--- a/tests/basics/string-format-modulo.py
+++ b/tests/basics/string-format-modulo.py
@@ -23,11 +23,9 @@ except TypeError:
print("%s" % True)
print("%s" % 1)
-print("%s" % 1.0)
print("%r" % True)
print("%r" % 1)
-print("%r" % 1.0)
print("%c" % 48)
print("%c" % 'a')
@@ -37,28 +35,16 @@ print("%d" % 10)
print("%+d" % 10)
print("% d" % 10)
print("%d" % -10)
-print("%d" % 1.0)
print("%d" % True)
print("%i" % -10)
-print("%i" % 1.0)
print("%i" % True)
print("%u" % -10)
-print("%u" % 1.0)
print("%u" % True)
print("%x" % 18)
-print("%x" % 18.0)
print("%o" % 18)
-print("%o" % 18.0)
print("%X" % 18)
-print("%X" % 18.0)
print("%#x" % 18)
print("%#X" % 18)
print("%#6o" % 18)
print("%#6x" % 18)
print("%#06x" % 18)
-print("%e" % 1.23456)
-print("%E" % 1.23456)
-print("%f" % 1.23456)
-print("%F" % 1.23456)
-print("%g" % 1.23456)
-print("%G" % 1.23456)
diff --git a/tests/basics/string-format.py b/tests/basics/string-format.py
index 2d6d0cc721..84ea054758 100644
--- a/tests/basics/string-format.py
+++ b/tests/basics/string-format.py
@@ -60,26 +60,6 @@ test("{:@<6d}", -123)
test("{:@=6d}", -123)
test("{:06d}", -123)
-test("{:10.4e}", 123.456)
-test("{:10.4e}", -123.456)
-test("{:10.4f}", 123.456)
-test("{:10.4f}", -123.456)
-test("{:10.4g}", 123.456)
-test("{:10.4g}", -123.456)
-test("{:e}", 100)
-test("{:f}", 200)
-test("{:g}", 300)
-
-test("{:10.4E}", 123.456)
-test("{:10.4E}", -123.456)
-test("{:10.4F}", 123.456)
-test("{:10.4F}", -123.456)
-test("{:10.4G}", 123.456)
-test("{:10.4G}", -123.456)
-
-# The following fails right now
-#test("{:10.1}", 0.0)
-
def test_fmt(conv, fill, alignment, sign, prefix, width, precision, type, arg):
fmt = '{'
if conv:
@@ -137,71 +117,4 @@ if full_tests:
for str in ('', 'a', 'bcd', 'This is a test with a longer string'):
test_fmt(conv, fill, alignment, '', '', width, '', 's', str)
-eg_nums = (0.0, -0.0, 0.1, 1.234, 12.3459, 1.23456789, 123456789.0, -0.0,
- -0.1, -1.234, -12.3459, 1e4, 1e-4, 1e5, 1e-5, 1e6, 1e-6, 1e10,
- 1e37, -1e37, 1e-37, -1e-37,
- 1.23456e8, 1.23456e7, 1.23456e6, 1.23456e5, 1.23456e4, 1.23456e3, 1.23456e2, 1.23456e1, 1.23456e0,
- 1.23456e-1, 1.23456e-2, 1.23456e-3, 1.23456e-4, 1.23456e-5, 1.23456e-6, 1.23456e-7, 1.23456e-8,
- -1.23456e8, -1.23456e7, -1.23456e6, -1.23456e5, -1.23456e4, -1.23456e3, -1.23456e2, -1.23456e1, -1.23456e0,
- -1.23456e-1, -1.23456e-2, -1.23456e-3, -1.23456e-4, -1.23456e-5, -1.23456e-6, -1.23456e-7, -1.23456e-8)
-
-if full_tests:
- for type in ('e', 'E', 'g', 'G', 'n'):
- for width in ('', '4', '6', '8', '10'):
- for alignment in ('', '<', '>', '=', '^'):
- for fill in ('', '@', '0', ' '):
- for sign in ('', '+', '-', ' '):
- for prec in ('', '1', '3', '6'):
- for num in eg_nums:
- test_fmt('', fill, alignment, sign, '', width, prec, type, num)
-
-# Note: We use 1.23459 rather than 1.2345 because '{:3f}'.format(1.2345)
-# rounds differently than print("%.3f", 1.2345);
-
-f_nums = (0.0, -0.0, 0.0001, 0.001, 0.01, 0.1, 1.0, 10.0,
- 0.0012, 0.0123, 0.1234, 1.23459, 12.3456,
- -0.0001, -0.001, -0.01, -0.1, -1.0, -10.0,
- -0.0012, -0.0123, -0.1234, -1.23459, -12.3456)
-
-if full_tests:
- for type in ('f', 'F'):
- for width in ('', '4', '6', '8', '10'):
- for alignment in ('', '<', '>', '=', '^'):
- for fill in ('', ' ', '0', '@'):
- for sign in ('', '+', '-', ' '):
- # An empty precision defaults to 6, but when uPy is
- # configured to use a float, we can only use a
- # precision of 6 with numbers less than 10 and still
- # get results that compare to CPython (which uses
- # long doubles).
- for prec in ('1', '2', '3'):
- for num in f_nums:
- test_fmt('', fill, alignment, sign, '', width, prec, type, num)
- for num in int_nums2:
- test_fmt('', fill, alignment, sign, '', width, '', type, num)
-
-pct_nums1 = (0.1, 0.58, 0.99, -0.1, -0.58, -0.99)
-pct_nums2 = (True, False, 1, 0, -1)
-
-if full_tests:
- type = '%'
- for width in ('', '4', '6', '8', '10'):
- for alignment in ('', '<', '>', '=', '^'):
- for fill in ('', ' ', '0', '@'):
- for sign in ('', '+', '-', ' '):
- # An empty precision defaults to 6, but when uPy is
- # configured to use a float, we can only use a
- # precision of 6 with numbers less than 10 and still
- # get results that compare to CPython (which uses
- # long doubles).
- for prec in ('1', '2', '3'):
- for num in pct_nums1:
- test_fmt('', fill, alignment, sign, '', width, prec, type, num)
- for num in pct_nums2:
- test_fmt('', fill, alignment, sign, '', width, '', type, num)
-
-# We don't currently test a type of '' with floats (see the detailed comment
-# in objstr.c)
-
# TODO Add tests for erroneous format strings.
-
diff --git a/tests/basics/true-value.py b/tests/basics/true-value.py
index 1dd547f326..9ec209fe82 100644
--- a/tests/basics/true-value.py
+++ b/tests/basics/true-value.py
@@ -9,12 +9,6 @@ if not None:
if not 0:
print("0")
-if not 0.0:
- print("float 0")
-
-if not 0+0j:
- print("complex 0")
-
if not "":
print("Empty string")
if "foo":
diff --git a/tests/basics/try-module.py b/tests/basics/try-module.py
deleted file mode 100644
index 03a9db15b5..0000000000
--- a/tests/basics/try-module.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# Regression test for #290 - throwing exception in another module led to
-# its namespace stick and namespace of current module not coming back.
-import import1b
-
-def func1():
- print('func1')
-
-def func2():
- try:
- import1b.throw()
- except ValueError:
- pass
- func1()
-
-func2()
diff --git a/tests/basics/types1.py b/tests/basics/types1.py
index 57b33b842b..38a20d6803 100644
--- a/tests/basics/types1.py
+++ b/tests/basics/types1.py
@@ -2,8 +2,6 @@
print(bool)
print(int)
-print(float)
-print(complex)
print(tuple)
print(list)
print(set)
@@ -11,8 +9,6 @@ print(dict)
print(type(bool()) == bool)
print(type(int()) == int)
-print(type(float()) == float)
-print(type(complex()) == complex)
print(type(tuple()) == tuple)
print(type(list()) == list)
print(type(set()) == set)
@@ -20,8 +16,6 @@ print(type(dict()) == dict)
print(type(False) == bool)
print(type(0) == int)
-print(type(0.0) == float)
-print(type(1j) == complex)
print(type(()) == tuple)
print(type([]) == list)
print(type({None}) == set)
diff --git a/tests/basics/types2.py b/tests/basics/types2.py
index 83a69c918f..ba7be6b154 100644
--- a/tests/basics/types2.py
+++ b/tests/basics/types2.py
@@ -9,4 +9,6 @@ print(int == int)
print(int != list)
d = {}
-d[int] = float
+d[int] = list
+d[list] = int
+print(len(d))