summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Shockley <benjaminshockley@hotmail.com>2020-08-20 13:48:15 -0500
committerGitHub <noreply@github.com>2020-08-20 13:48:15 -0500
commit0084f0af24e4e219bc040c52ee723959423de6e2 (patch)
tree1aebdb362f08bf6417caa87836e3e4e739afc964 /tests
parent9aebe2f1efc99871fcf283c304e3a8700050d736 (diff)
parent4d7b9cde33934a44c4c905a49d2f831339fc8bd2 (diff)
Merge pull request #2 from adafruit/master
Master
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/assign1.py1
-rw-r--r--tests/basics/bigint_array_overflow.py28
-rw-r--r--tests/basics/builtin_chr.py1
-rw-r--r--tests/basics/class_bytes.py9
-rw-r--r--tests/basics/dict1.py2
-rw-r--r--tests/basics/dict_popitem.py1
-rw-r--r--tests/basics/dict_setdefault.py2
-rw-r--r--tests/basics/exception1.py1
-rw-r--r--tests/basics/gen_yield_from.py.exp14
-rw-r--r--tests/basics/gen_yield_from_close.py.exp20
-rw-r--r--tests/basics/gen_yield_from_throw.py2
-rw-r--r--tests/basics/gen_yield_from_throw.py.exp6
-rw-r--r--tests/basics/gen_yield_from_throw2.py2
-rw-r--r--tests/basics/generator_close.py.exp10
-rw-r--r--tests/basics/generator_return.py2
-rw-r--r--tests/basics/int_big_and2.py4
-rw-r--r--tests/basics/int_big_and3.py4
-rw-r--r--tests/basics/int_big_error.py4
-rw-r--r--tests/basics/int_big_or.py8
-rw-r--r--tests/basics/int_big_or2.py4
-rw-r--r--tests/basics/int_big_or3.py4
-rw-r--r--tests/basics/int_big_xor.py8
-rw-r--r--tests/basics/int_big_xor2.py4
-rw-r--r--tests/basics/int_big_xor3.py4
-rw-r--r--tests/basics/int_bytes.py24
-rw-r--r--tests/basics/int_bytes_intbig.py18
-rw-r--r--tests/basics/int_longint_bytes.py1
-rw-r--r--tests/basics/parser.py.exp3
-rw-r--r--tests/basics/python34.py6
-rw-r--r--tests/basics/python34.py.exp1
-rw-r--r--tests/basics/set_iter.py1
-rw-r--r--tests/basics/set_pop.py2
-rw-r--r--tests/basics/smallint_array_overflow.py52
-rw-r--r--tests/basics/string_cr_conversion.py2
-rw-r--r--tests/basics/string_pep498_fstring.py113
-rw-r--r--tests/basics/string_pep498_fstring.py.exp0
-rw-r--r--tests/basics/struct_overflow.py47
-rw-r--r--tests/basics/subclass_native3.py4
-rw-r--r--tests/basics/subscr_tuple.py6
-rw-r--r--tests/basics/try_as_var.py2
-rw-r--r--tests/cmdline/cmd_parsetree.py.exp4
-rw-r--r--tests/cmdline/repl_autocomplete.py3
-rw-r--r--tests/cmdline/repl_autocomplete.py.exp6
-rw-r--r--tests/extmod/uctypes_array_assign_le.py1
-rw-r--r--tests/extmod/uctypes_byteat.py4
-rw-r--r--tests/extmod/uctypes_error.py10
-rw-r--r--tests/extmod/ujson_dump_iobase.py2
-rw-r--r--tests/extmod/ure1.py13
-rw-r--r--tests/extmod/ure_groups.py33
-rw-r--r--tests/extmod/ure_span.py40
-rw-r--r--tests/extmod/ure_sub.py61
-rw-r--r--tests/extmod/ure_sub_unmatched.py19
-rw-r--r--tests/extmod/ure_sub_unmatched.py.exp1
-rw-r--r--tests/feature_check/complex.py1
-rw-r--r--tests/float/builtin_float_minmax.py1
-rw-r--r--tests/float/float_struct.py1
-rw-r--r--tests/float/math_fun_bool.py2
-rw-r--r--tests/import/import_override.py.exp2
-rw-r--r--tests/import/mpy_invalid.py4
-rw-r--r--tests/import/mpy_invalid.py.exp6
-rw-r--r--tests/inlineasm/asmfpaddsub.py1
-rw-r--r--tests/inlineasm/asmfpldrstr.py1
-rw-r--r--tests/inlineasm/asmfpmuldiv.py1
-rw-r--r--tests/inlineasm/asmfpsqrt.py1
-rw-r--r--tests/inlineasm/asmspecialregs.py1
-rw-r--r--tests/jni/README1
-rw-r--r--tests/misc/features.py6
-rw-r--r--tests/misc/sys_exc_info.py2
-rwxr-xr-xtests/run-tests3
-rw-r--r--tests/thread/mutate_bytearray.py1
-rw-r--r--tests/unix/extra_coverage.py.exp10
-rw-r--r--tests/wipy/i2c.py1
-rw-r--r--tests/wipy/pin.py7
-rw-r--r--tests/wipy/sd.py1
-rw-r--r--tests/wipy/uart.py6
-rw-r--r--tests/wipy/wlan/wlan.py1
76 files changed, 599 insertions, 86 deletions
diff --git a/tests/basics/assign1.py b/tests/basics/assign1.py
index 118747f74..01047fa92 100644
--- a/tests/basics/assign1.py
+++ b/tests/basics/assign1.py
@@ -8,4 +8,3 @@ print(a, b)
a = b = c = 3
print(a, b, c)
-
diff --git a/tests/basics/bigint_array_overflow.py b/tests/basics/bigint_array_overflow.py
new file mode 100644
index 000000000..0dd79c23d
--- /dev/null
+++ b/tests/basics/bigint_array_overflow.py
@@ -0,0 +1,28 @@
+import skip_if
+skip_if.no_bigint()
+
+try:
+ from array import array
+except ImportError:
+ print("SKIP")
+ raise SystemExit
+
+def test_array_overflow(typecode, val):
+ try:
+ print(array(typecode, [val]))
+ except OverflowError:
+ print('OverflowError')
+
+# big int -1
+test_array_overflow('Q', -2**64 // 2**64)
+test_array_overflow('L', -2**64 // 2**64)
+test_array_overflow('I', -2**64 // 2**64)
+test_array_overflow('H', -2**64 // 2**64)
+test_array_overflow('B', -2**64 // 2**64)
+
+# big int 2**63
+test_array_overflow('q', 2**63)
+test_array_overflow('l', 2**63)
+test_array_overflow('i', 2**63)
+test_array_overflow('h', 2**63)
+test_array_overflow('b', 2**63)
diff --git a/tests/basics/builtin_chr.py b/tests/basics/builtin_chr.py
index 02d783ae6..c1a9f7053 100644
--- a/tests/basics/builtin_chr.py
+++ b/tests/basics/builtin_chr.py
@@ -6,4 +6,3 @@ try:
chr(0x110000)
except ValueError:
print("ValueError")
-
diff --git a/tests/basics/class_bytes.py b/tests/basics/class_bytes.py
new file mode 100644
index 000000000..75e2e7244
--- /dev/null
+++ b/tests/basics/class_bytes.py
@@ -0,0 +1,9 @@
+class C1:
+ def __init__(self, value):
+ self.value = value
+
+ def __bytes__(self):
+ return self.value
+
+c1 = C1(b"class 1")
+print(bytes(c1))
diff --git a/tests/basics/dict1.py b/tests/basics/dict1.py
index 20fa9def3..0cec51173 100644
--- a/tests/basics/dict1.py
+++ b/tests/basics/dict1.py
@@ -27,7 +27,7 @@ print({1:1} == {2:1})
try:
{}[0]
except KeyError as er:
- print('KeyError', er, repr(er), er.args)
+ print('KeyError', er, er.args)
# unsupported unary op
try:
diff --git a/tests/basics/dict_popitem.py b/tests/basics/dict_popitem.py
index e37bcec19..0e3384253 100644
--- a/tests/basics/dict_popitem.py
+++ b/tests/basics/dict_popitem.py
@@ -13,4 +13,3 @@ except KeyError:
else:
print("Did not raise KeyError")
print(sorted(els))
-
diff --git a/tests/basics/dict_setdefault.py b/tests/basics/dict_setdefault.py
index 57d0ba451..87de5b3af 100644
--- a/tests/basics/dict_setdefault.py
+++ b/tests/basics/dict_setdefault.py
@@ -9,5 +9,3 @@ d.pop(5)
print(d.setdefault(5, 1))
print(d[1])
print(d[5])
-
-
diff --git a/tests/basics/exception1.py b/tests/basics/exception1.py
index 739dd3275..d83764cb9 100644
--- a/tests/basics/exception1.py
+++ b/tests/basics/exception1.py
@@ -1,7 +1,6 @@
print(repr(IndexError()))
print(str(IndexError()))
-print(repr(IndexError("foo")))
print(str(IndexError("foo")))
a = IndexError(1, "test", [100, 200])
diff --git a/tests/basics/gen_yield_from.py.exp b/tests/basics/gen_yield_from.py.exp
new file mode 100644
index 000000000..507f2b9ca
--- /dev/null
+++ b/tests/basics/gen_yield_from.py.exp
@@ -0,0 +1,14 @@
+here1
+3
+here2
+[1, 2]
+here1
+None
+here2
+[1, 2]
+here1
+123
+here2
+[1, 2]
+444
+[0, 1, 2]
diff --git a/tests/basics/gen_yield_from_close.py.exp b/tests/basics/gen_yield_from_close.py.exp
new file mode 100644
index 000000000..a44d1353d
--- /dev/null
+++ b/tests/basics/gen_yield_from_close.py.exp
@@ -0,0 +1,20 @@
+-1
+1
+StopIteration
+-1
+1
+2
+leaf caught GeneratorExit and swallowed it
+delegating caught GeneratorExit
+StopIteration
+-1
+1
+2
+leaf caught GeneratorExit and raised StopIteration instead
+delegating caught GeneratorExit
+StopIteration
+123
+RuntimeError
+0
+1
+close
diff --git a/tests/basics/gen_yield_from_throw.py b/tests/basics/gen_yield_from_throw.py
index 829bf0f3b..d6754d5cd 100644
--- a/tests/basics/gen_yield_from_throw.py
+++ b/tests/basics/gen_yield_from_throw.py
@@ -21,7 +21,7 @@ except TypeError:
def gen3():
yield 123
yield 456
-
+
g3 = gen3()
print(next(g3))
try:
diff --git a/tests/basics/gen_yield_from_throw.py.exp b/tests/basics/gen_yield_from_throw.py.exp
new file mode 100644
index 000000000..6ce97ad86
--- /dev/null
+++ b/tests/basics/gen_yield_from_throw.py.exp
@@ -0,0 +1,6 @@
+1
+got ValueError from upstream!
+str1
+got TypeError from downstream!
+123
+got StopIteration from downstream!
diff --git a/tests/basics/gen_yield_from_throw2.py b/tests/basics/gen_yield_from_throw2.py
index 0abfdd8cc..5c0fc7dbc 100644
--- a/tests/basics/gen_yield_from_throw2.py
+++ b/tests/basics/gen_yield_from_throw2.py
@@ -6,7 +6,7 @@ def gen():
except GeneratorExit:
print('GeneratorExit')
yield 456
-
+
# thrown a class
g = gen()
print(next(g))
diff --git a/tests/basics/generator_close.py.exp b/tests/basics/generator_close.py.exp
new file mode 100644
index 000000000..fcd583935
--- /dev/null
+++ b/tests/basics/generator_close.py.exp
@@ -0,0 +1,10 @@
+None
+StopIteration
+1
+None
+StopIteration
+[1, 2]
+None
+StopIteration
+None
+ValueError
diff --git a/tests/basics/generator_return.py b/tests/basics/generator_return.py
index a3ac88575..5814ce837 100644
--- a/tests/basics/generator_return.py
+++ b/tests/basics/generator_return.py
@@ -7,4 +7,4 @@ print(next(g))
try:
print(next(g))
except StopIteration as e:
- print(repr(e))
+ print(type(e), e.args)
diff --git a/tests/basics/int_big_and2.py b/tests/basics/int_big_and2.py
index f8c81fe0c..045a90ef7 100644
--- a/tests/basics/int_big_and2.py
+++ b/tests/basics/int_big_and2.py
@@ -1,4 +1,4 @@
-# test + +
+# test + +
print( 97989513389222316022151446562729620153292831887555425160965597396
& 23716683549865351578586448630079789776107310103486834795830390982)
@@ -24,7 +24,7 @@ print( 283894311
print( 40019818573920230246248826511203818792007462193311949166285967147
& 9487909752)
-# test - -
+# test - -
print( -97989513389222316022151446562729620153292831887555425160965597396
& -23716683549865351578586448630079789776107310103486834795830390982)
diff --git a/tests/basics/int_big_and3.py b/tests/basics/int_big_and3.py
index 788ecd823..7a3b415af 100644
--- a/tests/basics/int_big_and3.py
+++ b/tests/basics/int_big_and3.py
@@ -1,4 +1,4 @@
-# test - +
+# test - +
print( -97989513389222316022151446562729620153292831887555425160965597396
& 23716683549865351578586448630079789776107310103486834795830390982)
@@ -24,7 +24,7 @@ print( -283894311
print( -40019818573920230246248826511203818792007462193311949166285967147
& 9487909752)
-# test + -
+# test + -
print( 97989513389222316022151446562729620153292831887555425160965597396
& -23716683549865351578586448630079789776107310103486834795830390982)
diff --git a/tests/basics/int_big_error.py b/tests/basics/int_big_error.py
index e036525d1..79809aef1 100644
--- a/tests/basics/int_big_error.py
+++ b/tests/basics/int_big_error.py
@@ -17,9 +17,9 @@ try:
except TypeError:
print("TypeError")
-# overflow because rhs of >> is being converted to machine int
+# overflow because arg of bytearray is being converted to machine int
try:
- 1 >> i
+ bytearray(i)
except OverflowError:
print('OverflowError')
diff --git a/tests/basics/int_big_or.py b/tests/basics/int_big_or.py
index 17d993526..ccded3778 100644
--- a/tests/basics/int_big_or.py
+++ b/tests/basics/int_big_or.py
@@ -3,7 +3,7 @@ print(0 | (1 << 80))
a = 0xfffffffffffffffffffffffffffff
print(a | (1 << 200))
-# test + +
+# test + +
print(0 | (1 << 80))
print((1 << 80) | (1 << 80))
@@ -15,7 +15,7 @@ print(a | (1 << 200))
print(a | a == 0)
print(bool(a | a))
-# test - +
+# test - +
print((-1 << 80) | (1 << 80))
print((-1 << 80) | 0)
@@ -25,7 +25,7 @@ print((-a) | (1 << 200))
print((-a) | a == 0)
print(bool((-a) | a))
-# test + -
+# test + -
print(0 | (-1 << 80))
print((1 << 80) | (-1 << 80))
@@ -35,7 +35,7 @@ print(a | (-1 << 200))
print(a | (-a) == 0)
print(bool(a | (-a)))
-# test - -
+# test - -
print((-1 << 80) | (-1 << 80))
diff --git a/tests/basics/int_big_or2.py b/tests/basics/int_big_or2.py
index 255495150..92d76c770 100644
--- a/tests/basics/int_big_or2.py
+++ b/tests/basics/int_big_or2.py
@@ -1,4 +1,4 @@
-# test + +
+# test + +
print( 97989513389222316022151446562729620153292831887555425160965597396
| 23716683549865351578586448630079789776107310103486834795830390982)
@@ -23,7 +23,7 @@ print( 283894311
print( 40019818573920230246248826511203818792007462193311949166285967147
| 9487909752)
-# test - -
+# test - -
print( -97989513389222316022151446562729620153292831887555425160965597396
| -23716683549865351578586448630079789776107310103486834795830390982)
diff --git a/tests/basics/int_big_or3.py b/tests/basics/int_big_or3.py
index 07edaea2d..212b3da8a 100644
--- a/tests/basics/int_big_or3.py
+++ b/tests/basics/int_big_or3.py
@@ -1,4 +1,4 @@
-# test - +
+# test - +
print( -97989513389222316022151446562729620153292831887555425160965597396
| 23716683549865351578586448630079789776107310103486834795830390982)
@@ -24,7 +24,7 @@ print( -283894311
print( -40019818573920230246248826511203818792007462193311949166285967147
| 9487909752)
-# test + -
+# test + -
print( 97989513389222316022151446562729620153292831887555425160965597396
| -23716683549865351578586448630079789776107310103486834795830390982)
diff --git a/tests/basics/int_big_xor.py b/tests/basics/int_big_xor.py
index cd1d9ae97..28b191d3d 100644
--- a/tests/basics/int_big_xor.py
+++ b/tests/basics/int_big_xor.py
@@ -1,4 +1,4 @@
-# test + +
+# test + +
print(0 ^ (1 << 80))
print((1 << 80) ^ (1 << 80))
@@ -10,7 +10,7 @@ print(a ^ (1 << 200))
print(a ^ a == 0)
print(bool(a ^ a))
-# test - +
+# test - +
print((-1 << 80) ^ (1 << 80))
print((-1 << 80) ^ 0)
@@ -22,7 +22,7 @@ print(bool((-a) ^ a))
i = -1
print(i ^ 0xffffffffffffffff) # carry overflows to higher digit
-# test + -
+# test + -
print(0 ^ (-1 << 80))
print((1 << 80) ^ (-1 << 80))
@@ -32,7 +32,7 @@ print(a ^ (-1 << 200))
print(a ^ (-a) == 0)
print(bool(a ^ (-a)))
-# test - -
+# test - -
print((-1 << 80) ^ (-1 << 80))
diff --git a/tests/basics/int_big_xor2.py b/tests/basics/int_big_xor2.py
index b5b3db60c..21ef842f8 100644
--- a/tests/basics/int_big_xor2.py
+++ b/tests/basics/int_big_xor2.py
@@ -1,4 +1,4 @@
-# test + +
+# test + +
print( 97989513389222316022151446562729620153292831887555425160965597396
^ 23716683549865351578586448630079789776107310103486834795830390982)
@@ -24,7 +24,7 @@ print( 283894311
print( 40019818573920230246248826511203818792007462193311949166285967147
^ 9487909752)
-# test - -
+# test - -
print( -97989513389222316022151446562729620153292831887555425160965597396
^ -23716683549865351578586448630079789776107310103486834795830390982)
diff --git a/tests/basics/int_big_xor3.py b/tests/basics/int_big_xor3.py
index 00881e374..ff5e9aeff 100644
--- a/tests/basics/int_big_xor3.py
+++ b/tests/basics/int_big_xor3.py
@@ -1,4 +1,4 @@
-# test - +
+# test - +
print( -97989513389222316022151446562729620153292831887555425160965597396
^ 23716683549865351578586448630079789776107310103486834795830390982)
@@ -24,7 +24,7 @@ print( -283894311
print( -40019818573920230246248826511203818792007462193311949166285967147
^ 9487909752)
-# test + -
+# test + -
print( 97989513389222316022151446562729620153292831887555425160965597396
^ -23716683549865351578586448630079789776107310103486834795830390982)
diff --git a/tests/basics/int_bytes.py b/tests/basics/int_bytes.py
index 059c16d3f..d42afac1f 100644
--- a/tests/basics/int_bytes.py
+++ b/tests/basics/int_bytes.py
@@ -1,6 +1,11 @@
print((10).to_bytes(1, "little"))
+print((-10).to_bytes(1, "little", signed=True))
+# Test fitting in length that's not a power of two.
+print((0x10000).to_bytes(3, 'little'))
print((111111).to_bytes(4, "little"))
+print((-111111).to_bytes(4, "little", signed=True))
print((100).to_bytes(10, "little"))
+print((-100).to_bytes(10, "little", signed=True))
# check that extra zero bytes don't change the internal int value
print(int.from_bytes(bytes(20), "little") == 0)
@@ -8,7 +13,9 @@ print(int.from_bytes(b"\x01" + bytes(20), "little") == 1)
# big-endian conversion
print((10).to_bytes(1, "big"))
+print((-10).to_bytes(1, "big", signed=True))
print((100).to_bytes(10, "big"))
+print((-100).to_bytes(10, "big", signed=True))
print(int.from_bytes(b"\0\0\0\0\0\0\0\0\0\x01", "big"))
print(int.from_bytes(b"\x01\0", "big"))
@@ -17,3 +24,20 @@ try:
(1).to_bytes(-1, "little")
except ValueError:
print("ValueError")
+
+# too small buffer should raise an error
+try:
+ (256).to_bytes(1, "little")
+except OverflowError:
+ print("OverflowError")
+
+# negative numbers should raise an error if signed=False
+try:
+ (-256).to_bytes(2, "little")
+except OverflowError:
+ print("OverflowError")
+
+try:
+ (-256).to_bytes(2, "little", signed=False)
+except OverflowError:
+ print("OverflowError")
diff --git a/tests/basics/int_bytes_intbig.py b/tests/basics/int_bytes_intbig.py
index ce6fec40a..a9f069902 100644
--- a/tests/basics/int_bytes_intbig.py
+++ b/tests/basics/int_bytes_intbig.py
@@ -2,7 +2,9 @@ import skip_if
skip_if.no_bigint()
print((2**64).to_bytes(9, "little"))
+print((-2**64).to_bytes(9, "little", signed=True))
print((2**64).to_bytes(9, "big"))
+print((-2**64).to_bytes(9, "big", signed=True))
b = bytes(range(20))
@@ -15,3 +17,19 @@ print(ib.to_bytes(20, "big"))
# check that extra zero bytes don't change the internal int value
print(int.from_bytes(b + bytes(10), "little") == int.from_bytes(b, "little"))
+
+# too small buffer should raise an error
+try:
+ (2**64).to_bytes(8, "little")
+except OverflowError:
+ print("OverflowError")
+
+# negative numbers should raise an error if signed=False
+try:
+ (-2**64).to_bytes(9, "little")
+except OverflowError:
+ print("OverflowError")
+try:
+ (-2**64).to_bytes(9, "little", signed=False)
+except OverflowError:
+ print("OverflowError")
diff --git a/tests/basics/int_longint_bytes.py b/tests/basics/int_longint_bytes.py
index 42e445f53..90cbff2f8 100644
--- a/tests/basics/int_longint_bytes.py
+++ b/tests/basics/int_longint_bytes.py
@@ -3,6 +3,7 @@ import skip_if
skip_if.no_bigint()
print((2**64).to_bytes(9, "little"))
+print((-2**64).to_bytes(9, "little", signed=True))
print(int.from_bytes(b"\x00\x01\0\0\0\0\0\0", "little"))
print(int.from_bytes(b"\x01\0\0\0\0\0\0\0", "little"))
print(int.from_bytes(b"\x00\x01\0\0\0\0\0\0", "little"))
diff --git a/tests/basics/parser.py.exp b/tests/basics/parser.py.exp
new file mode 100644
index 000000000..4d9886a09
--- /dev/null
+++ b/tests/basics/parser.py.exp
@@ -0,0 +1,3 @@
+SyntaxError
+SyntaxError
+SyntaxError
diff --git a/tests/basics/python34.py b/tests/basics/python34.py
index 36531f11c..4030db143 100644
--- a/tests/basics/python34.py
+++ b/tests/basics/python34.py
@@ -1,4 +1,4 @@
-# tests that differ when running under Python 3.4 vs 3.5/3.6
+# tests that differ when running under Python 3.4 vs 3.5/3.6/3.7
try:
exec
@@ -36,3 +36,7 @@ test_syntax("del ()") # can't delete empty tuple (in 3.6 we can)
import sys
print(sys.version[:3])
print(sys.version_info[0], sys.version_info[1])
+
+# from basics/exception1.py
+# in 3.7 no comma is printed if there is only 1 arg (in 3.4-3.6 one is printed)
+print(repr(IndexError("foo")))
diff --git a/tests/basics/python34.py.exp b/tests/basics/python34.py.exp
index 590fc364f..848017130 100644
--- a/tests/basics/python34.py.exp
+++ b/tests/basics/python34.py.exp
@@ -11,3 +11,4 @@ SyntaxError
SyntaxError
3.4
3 4
+IndexError('foo',)
diff --git a/tests/basics/set_iter.py b/tests/basics/set_iter.py
index 296017730..e7da28e1b 100644
--- a/tests/basics/set_iter.py
+++ b/tests/basics/set_iter.py
@@ -2,4 +2,3 @@ s = {1, 2, 3, 4}
l = list(s)
l.sort()
print(l)
-
diff --git a/tests/basics/set_pop.py b/tests/basics/set_pop.py
index 5e1196c9f..e951ca593 100644
--- a/tests/basics/set_pop.py
+++ b/tests/basics/set_pop.py
@@ -15,4 +15,4 @@ while s:
print(s.pop()) # last pop() should trigger the optimisation
for i in range(N):
s.add(i) # check that we can add the numbers back to the set
-print(list(s))
+print(sorted(s))
diff --git a/tests/basics/smallint_array_overflow.py b/tests/basics/smallint_array_overflow.py
new file mode 100644
index 000000000..25b457cca
--- /dev/null
+++ b/tests/basics/smallint_array_overflow.py
@@ -0,0 +1,52 @@
+try:
+ from array import array
+except ImportError:
+ print("SKIP")
+ raise SystemExit
+
+def test_array_overflow(typecode, val):
+ try:
+ print(array(typecode, [val]))
+ except OverflowError:
+ print('OverflowError')
+
+def test_bytearray_overflow(val):
+ try:
+ print(bytearray([val]))
+ except (OverflowError, ValueError):
+ # CircuitPython always does OverflowError
+ print('(OverflowError, ValueError)')
+
+
+# small int -1
+test_array_overflow('Q', -1)
+test_array_overflow('L', -1)
+test_array_overflow('I', -1)
+test_array_overflow('H', -1)
+test_array_overflow('B', -1)
+
+# 0 ok
+test_array_overflow('Q', 0)
+test_array_overflow('L', 0)
+test_array_overflow('I', 0)
+test_array_overflow('H', 0)
+test_array_overflow('B', 0)
+
+# 1 ok
+test_array_overflow('Q', 1)
+test_array_overflow('L', 1)
+test_array_overflow('I', 1)
+test_array_overflow('H', 1)
+test_array_overflow('B', 1)
+
+# truth value conversions
+test_array_overflow('b', True)
+test_array_overflow('b', False)
+
+# similar tests for bytearrays
+test_bytearray_overflow(0)
+test_bytearray_overflow(1)
+test_bytearray_overflow(-1)
+test_bytearray_overflow(256)
+test_bytearray_overflow(True)
+test_bytearray_overflow(False)
diff --git a/tests/basics/string_cr_conversion.py b/tests/basics/string_cr_conversion.py
index 0c3ba16b8..b8ec7e825 100644
--- a/tests/basics/string_cr_conversion.py
+++ b/tests/basics/string_cr_conversion.py
@@ -1 +1 @@
-# this file has CR line endings to test lexer's conversion of them to LF # in triple quoted strings print(repr("""abc def""")) \ No newline at end of file
+# this file has CR line endings to test lexer's conversion of them to LF # in triple quoted strings print(repr("""abc def"""))
diff --git a/tests/basics/string_pep498_fstring.py b/tests/basics/string_pep498_fstring.py
new file mode 100644
index 000000000..c645a730c
--- /dev/null
+++ b/tests/basics/string_pep498_fstring.py
@@ -0,0 +1,113 @@
+# Tests against https://www.python.org/dev/peps/pep-0498/
+
+assert f'no interpolation' == 'no interpolation'
+assert f"no interpolation" == 'no interpolation'
+
+# Quoth the PEP:
+# Backslashes may not appear anywhere within expressions. Comments, using the
+# '#' character, are not allowed inside an expression
+#
+# CPython (3.7.4 on Linux) raises a SyntaxError here:
+# >>> f'{#}'
+# File "<stdin>", line 1
+# SyntaxError: f-string expression part cannot include '#'
+# >>> f'{\}'
+# File "<stdin>", line 1
+# SyntaxError: f-string expression part cannot include a backslash
+# >>> f'{\\}'
+# File "<stdin>", line 1
+# SyntaxError: f-string expression part cannot include a backslash
+# >>> f'{\#}'
+# File "<stdin>", line 1
+# SyntaxError: f-string expression part cannot include a backslash
+
+# Backslashes and comments allowed outside expression
+assert f"\\" == "\\"
+assert f'#' == '#'
+
+## But not inside
+try:
+ eval("f'{\}'")
+except SyntaxError:
+ pass
+else:
+ raise AssertionError('f-string with backslash in expression did not raise SyntaxError')
+
+try:
+ eval("f'{#}'")
+except SyntaxError:
+ pass
+else:
+ raise AssertionError('f-string with \'#\' in expression did not raise SyntaxError')
+
+# Quoth the PEP:
+# While scanning the string for expressions, any doubled braces '{{' or '}}'
+# inside literal portions of an f-string are replaced by the corresponding
+# single brace. Doubled literal opening braces do not signify the start of an
+# expression. A single closing curly brace '}' in the literal portion of a
+# string is an error: literal closing curly braces must be doubled '}}' in
+# order to represent a single closing brace.
+#
+# CPython (3.7.4 on Linux) raises a SyntaxError for the last case:
+# >>> f'{{}'
+# File "<stdin>", line 1
+# SyntaxError: f-string: single '}' is not allowed
+
+assert f'{{}}' == '{}'
+
+try:
+ eval("f'{{}'")
+except ValueError:
+ pass
+else:
+ raise RuntimeError('Expected ValueError for invalid f-string literal bracing')
+
+x = 1
+assert f'{x}' == '1'
+
+# Quoth the PEP:
+# The expressions that are extracted from the string are evaluated in the
+# context where the f-string appeared. This means the expression has full
+# access to local and global variables. Any valid Python expression can be
+# used, including function and method calls. Because the f-strings are
+# evaluated where the string appears in the source code, there is no additional
+# expressiveness available with f-strings. There are also no additional
+# security concerns: you could have also just written the same expression, not
+# inside of an f-string:
+
+def foo():
+ return 20
+
+assert f'result={foo()}' == 'result=20'
+assert f'result={foo()}' == 'result={}'.format(foo())
+assert f'result={foo()}' == 'result={result}'.format(result=foo())
+
+
+# Quoth the PEP:
+# Adjacent f-strings and regular strings are concatenated. Regular strings are
+# concatenated at compile time, and f-strings are concatenated at run time. For
+# example, the expression:
+#
+# >>> x = 10
+# >>> y = 'hi'
+# >>> 'a' 'b' f'{x}' '{c}' f'str<{y:^4}>' 'd' 'e'
+#
+# yields the value: 'ab10{c}str< hi >de'
+#
+# Because strings are concatenated at lexer time rather than parser time in
+# MicroPython for mostly RAM efficiency reasons (see
+# https://github.com/micropython/micropython/commit/534b7c368dc2af7720f3aaed0c936ef46d773957),
+# and because f-strings here are implemented as a syntax translation
+# (f'{something}' => '{}'.format(something)), this particular functionality is unimplemented,
+# and in the above example, the '{c}' portion will trigger a KeyError on String.format()
+
+x = 10
+y = 'hi'
+assert (f'h' f'i') == 'hi'
+#assert (f'h' 'i') == 'hi'
+#assert ('h' f'i') == 'hi'
+assert f'{x:^4}' == ' 10 '
+#assert ('a' 'b' f'{x}' f'str<{y:^4}>' 'd' 'e') == 'ab10str< hi >de'
+
+# Other tests
+assert f'{{{4*10}}}' == '{40}'
diff --git a/tests/basics/string_pep498_fstring.py.exp b/tests/basics/string_pep498_fstring.py.exp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/basics/string_pep498_fstring.py.exp
diff --git a/tests/basics/struct_overflow.py b/tests/basics/struct_overflow.py
new file mode 100644
index 000000000..aee0c6b9d
--- /dev/null
+++ b/tests/basics/struct_overflow.py
@@ -0,0 +1,47 @@
+import skip_if
+skip_if.no_bigint()
+
+try:
+ import ustruct as struct
+except:
+ try:
+ import struct
+ except ImportError:
+ print("SKIP")
+ raise SystemExit
+
+def test_struct_overflow(typecode, val):
+ try:
+ print(struct.pack(typecode, val))
+ except OverflowError:
+ print('OverflowError')
+ except struct.error:
+ print('OverflowError')
+
+# small int -1
+test_struct_overflow('>Q', -1)
+test_struct_overflow('>L', -1)
+test_struct_overflow('>I', -1)
+test_struct_overflow('>H', -1)
+test_struct_overflow('>B', -1)
+
+# big int -1
+test_struct_overflow('>Q', -2**64 // 2**64)
+test_struct_overflow('>L', -2**64 // 2**64)
+test_struct_overflow('>I', -2**64 // 2**64)
+test_struct_overflow('>H', -2**64 // 2**64)
+test_struct_overflow('>B', -2**64 // 2**64)
+
+# possibly small ints
+test_struct_overflow('>q', 2**63)
+test_struct_overflow('>l', 2**31)
+test_struct_overflow('>i', 2**31)
+test_struct_overflow('>h', 2**15)
+test_struct_overflow('>b', 2**7)
+
+# definitely big ints
+test_struct_overflow('>q', 2**64 // 2**1)
+test_struct_overflow('>l', 2**64 // 2**33)
+test_struct_overflow('>i', 2**64 // 2**33)
+test_struct_overflow('>h', 2**64 // 2**49)
+test_struct_overflow('>b', 2**64 // 2**57)
diff --git a/tests/basics/subclass_native3.py b/tests/basics/subclass_native3.py
index bd99ab0d6..6745b77bb 100644
--- a/tests/basics/subclass_native3.py
+++ b/tests/basics/subclass_native3.py
@@ -7,12 +7,12 @@ print(repr(e))
print(e.args)
try:
- raise MyExc("Some error")
+ raise MyExc("Some error", 1)
except MyExc as e:
print("Caught exception:", repr(e))
try:
- raise MyExc("Some error2")
+ raise MyExc("Some error2", 2)
except Exception as e:
print("Caught exception:", repr(e))
diff --git a/tests/basics/subscr_tuple.py b/tests/basics/subscr_tuple.py
new file mode 100644
index 000000000..0210e24df
--- /dev/null
+++ b/tests/basics/subscr_tuple.py
@@ -0,0 +1,6 @@
+# subscripting a subclassed tuple
+class Foo(tuple):
+ pass
+
+foo = Foo((1,2))
+foo[0]
diff --git a/tests/basics/try_as_var.py b/tests/basics/try_as_var.py
index 0a92f1cae..4f02f9c10 100644
--- a/tests/basics/try_as_var.py
+++ b/tests/basics/try_as_var.py
@@ -1,7 +1,7 @@
try:
raise ValueError(534)
except ValueError as e:
- print(repr(e))
+ print(type(e), e.args)
# Var bound in except block is automatically deleted
try:
diff --git a/tests/cmdline/cmd_parsetree.py.exp b/tests/cmdline/cmd_parsetree.py.exp
index 12a1bfbe9..c06ce4e31 100644
--- a/tests/cmdline/cmd_parsetree.py.exp
+++ b/tests/cmdline/cmd_parsetree.py.exp
@@ -1,6 +1,6 @@
----------------
[ 4] rule(1) (n=9)
- tok(4)
+ tok(10)
[ 4] rule(22) (n=4)
id(i)
[ 4] rule(44) (n=1)
@@ -9,7 +9,7 @@
NULL
[ 6] rule(5) (n=2)
id(a)
- tok(14)
+ tok(20)
[ 7] rule(5) (n=2)
id(b)
str(str)
diff --git a/tests/cmdline/repl_autocomplete.py b/tests/cmdline/repl_autocomplete.py
index 27cad428f..43c49cdc2 100644
--- a/tests/cmdline/repl_autocomplete.py
+++ b/tests/cmdline/repl_autocomplete.py
@@ -6,4 +6,7 @@ x = '123'
1, x.isdi ()
i = str
i.lowe ('ABC')
+x = 5
+x. 
+x._
None. 
diff --git a/tests/cmdline/repl_autocomplete.py.exp b/tests/cmdline/repl_autocomplete.py.exp
index 75002985e..7d160e7bf 100644
--- a/tests/cmdline/repl_autocomplete.py.exp
+++ b/tests/cmdline/repl_autocomplete.py.exp
@@ -10,5 +10,11 @@ Use \.\+
>>> i = str
>>> i.lower('ABC')
'abc'
+>>> x = 5
+>>> x.
+from_bytes to_bytes
+>>> x.
+>>> x.__class__
+<class 'int'>
>>> None.
>>>
diff --git a/tests/extmod/uctypes_array_assign_le.py b/tests/extmod/uctypes_array_assign_le.py
index 6afa7e0a2..37c52388d 100644
--- a/tests/extmod/uctypes_array_assign_le.py
+++ b/tests/extmod/uctypes_array_assign_le.py
@@ -55,4 +55,3 @@ assert hex(S.arr6[0]) == "0xaabbccdd"
print(S.arr6[0] == S.arr8[0].l)
assert S.arr6[0] == S.arr8[0].l
-
diff --git a/tests/extmod/uctypes_byteat.py b/tests/extmod/uctypes_byteat.py
index ab2535db8..784209f80 100644
--- a/tests/extmod/uctypes_byteat.py
+++ b/tests/extmod/uctypes_byteat.py
@@ -6,5 +6,5 @@ except ImportError:
data = bytearray(b'01234567')
-print(uctypes.bytes_at(uctypes.addressof(data), 4))
-print(uctypes.bytearray_at(uctypes.addressof(data), 4))
+print(uctypes.bytes_at(uctypes.addressof(data), 4))
+print(uctypes.bytearray_at(uctypes.addressof(data), 4))
diff --git a/tests/extmod/uctypes_error.py b/tests/extmod/uctypes_error.py
index 95ba0fad4..2500e2927 100644
--- a/tests/extmod/uctypes_error.py
+++ b/tests/extmod/uctypes_error.py
@@ -9,29 +9,29 @@ except ImportError:
data = bytearray(b"01234567")
# del subscr not supported
-S = uctypes.struct(uctypes.addressof(data), {})
+S = uctypes.struct(uctypes.addressof(data), {})
try:
del S[0]
except TypeError:
print('TypeError')
# list is an invalid descriptor
-S = uctypes.struct(uctypes.addressof(data), [])
+S = uctypes.struct(uctypes.addressof(data), [])
try:
- S.x
+ S.x
except TypeError:
print('TypeError')
# can't access attribute with invalid descriptor
S = uctypes.struct(uctypes.addressof(data), {'x':[]})
try:
- S.x
+ S.x
except TypeError:
print('TypeError')
# can't assign to aggregate
S = uctypes.struct(uctypes.addressof(data), {'x':(uctypes.ARRAY | 0, uctypes.INT8 | 2)})
try:
- S.x = 1
+ S.x = 1
except TypeError:
print('TypeError')
diff --git a/tests/extmod/ujson_dump_iobase.py b/tests/extmod/ujson_dump_iobase.py
index d30d1b561..6280fb11b 100644
--- a/tests/extmod/ujson_dump_iobase.py
+++ b/tests/extmod/ujson_dump_iobase.py
@@ -28,5 +28,5 @@ class S(io.IOBase):
# dump to the user stream
s = S()
-json.dump([123, {}], s)
+json.dump([123, {}], s)
print(s.buf)
diff --git a/tests/extmod/ure1.py b/tests/extmod/ure1.py
index 54471ed4f..710720c8b 100644
--- a/tests/extmod/ure1.py
+++ b/tests/extmod/ure1.py
@@ -28,6 +28,19 @@ try:
except IndexError:
print("IndexError")
+r = re.compile(r"\n")
+m = r.match("\n")
+print(m.group(0))
+m = r.match("\\")
+print(m)
+r = re.compile(r"[\n-\r]")
+m = r.match("\n")
+print(m.group(0))
+r = re.compile(r"[\]]")
+m = r.match("]")
+print(m.group(0))
+print("===")
+
r = re.compile("[a-cu-z]")
m = r.match("a")
print(m.group(0))
diff --git a/tests/extmod/ure_groups.py b/tests/extmod/ure_groups.py
new file mode 100644
index 000000000..4fac896d7
--- /dev/null
+++ b/tests/extmod/ure_groups.py
@@ -0,0 +1,33 @@
+# test match.groups()
+
+try:
+ import ure as re
+except ImportError:
+ try:
+ import re
+ except ImportError:
+ print("SKIP")
+ raise SystemExit
+
+try:
+ m = re.match(".", "a")
+ m.groups
+except AttributeError:
+ print('SKIP')
+ raise SystemExit
+
+
+m = re.match(r'(([0-9]*)([a-z]*)[0-9]*)','1234hello567')
+print(m.groups())
+
+m = re.match(r'([0-9]*)(([a-z]*)([0-9]*))','1234hello567')
+print(m.groups())
+
+# optional group that matches
+print(re.match(r'(a)?b(c)', 'abc').groups())
+
+# optional group that doesn't match
+print(re.match(r'(a)?b(c)', 'bc').groups())
+
+# only a single match
+print(re.match(r'abc', 'abc').groups())
diff --git a/tests/extmod/ure_span.py b/tests/extmod/ure_span.py
new file mode 100644
index 000000000..50f44399c
--- /dev/null
+++ b/tests/extmod/ure_span.py
@@ -0,0 +1,40 @@
+# test match.span(), and nested spans
+
+try:
+ import ure as re
+except ImportError:
+ try:
+ import re
+ except ImportError:
+ print("SKIP")
+ raise SystemExit
+
+try:
+ m = re.match(".", "a")
+ m.span
+except AttributeError:
+ print('SKIP')
+ raise SystemExit
+
+
+def print_spans(match):
+ print('----')
+ try:
+ i = 0
+ while True:
+ print(match.span(i), match.start(i), match.end(i))
+ i += 1
+ except IndexError:
+ pass
+
+m = re.match(r'(([0-9]*)([a-z]*)[0-9]*)','1234hello567')
+print_spans(m)
+
+m = re.match(r'([0-9]*)(([a-z]*)([0-9]*))','1234hello567')
+print_spans(m)
+
+# optional span that matches
+print_spans(re.match(r'(a)?b(c)', 'abc'))
+
+# optional span that doesn't match
+print_spans(re.match(r'(a)?b(c)', 'bc'))
diff --git a/tests/extmod/ure_sub.py b/tests/extmod/ure_sub.py
new file mode 100644
index 000000000..f5a19af8d
--- /dev/null
+++ b/tests/extmod/ure_sub.py
@@ -0,0 +1,61 @@
+try:
+ import ure as re
+except ImportError:
+ try:
+ import re
+ except ImportError:
+ print('SKIP')
+ raise SystemExit
+
+try:
+ re.sub
+except AttributeError:
+ print('SKIP')
+ raise SystemExit
+
+
+def multiply(m):
+ return str(int(m.group(0)) * 2)
+
+print(re.sub("\d+", multiply, "10 20 30 40 50"))
+
+print(re.sub("\d+", lambda m: str(int(m.group(0)) // 2), "10 20 30 40 50"))
+
+def A():
+ return "A"
+print(re.sub('a', A(), 'aBCBABCDabcda.'))
+
+print(
+ re.sub(
+ r'def\s+([a-zA-Z_][a-zA-Z_0-9]*)\s*\(\s*\):',
+ 'static PyObject*\npy_\\1(void){\n return;\n}\n',
+ '\n\ndef myfunc():\n\ndef myfunc1():\n\ndef myfunc2():'
+ )
+)
+
+print(
+ re.compile(
+ '(calzino) (blu|bianco|verde) e (scarpa) (blu|bianco|verde)'
+ ).sub(
+ r'\g<1> colore \2 con \g<3> colore \4? ...',
+ 'calzino blu e scarpa verde'
+ )
+)
+
+# no matches at all
+print(re.sub('a', 'b', 'c'))
+
+# with maximum substitution count specified
+print(re.sub('a', 'b', '1a2a3a', 2))
+
+# invalid group
+try:
+ re.sub('(a)', 'b\\2', 'a')
+except:
+ print('invalid group')
+
+# invalid group with very large number (to test overflow in uPy)
+try:
+ re.sub('(a)', 'b\\199999999999999999999999999999999999999', 'a')
+except:
+ print('invalid group')
diff --git a/tests/extmod/ure_sub_unmatched.py b/tests/extmod/ure_sub_unmatched.py
new file mode 100644
index 000000000..4795b3196
--- /dev/null
+++ b/tests/extmod/ure_sub_unmatched.py
@@ -0,0 +1,19 @@
+# test re.sub with unmatched groups, behaviour changed in CPython 3.5
+
+try:
+ import ure as re
+except ImportError:
+ try:
+ import re
+ except ImportError:
+ print('SKIP')
+ raise SystemExit
+
+try:
+ re.sub
+except AttributeError:
+ print('SKIP')
+ raise SystemExit
+
+# first group matches, second optional group doesn't so is replaced with a blank
+print(re.sub(r'(a)(b)?', r'\2-\1', '1a2'))
diff --git a/tests/extmod/ure_sub_unmatched.py.exp b/tests/extmod/ure_sub_unmatched.py.exp
new file mode 100644
index 000000000..1e5f0fda0
--- /dev/null
+++ b/tests/extmod/ure_sub_unmatched.py.exp
@@ -0,0 +1 @@
+1-a2
diff --git a/tests/feature_check/complex.py b/tests/feature_check/complex.py
index a22eb52ce..7576dcb95 100644
--- a/tests/feature_check/complex.py
+++ b/tests/feature_check/complex.py
@@ -3,4 +3,3 @@ try:
print("complex")
except NameError:
print("no")
-
diff --git a/tests/float/builtin_float_minmax.py b/tests/float/builtin_float_minmax.py
index 266ed133d..8a53746e5 100644
--- a/tests/float/builtin_float_minmax.py
+++ b/tests/float/builtin_float_minmax.py
@@ -29,4 +29,3 @@ print(min([1, 2.9, 4, 6.5, -1, 2]))
print(max([1, 2.9, 4, 6.5, -1, 2]))
print(min([1, 2.9, 4, -6.5, -1, 2]))
print(max([1, 2.9, 4, -6.5, -1, 2]))
-
diff --git a/tests/float/float_struct.py b/tests/float/float_struct.py
index c4c186b89..dd7a418ad 100644
--- a/tests/float/float_struct.py
+++ b/tests/float/float_struct.py
@@ -15,4 +15,3 @@ for fmt in ('f', 'd', '>f', '>d', '<f', '<d'):
x = struct.pack(fmt, i)
v = struct.unpack(fmt, x)[0]
print('%2s: %.17f - %s' % (fmt, v, (i == v) and 'passed' or 'failed'))
-
diff --git a/tests/float/math_fun_bool.py b/tests/float/math_fun_bool.py
index 30ab14a52..761871b41 100644
--- a/tests/float/math_fun_bool.py
+++ b/tests/float/math_fun_bool.py
@@ -6,7 +6,7 @@ except ImportError:
print("SKIP")
raise SystemExit
-test_values = [1, 0, -1, 1.0, 0.0, -1.0, float('NaN'), float('Inf'),
+test_values = [1, 0, -1, 1.0, 0.0, -1.0, float('NaN'), float('Inf'),
-float('NaN'), -float('Inf')]
functions = [isfinite, isnan, isinf]
diff --git a/tests/import/import_override.py.exp b/tests/import/import_override.py.exp
new file mode 100644
index 000000000..365248da6
--- /dev/null
+++ b/tests/import/import_override.py.exp
@@ -0,0 +1,2 @@
+import import1b None 0
+456
diff --git a/tests/import/mpy_invalid.py b/tests/import/mpy_invalid.py
index 6a4e116e7..b9dd99a44 100644
--- a/tests/import/mpy_invalid.py
+++ b/tests/import/mpy_invalid.py
@@ -59,8 +59,8 @@ for i in range(len(user_files)):
mod = 'mod%u' % i
try:
__import__(mod)
- except ValueError as er:
- print(mod, 'ValueError', er)
+ except Exception as e:
+ print(mod, type(e).__name__, e)
# unmount and undo path addition
uos.umount('/userfs')
diff --git a/tests/import/mpy_invalid.py.exp b/tests/import/mpy_invalid.py.exp
index e4f2b13e9..197eb4f7b 100644
--- a/tests/import/mpy_invalid.py.exp
+++ b/tests/import/mpy_invalid.py.exp
@@ -1,3 +1,3 @@
-mod0 ValueError Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.
-mod1 ValueError Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.
-mod2 ValueError Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.
+mod0 RuntimeError Corrupt .mpy file
+mod1 RuntimeError Corrupt .mpy file
+mod2 MpyError Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.
diff --git a/tests/inlineasm/asmfpaddsub.py b/tests/inlineasm/asmfpaddsub.py
index b5fcecb6c..2bdfccf0e 100644
--- a/tests/inlineasm/asmfpaddsub.py
+++ b/tests/inlineasm/asmfpaddsub.py
@@ -12,4 +12,3 @@ def add_sub(r0, r1, r2):
vmov(r0, s31)
print(add_sub(100, 20, 30))
-
diff --git a/tests/inlineasm/asmfpldrstr.py b/tests/inlineasm/asmfpldrstr.py
index 8fa9af636..4c480671f 100644
--- a/tests/inlineasm/asmfpldrstr.py
+++ b/tests/inlineasm/asmfpldrstr.py
@@ -9,4 +9,3 @@ def arrayadd(r0):
z = array.array("f", [2, 4, 10])
arrayadd(z)
print(z[2])
-
diff --git a/tests/inlineasm/asmfpmuldiv.py b/tests/inlineasm/asmfpmuldiv.py
index edf9511bc..043a28e22 100644
--- a/tests/inlineasm/asmfpmuldiv.py
+++ b/tests/inlineasm/asmfpmuldiv.py
@@ -12,4 +12,3 @@ def muldiv(r0, r1, r2):
vmov(r0, s31)
print(muldiv(100, 10, 50))
-
diff --git a/tests/inlineasm/asmfpsqrt.py b/tests/inlineasm/asmfpsqrt.py
index f2c2d3a95..7b7d52e23 100644
--- a/tests/inlineasm/asmfpsqrt.py
+++ b/tests/inlineasm/asmfpsqrt.py
@@ -12,4 +12,3 @@ def sqrt_test(r0, r1):
vmov(r0, s31)
print(sqrt_test(256, 10))
-
diff --git a/tests/inlineasm/asmspecialregs.py b/tests/inlineasm/asmspecialregs.py
index edfe4c2bd..2d3b0e396 100644
--- a/tests/inlineasm/asmspecialregs.py
+++ b/tests/inlineasm/asmspecialregs.py
@@ -8,4 +8,3 @@ def getBASEPRI():
print(getBASEPRI())
print(getIPSR())
-
diff --git a/tests/jni/README b/tests/jni/README
index 8418bb84f..a0689e924 100644
--- a/tests/jni/README
+++ b/tests/jni/README
@@ -9,4 +9,3 @@ of JVM.
For example, for OpenJDK 7 on x86_64, following may work:
LD_LIBRARY_PATH=/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server ./run-tests jni/*.py
-
diff --git a/tests/misc/features.py b/tests/misc/features.py
index 3efb476ab..de75cb46d 100644
--- a/tests/misc/features.py
+++ b/tests/misc/features.py
@@ -25,7 +25,7 @@ print(ten())
a=[]
for i in range(13):
a.append(i)
-print(a[11])
+print(a[11])
print(a[-1])
str="0123456789"
print(str[1]+str[3])
@@ -73,13 +73,13 @@ while True:
try:
def gcheck():
global a
- print(a)
+ print(a)
gcheck()
class c25():
x=25
x=c25()
print(x.x)
- raise
+ raise
except:
print(26)
print(27+zero)
diff --git a/tests/misc/sys_exc_info.py b/tests/misc/sys_exc_info.py
index 4bb2c61e8..bf9438e46 100644
--- a/tests/misc/sys_exc_info.py
+++ b/tests/misc/sys_exc_info.py
@@ -9,7 +9,7 @@ def f():
print(sys.exc_info()[0:2])
try:
- 1/0
+ raise ValueError('value', 123)
except:
print(sys.exc_info()[0:2])
f()
diff --git a/tests/run-tests b/tests/run-tests
index 94e1591e8..6e980f03c 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -385,6 +385,7 @@ def run_tests(pyb, tests, args, base_path=".", num_threads=1):
skip_tests.add('stress/gc_trace.py') # requires yield
skip_tests.add('stress/recursive_gen.py') # requires yield
skip_tests.add('extmod/vfs_userfs.py') # because native doesn't properly handle globals across different modules
+ skip_tests.add('../extmod/ulab/tests/argminmax.py') # requires yield
def run_one_test(test_file):
test_file = test_file.replace('\\', '/')
@@ -579,7 +580,7 @@ the last matching regex is used:
# run PC tests
test_dirs = (
'basics', 'micropython', 'float', 'import', 'io', 'misc',
- 'stress', 'unicode', 'extmod', 'unix', 'cmdline',
+ 'stress', 'unicode', 'extmod', '../extmod/ulab/tests', 'unix', 'cmdline',
)
else:
# run tests from these directories
diff --git a/tests/thread/mutate_bytearray.py b/tests/thread/mutate_bytearray.py
index f3276f1b2..f91b2d580 100644
--- a/tests/thread/mutate_bytearray.py
+++ b/tests/thread/mutate_bytearray.py
@@ -42,4 +42,3 @@ count = [0 for _ in range(256)]
for b in ba:
count[b] += 1
print(count)
-
diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp
index 9df852757..06b5d3790 100644
--- a/tests/unix/extra_coverage.py.exp
+++ b/tests/unix/extra_coverage.py.exp
@@ -27,11 +27,11 @@ RuntimeError:
# repl
ame__
-__class__ __name__ argv byteorder
-exc_info exit getsizeof implementation
-maxsize modules path platform
-print_exception stderr stdin
-stdout version version_info
+argv byteorder exc_info exit
+getsizeof implementation maxsize modules
+path platform print_exception
+stderr stdin stdout version
+version_info
ementation
# attrtuple
(start=1, stop=2, step=3)
diff --git a/tests/wipy/i2c.py b/tests/wipy/i2c.py
index 693155419..39dcdc722 100644
--- a/tests/wipy/i2c.py
+++ b/tests/wipy/i2c.py
@@ -173,4 +173,3 @@ except Exception:
# reinitialization must work
i2c.init(baudrate=400000)
print(i2c)
-
diff --git a/tests/wipy/pin.py b/tests/wipy/pin.py
index 22c7c6176..666ecb66b 100644
--- a/tests/wipy/pin.py
+++ b/tests/wipy/pin.py
@@ -1,7 +1,7 @@
-"""
-This test need a set of pins which can be set as inputs and have no external
+"""
+This test need a set of pins which can be set as inputs and have no external
pull up or pull down connected.
-GP12 and GP17 must be connected together
+GP12 and GP17 must be connected together
"""
from machine import Pin
import os
@@ -179,4 +179,3 @@ try:
pin.id('ABC') # id cannot be set
except Exception:
print('Exception')
-
diff --git a/tests/wipy/sd.py b/tests/wipy/sd.py
index 92746e01e..c946e0c9f 100644
--- a/tests/wipy/sd.py
+++ b/tests/wipy/sd.py
@@ -43,4 +43,3 @@ try:
sd = SD(pins=('GP10', 'GP11'))
except Exception:
print("Exception")
-
diff --git a/tests/wipy/uart.py b/tests/wipy/uart.py
index 8e794015d..d8b405f77 100644
--- a/tests/wipy/uart.py
+++ b/tests/wipy/uart.py
@@ -1,5 +1,5 @@
'''
-UART test for the CC3200 based boards.
+UART test for the CC3200 based boards.
UART0 and UART1 must be connected together for this test to pass.
'''
@@ -58,7 +58,7 @@ print(uart0.read() == None)
uart0.write(b'123')
buf = bytearray(3)
-print(uart1.readinto(buf, 1) == 1)
+print(uart1.readinto(buf, 1) == 1)
print(buf)
print(uart1.readinto(buf) == 2)
print(buf)
@@ -145,7 +145,7 @@ except Exception:
try:
UART(2, 9600)
except Exception:
- print('Exception')
+ print('Exception')
for uart_id in uart_id_range:
uart = UART(uart_id, 1000000)
diff --git a/tests/wipy/wlan/wlan.py b/tests/wipy/wlan/wlan.py
index 49e2e4af6..96121325c 100644
--- a/tests/wipy/wlan/wlan.py
+++ b/tests/wipy/wlan/wlan.py
@@ -179,4 +179,3 @@ try:
wifi.ifconfig(config=())
except:
print('Exception')
-