summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-08-14 12:47:47 +1000
committerDamien George <damien.p.george@gmail.com>2017-08-14 12:47:47 +1000
commitf6e6776d6f8233432615f1ef438cbd1447c51aac (patch)
tree34589f98ab4d89914025b7d4ee10d2801cd80b3d /tests/basics
parentd9d9b0a3005a810543724622374cc26a5399bd0e (diff)
parentc8d31585a00616b39839d112b7c696dafed6b08d (diff)
downloadmicropython-f6e6776d6f8233432615f1ef438cbd1447c51aac.tar.gz
micropython-f6e6776d6f8233432615f1ef438cbd1447c51aac.zip
Merge tag 'v1.8.5' into parse-bytecode
New port to Zephyr, upip runs on baremetal, and reduction in code size This release adds a new port of MicroPython to run on top of the Zephyr real-time operating system. As part of this there is now basic support for using mbedTLS as the ussl module. The release also brings initial support for running the package manager upip on baremetal systems with low heap memory (such as esp8266), through a Python module interface. Work has been done in this release to clean up the core, removing redundant and/or unreachable code, and factoring existing duplicated code patterns. This brings a reduction of 828 bytes in code size to the bare-arm port, and 1368 bytes to the minimal port. There is also improved coverage through the addition of new tests for corner cases. The "micropython" module sees the addition of the "const" identity function which should be used as "from micropython import const" in scripts that want to use the MicroPython constant optimisations in the compile stage. There is also the addition of the "opt_level" function to change the parser/compiler optimisation level at runtime. The behaviour of "sys.exit" (and "raise SystemExit") on baremetal is now changed: this function no longer does a soft-reset of the board, rather it just stops the running script and drops to the REPL. In order to do an actual soft reset the "machine.soft_reset" function has been added (to the stmhal port only, for the time being). Following CPython, KeyError exceptions for dictionary lookups now have the failed key stored as the argument of the exception instance, accessible as exc.args[0]. The "ujson.load" function has also been added, to load JSON data from an arbitrary stream. The I2C support in the machine module now has clock stretching, the addition of the "addrsize" parameter in memory transfer methods, and I2C scanning now uses dummy writes instead of dummy reads to make the scanning more reliable. The CMSIS library has been upgrade to v4.30, and the boards section of the stmhal port has been refactored to use a common.ld script. The stmhal port now has a full implementation of the machine.SPI class, with support for both hardware SPI peripherals and fast software SPI. The USB HID driver in stmhal has added support to receive USB HID messages from the host. py core: - asmthumb: flush D-cache, and invalidate I-cache on STM32F7 - makeqstrdefs.py: use python 2.6 syntax for set creation - objnone: remove unnecessary handling of MP_UNARY_OP_BOOL - move frozen modules rules from esp8266 port for reuse across ports - combine 3 comprehension emit functions (list/dict/set) into 1 - combine 3 comprehension opcodes (list/dict/set) into 1 - vstr: remove vstr.had_error flag and inline basic vstr functions - objnone: use mp_generic_unary_op instead of custom one - showbc: make printf's go to the platform print stream - remove 'name' member from mp_obj_module_t struct - builtinimport: fix nanbox build after change to better handle -m modules - stream: remove unnecessary check for NULL return from vstr_extend - py.mk: suppress some compiler warnings when building berkeley-db - shrink mp_arg_t struct by using reduced-size integer members - update opcode format table because 3 opcodes were removed, 1 added - parse: only replace constants that are standalone identifiers - py.mk: add support for building modussl_mbedtls - only store the exception instance on Py stack in bytecode try block - vm: use MP_OBJ_FROM_PTR to cast a type to an object - modmicropython: add micropython.const, alias for identity function - objstr: remove unreachable function used only for terse error msgs - emitbc: remove/refactor unreachable code, to improve coverage - objfun: remove unnecessary check for viper fun with 5 or more args - objfun: use if instead of switch to check return value of VM execute - objset: use mp_check_self() to check args of set/frozenset methods - objset: ensure that use of frozenset.update raises an exception - compile: fix async-for/async-with to work with simpler exc on stack - scope: use lookup-table to determine a scope's simple name - scope: shrink scope_t struct by 1 machine word - scope: factor common code to find locals and close over them - compile: fix typo when checking for parse-node kind - argcheck: simplify if-chain so that the last one is the default - objbool: defer bool's unary op implementation to small int - objbool: make a slight simplification of bool constructor - modstruct: remove unreachable code, and add comment about CPy diff - add mp_raise_OSError(errno) helper function - objstringio: add readinto() method - modmicropython: add micropython.opt_level([value]) function - compile: remove unreachable code - mpz: in divmod, replace check for rhs!=0 with assert - mpz: use assert to verify mpz does not have a fixed digit buffer - factor duplicated function to calculate size of formatted int - objint: use size_t for arguments that measure bytes/sizes - compile: remove debugging code for compiler dispatch - lexer: remove unnecessary code, and unreachable code - vstr: combine vstr_new_size with vstr_new since they are rarely used - objdict: fix optimisation for allocating result in fromkeys - objdict: actually provide the key that failed in KeyError exception - use mp_raise_msg helper function where appropriate - add the module specified by -m to sys.modules as '__main__' extmod: - modussl_mbedtls: initial implementation of mbedTLS ussl module - uctypes: allow full 32-bit address range - modubinascii: fix crc32() function on 32-bit platforms - modussl_mbedtls: implement key= and cert= args to wrap_socket() - modussl_mbedtls: use 2-component include paths - machine_i2c: add clock stretching support - modussl_mbedtls: add server_hostname param for wrap_socket() - uzlib: add tinfgzip.c (gzip header parsing) from upstream - moduzlib: DecompIO: Add support for gzip-formatted streams - uzlib/: update uzlib to v2.0.3 - vfs_fat: add fat_vfs_statvfs(), reused from stmhal - machine_i2c: add support for the addrsize parameter in mem xfers - machine_spi: simplify SPI xfer function to only take one buf len - machine_spi: factor out software SPI code from esp8266 to extmod - machine_spi: use delay_half, not baudrate, for internal timing - machine_spi: add optional support for fast software SPI - vfs_fat: use mp_raise_OSError helper function - modlwip: use mp_raise_OSError helper function - use mp_raise_OSError helper function - vfs_fat_file: use MP_Exxx errno constants - uzlib: update to upstream v2.1 - machine_i2c: use writes not reads in i2c.scan() - vfs_fat: add file and directory checks for remove and rmdir - modujson: implement ujson.load() to load JSON from a stream - modujson: fix nanbox build - utime_mphal: factor out implementations in terms of mp_hal_* for reuse - utime_mphal: sleep_us/ms(): Don't wait on negative argument - modussl_mbedtls: add dummy setblocking() method lib: - interrupt_char: factor out typical Ctrl+C handling from esp8266 port - cmsis: move CMSIS headers to lib/ - cmsis: remove CMSIS-DSP headers, they are unused - cmsis: upgrade CMSIS-CORE to V4.30 - utils/pyexec: don't treat SystemExit as "forced exit" - utils/pyexec: allow behaviour of SystemExit to be configurable drivers: - dht: use mp_raise_OSError helper function tools: - update upip to 0.8, fixes IPv6 support - upgrade upip to 1.0, fully self-hosted release (without fallbacks), and uses stream gzip decompression (step towards support for limited-heap baremetal systems) - upgrade upip to 1.1.3, initial support for running on a baremetal, low-heap systems (like esp8266), using Python module interface tests: - pyb: add test for ExtInt when doing swint while disabled - pyb: update exp file for previously updated extint test - extmod/urandom: add urandom tests for error cases - basics: add errno1 test, to check basics of uerrno module - extmod: add test for machine.time_pulse_us() - struct1: test "l" specifier to improve coverage - array1: add tests for "l", "L" array types to improve coverage - get cmdline verbose tests running again - run-tests: add --via-mpy option to run test from precompiled code - uzlib_decompio_gz: test for DecompIO with gzip bitstream - basics: add test case for overflowing Py stack in try-finally - micropython: add tests for const names being replaced in parser - cmdline/cmd_showbc: fix test now that 1 value is stored on stack - extmod/vfs_fat_ramdisk: add test for VFS.statvfs() - float: add test for parsing a float from an empty string - basics: add test for set.difference_update with arg being itself - basics: add further tests for nonlocal scoping and closures - import: add test for compiling "import a.b as c" - basics: add test constructing a set from a non-trivial expression - basics: add test for printing OSError when errno is unknown - run-tests: disable cmdline/cmd_showbc test on Windows - extmod/btree1: checks for put, seq, string print and unsupported binary op - fix expected output of verbose cmdline test - extmod/uzlib: test adaptive huffman tree for tinflate coverage - improve coverage of struct with test for non-compliant behaviour - io/write_ext: add description comment - io/bytesio_ext: add test for readinto() - micropython: add test for micropython.opt_level() function - improve test coverage of py/compile.c - extmod/vfs_fat: test coverage for remove() and rmdir() - extmod: add test for ujson.load() - extmod/vfs_fat: replace asserts with prints and expected outputs - micropython: add tests for heap_lock, and emergency exceptions - cmdline: improve coverage test for printing bytecode - improve coverage of array, range, dict, slice, exc, unicode - add test to print full KeyError exc from failed dict lookup - run-tests: enable extmod/machine1.py on pyboard unix port: - fix build for when MICROPY_PY_SOCKET=0 - modjni: implement subscription for object arrays - modjni: add array() top-level function to create Java array - modjni: array(): Support creation of object arrays - enable btree module for coverage build - use mp_raise_OSError helper function - use common RAISE_ERRNO macro from mphalport.h windows port: - enable MICROPY_PY_UERRNO qemu-arm port: - enable lots of extmods and enable tests for them stmhal port: - lcd: de-assert chip select after completing SPI transmission - {accel,lcd}: use GPIO_{set,clear}_pin - extint: force 0 to 1 transition on swint() - boards: add pllvalues.py script to compute PLL values for sysclk - boards: for OLIMEX_E407, enable UART1 and fix I2C1 mapping - use attribute to avoid inlining - put common definitions from linker files to common.ld - remove STM32CubeF2 HAL files, they are unused/unsupported - modmachine: fix clearing of reset-cause flags - add virtual com port support for STM32L476DISC - remove CMSIS STM32F2xx files, they are unused/unsupported - spi: simplify spi_transfer function to take only one buf len arg - mphalport: implement mp_hal_pin_{input,output,write} - spi: make machine.SPI class conform to correct API - mphalport: fix mp_hal_pin_write to use correct pin_mask - spi: use software SPI if no periph id given, even if pins given - spi: enable use of fast software SPI - fix linker map for STM32L476 chips - usbdev: add OUT endpoint to HID interface - usb: add support to receive USB HID messages from host - usb: use correct ClassData structure for HID receive - usb: use real packet size (not maximum) in HID receive - fix ESPRUINO_PICO by adding ld scripts with correct flash size - mphalport: change pin obj type to const pointer, to avoid casts - moduos: implement total-number-of-blocks field in statvfs - disable network and usocket for ESPRUINO_PICO - enable machine.time_pulse_us() function - use mp_raise_OSError helper function - pybstdio: use size_t instead of mp_uint_t - modutime: refactor to use extmod/utime_mphal.c - implement machine.soft_reset() - enable str.center(), str.[r]partition() and builtin compile() cc3200 port: - add ssl_version argument to ssl.wrap_socket() esp8266 port: - Makefile: rename SCRIPTDIR to FROZEN_DIR for consistency with FROZEN_MPY_DIR - ets_alt_task: ets_post: Should return 0 on success, !0 - failure - esp_mphal: add tentative change to mp_hal_stdin_rx_chr() to wait IRQ - extend system microsecond counter to 64-bits; use in ticks_ms - add uos.statvfs() to get filesystem status - moduos: move stat/statvfs funcs to sit within #if VFS guard - modmachine: idle(): Return number of CPU cycles spent idling - main: put /lib before / in sys.path - modpybrtc.c: implement machine.RTC.alarm_left() - make PY_UHASHLIB_SHA1 config depend on PY_USSL and SSL_AXTLS - add FLASH_MODE,FLASH_SIZE options for make deploy target - use mp_raise_OSError helper function - make neopixel support configurable - mpconfigport: enable MICROPY_PY_BUILTINS_SLICE_ATTRS - enable sys.{stdin,stdout,stderr}.buffer for raw serial access - enable importing of precompiled .mpy files - enable micropython.alloc_emergency_exception_buf() zephyr port: - initial Zephyr RTOS port, MicroPython part - initial Zephyr RTOS port, Zephyr part - add zephyr_getchar module to handle console input - switch to microkernel, required for network to work in background - automatically derive ARCH - support extra make targets - Makefile: automatically derive target-specific CFLAGS - use recently added "make outputexports" Zephyr target - add README - enable stack checking and micropython.mem_info() - enable frozen modules support - main: execute main.py frozen module on boot, if available - zephyr_getchar: add support for Ctrl+C handling - add Ctrl+C handling - implement the help() function - add copyright blurbs README: - remove issue-stats badges, the service is no longer available - mention _thread module availability in select ports docs: - library/pyb.SPI: init(): describe "bits" argument - library/machine: update description of disable/enable IRQ funcs - uos: add uos.statvfs() documentation - wipy: correct deep sleep current figure - wipy: small doc fixes - reference: add constrained.rst doc travis: - abandon mingw32 in favour of mingw-w64 - run feature and coverage test for precompiled mpy files examples: - network/http_client*: use \r\n line-endings in request
Diffstat (limited to 'tests/basics')
-rw-r--r--tests/basics/array1.py10
-rw-r--r--tests/basics/async_def.py16
-rw-r--r--tests/basics/async_def.py.exp3
-rw-r--r--tests/basics/async_with.py14
-rw-r--r--tests/basics/async_with.py.exp6
-rw-r--r--tests/basics/async_with2.py2
-rw-r--r--tests/basics/async_with2.py.exp2
-rw-r--r--tests/basics/builtin_range.py6
-rw-r--r--tests/basics/del_global.py5
-rw-r--r--tests/basics/dict1.py24
-rw-r--r--tests/basics/dict_views.py15
-rw-r--r--tests/basics/errno1.py18
-rw-r--r--tests/basics/errno1.py.exp3
-rw-r--r--tests/basics/for_range.py5
-rw-r--r--tests/basics/frozenset_add.py5
-rw-r--r--tests/basics/int_constfolding.py5
-rw-r--r--tests/basics/scope.py22
-rw-r--r--tests/basics/set1.py4
-rw-r--r--tests/basics/set_difference.py3
-rw-r--r--tests/basics/slice_attrs.py9
-rw-r--r--tests/basics/struct1.py14
-rw-r--r--tests/basics/syntaxerror.py4
-rw-r--r--tests/basics/try_finally2.py30
-rw-r--r--tests/basics/unpack1.py1
24 files changed, 210 insertions, 16 deletions
diff --git a/tests/basics/array1.py b/tests/basics/array1.py
index bce22cc57d..c45b883c94 100644
--- a/tests/basics/array1.py
+++ b/tests/basics/array1.py
@@ -6,6 +6,12 @@ i = array.array('I', [1, 2, 3])
print(i, len(i))
print(a[0])
print(i[-1])
+a = array.array('l', [-1])
+print(len(a), a[0])
+a1 = array.array('l', [1, 2, 3])
+a2 = array.array('L', [1, 2, 3])
+print(a2[1])
+print(a1 == a2)
# Empty arrays
print(len(array.array('h')))
@@ -15,6 +21,10 @@ print(array.array('i'))
print(bool(array.array('i')))
print(bool(array.array('i', [1])))
+# containment, with incorrect type
+print('12' in array.array('B', b'12'))
+print([] in array.array('B', b'12'))
+
# bad typecode
try:
array.array('X')
diff --git a/tests/basics/async_def.py b/tests/basics/async_def.py
new file mode 100644
index 0000000000..e345703d74
--- /dev/null
+++ b/tests/basics/async_def.py
@@ -0,0 +1,16 @@
+# test async def
+
+def dec(f):
+ print('decorator')
+ return f
+
+# test definition with a decorator
+@dec
+async def foo():
+ print('foo')
+
+coro = foo()
+try:
+ coro.send(None)
+except StopIteration:
+ print('StopIteration')
diff --git a/tests/basics/async_def.py.exp b/tests/basics/async_def.py.exp
new file mode 100644
index 0000000000..f555ace99a
--- /dev/null
+++ b/tests/basics/async_def.py.exp
@@ -0,0 +1,3 @@
+decorator
+foo
+StopIteration
diff --git a/tests/basics/async_with.py b/tests/basics/async_with.py
index 742f9ba993..5af0c5d955 100644
--- a/tests/basics/async_with.py
+++ b/tests/basics/async_with.py
@@ -3,8 +3,9 @@
class AContext:
async def __aenter__(self):
print('enter')
+ return 1
async def __aexit__(self, exc_type, exc, tb):
- print('exit')
+ print('exit', exc_type, exc)
async def f():
async with AContext():
@@ -15,3 +16,14 @@ try:
o.send(None)
except StopIteration:
print('finished')
+
+async def g():
+ async with AContext() as ac:
+ print(ac)
+ raise ValueError('error')
+
+o = g()
+try:
+ o.send(None)
+except ValueError:
+ print('ValueError')
diff --git a/tests/basics/async_with.py.exp b/tests/basics/async_with.py.exp
index 1e9176af7b..d00b18c969 100644
--- a/tests/basics/async_with.py.exp
+++ b/tests/basics/async_with.py.exp
@@ -1,4 +1,8 @@
enter
body
-exit
+exit None None
finished
+enter
+1
+exit <class 'ValueError'> error
+ValueError
diff --git a/tests/basics/async_with2.py b/tests/basics/async_with2.py
index 0ebec489fe..44421ae917 100644
--- a/tests/basics/async_with2.py
+++ b/tests/basics/async_with2.py
@@ -20,7 +20,7 @@ class AContext:
print('enter')
print('f returned:', await f(10))
async def __aexit__(self, exc_type, exc, tb):
- print('exit')
+ print('exit', exc_type, exc)
print('f returned:', await f(20))
async def coro():
diff --git a/tests/basics/async_with2.py.exp b/tests/basics/async_with2.py.exp
index dd5a1c549a..76b173b4c2 100644
--- a/tests/basics/async_with2.py.exp
+++ b/tests/basics/async_with2.py.exp
@@ -9,7 +9,7 @@ coro yielded: 31
coro yielded: 32
body f returned: 33
body end
-exit
+exit None None
f start: 20
coro yielded: 21
coro yielded: 22
diff --git a/tests/basics/builtin_range.py b/tests/basics/builtin_range.py
index 9110cf12cd..59fc0344a4 100644
--- a/tests/basics/builtin_range.py
+++ b/tests/basics/builtin_range.py
@@ -50,3 +50,9 @@ try:
range(1)[0] = 1
except TypeError:
print("TypeError")
+
+# bad attr (can't store)
+try:
+ range(4).start = 0
+except AttributeError:
+ print('AttributeError')
diff --git a/tests/basics/del_global.py b/tests/basics/del_global.py
index 77d11cb3c4..d740357b03 100644
--- a/tests/basics/del_global.py
+++ b/tests/basics/del_global.py
@@ -54,3 +54,8 @@ try:
print(c)
except NameError:
print("NameError")
+
+a = 1
+b = 2
+c = 3
+del (a, (b, c))
diff --git a/tests/basics/dict1.py b/tests/basics/dict1.py
index c70ca588a7..20fa9def31 100644
--- a/tests/basics/dict1.py
+++ b/tests/basics/dict1.py
@@ -16,3 +16,27 @@ while x < 100:
d[x] = x
x += 1
print(d[50])
+
+# equality operator on dicts of different size
+print({} == {1:1})
+
+# equality operator on dicts of same size but with different keys
+print({1:1} == {2:1})
+
+# value not found
+try:
+ {}[0]
+except KeyError as er:
+ print('KeyError', er, repr(er), er.args)
+
+# unsupported unary op
+try:
+ +{}
+except TypeError:
+ print('TypeError')
+
+# unsupported binary op
+try:
+ {} + {}
+except TypeError:
+ print('TypeError')
diff --git a/tests/basics/dict_views.py b/tests/basics/dict_views.py
index fbf63fa0ac..7ebcc1f56d 100644
--- a/tests/basics/dict_views.py
+++ b/tests/basics/dict_views.py
@@ -3,4 +3,19 @@ for m in d.items, d.values, d.keys:
print(m())
print(list(m()))
+# print a view with more than one item
+print({1:1, 2:1}.values())
+
+# unsupported binary op on a dict values view
+try:
+ {1:1}.values() + 1
+except TypeError:
+ print('TypeError')
+
+# unsupported binary op on a dict keys view
+try:
+ {1:1}.keys() + 1
+except TypeError:
+ print('TypeError')
+
# set operations still to come
diff --git a/tests/basics/errno1.py b/tests/basics/errno1.py
new file mode 100644
index 0000000000..eae1bbe1b4
--- /dev/null
+++ b/tests/basics/errno1.py
@@ -0,0 +1,18 @@
+# test errno's and uerrno module
+
+try:
+ import uerrno
+except ImportError:
+ print("SKIP")
+ import sys
+ sys.exit()
+
+# check that constants exist and are integers
+print(type(uerrno.EIO))
+
+# check that errors are rendered in a nice way
+msg = str(OSError(uerrno.EIO))
+print(msg[:7], msg[-5:])
+
+# check that unknown errno is still rendered
+print(str(OSError(9999)))
diff --git a/tests/basics/errno1.py.exp b/tests/basics/errno1.py.exp
new file mode 100644
index 0000000000..c3703df4a2
--- /dev/null
+++ b/tests/basics/errno1.py.exp
@@ -0,0 +1,3 @@
+<class 'int'>
+[Errno ] EIO
+9999
diff --git a/tests/basics/for_range.py b/tests/basics/for_range.py
index ddff5ebd44..58a8f7caa7 100644
--- a/tests/basics/for_range.py
+++ b/tests/basics/for_range.py
@@ -35,6 +35,11 @@ try:
except TypeError:
print('TypeError')
try:
+ for x in range(start=0, end=1):
+ print(x)
+except TypeError:
+ print('TypeError')
+try:
for x in range(0, 1, step=1):
print(x)
except TypeError:
diff --git a/tests/basics/frozenset_add.py b/tests/basics/frozenset_add.py
index 50615775bd..415a8c2e13 100644
--- a/tests/basics/frozenset_add.py
+++ b/tests/basics/frozenset_add.py
@@ -10,3 +10,8 @@ try:
print(s.add(5))
except AttributeError:
print("AttributeError")
+
+try:
+ print(s.update([5]))
+except AttributeError:
+ print("AttributeError")
diff --git a/tests/basics/int_constfolding.py b/tests/basics/int_constfolding.py
index c01f964daa..aa38fa6b80 100644
--- a/tests/basics/int_constfolding.py
+++ b/tests/basics/int_constfolding.py
@@ -38,3 +38,8 @@ print(-123 // 7, -123 % 7)
print(123 // -7, 123 % -7)
print(-123 // -7, -123 % -7)
+# zero big-num on rhs
+print(1 + ((1 << 65) - (1 << 65)))
+
+# negative big-num on rhs
+print(1 + (-(1 << 65)))
diff --git a/tests/basics/scope.py b/tests/basics/scope.py
index 3aecc0b8d4..11704c482a 100644
--- a/tests/basics/scope.py
+++ b/tests/basics/scope.py
@@ -19,3 +19,25 @@ def f():
g()
return a
print(f())
+
+# nonlocal at inner-inner level (h)
+def f():
+ x = 1
+ def g():
+ def h():
+ nonlocal x
+ return x
+ return h
+ return g
+print(f()()())
+
+# nonlocal declared at outer level (g), and referenced by inner level (h)
+def f():
+ x = 1
+ def g():
+ nonlocal x
+ def h():
+ return x
+ return h
+ return g
+print(f()()())
diff --git a/tests/basics/set1.py b/tests/basics/set1.py
index 6afd9eb5ef..6ea69e4f05 100644
--- a/tests/basics/set1.py
+++ b/tests/basics/set1.py
@@ -6,6 +6,10 @@ print(s)
s = {3, 4, 3, 1}
print(sorted(s))
+# expression in constructor
+s = {1 + len(s)}
+print(s)
+
# Sets are not hashable
try:
{s: 1}
diff --git a/tests/basics/set_difference.py b/tests/basics/set_difference.py
index abfcbe7d63..97b63a8150 100644
--- a/tests/basics/set_difference.py
+++ b/tests/basics/set_difference.py
@@ -14,3 +14,6 @@ print(s.difference_update({1}))
print(sorted(s))
print(s.difference_update({1}, [2]))
print(sorted(s))
+
+s.difference_update(s)
+print(s)
diff --git a/tests/basics/slice_attrs.py b/tests/basics/slice_attrs.py
index 76368a78c6..67456ff8e6 100644
--- a/tests/basics/slice_attrs.py
+++ b/tests/basics/slice_attrs.py
@@ -14,3 +14,12 @@ except:
A()[1:2:3]
+
+# test storing to attr (shouldn't be allowed)
+class B:
+ def __getitem__(self, idx):
+ try:
+ idx.start = 0
+ except AttributeError:
+ print('AttributeError')
+B()[:]
diff --git a/tests/basics/struct1.py b/tests/basics/struct1.py
index 857e171c10..b53a9c8bc0 100644
--- a/tests/basics/struct1.py
+++ b/tests/basics/struct1.py
@@ -10,6 +10,8 @@ print(struct.unpack(">bI", b"\x80\0\0\x01\0"))
# 32-bit little-endian specific
#print(struct.unpack("bI", b"\x80\xaa\x55\xaa\0\0\x01\0"))
+print(struct.pack("<l", 1))
+print(struct.pack(">l", 1))
print(struct.pack("<i", 1))
print(struct.pack(">i", 1))
print(struct.pack("<h", 1))
@@ -101,15 +103,3 @@ try:
print(struct.unpack_from('<b', buf, -11))
except:
print('struct.error')
-
-# pack with too many args, not checked by uPy
-#try:
-# print(struct.pack('ii', 1, 2, 3))
-#except:
-# print('struct.error')
-
-# pack with too few args, not checked by uPy
-#try:
-# print(struct.pack('ii', 1))
-#except:
-# print('struct.error')
diff --git a/tests/basics/syntaxerror.py b/tests/basics/syntaxerror.py
index 2ae0183f8b..e5cbbac060 100644
--- a/tests/basics/syntaxerror.py
+++ b/tests/basics/syntaxerror.py
@@ -49,6 +49,9 @@ test_syntax("f[0]**2 = 1")
# can't assign to empty tuple
test_syntax("() = 1")
+# can't have *x on RHS
+test_syntax("x = *x")
+
# can't have multiple *x on LHS
test_syntax("*a, *b = c")
@@ -76,6 +79,7 @@ test_syntax("continue")
test_syntax("return")
test_syntax("yield")
test_syntax("nonlocal a")
+test_syntax("await 1")
# error on uPy, warning on CPy
#test_syntax("def f():\n a = 1\n global a")
diff --git a/tests/basics/try_finally2.py b/tests/basics/try_finally2.py
new file mode 100644
index 0000000000..3c4171d91f
--- /dev/null
+++ b/tests/basics/try_finally2.py
@@ -0,0 +1,30 @@
+# check that the Python stack does not overflow when the finally
+# block itself uses more stack than the rest of the function
+def f1(a, b):
+ pass
+def test1():
+ val = 1
+ try:
+ raise ValueError()
+ finally:
+ f1(2, 2) # use some stack
+ print(val) # check that the local variable is the same
+try:
+ test1()
+except ValueError:
+ pass
+
+# same as above but with 3 args instead of 2, to use an extra stack entry
+def f2(a, b, c):
+ pass
+def test2():
+ val = 1
+ try:
+ raise ValueError()
+ finally:
+ f2(2, 2, 2) # use some stack
+ print(val) # check that the local variable is the same
+try:
+ test2()
+except ValueError:
+ pass
diff --git a/tests/basics/unpack1.py b/tests/basics/unpack1.py
index 10e01dea06..0e8ec592c9 100644
--- a/tests/basics/unpack1.py
+++ b/tests/basics/unpack1.py
@@ -12,6 +12,7 @@ a, b, c = range(3); print(a, b, c)
(a,) = range(1); print(a)
(a, b) = range(2); print(a, b)
(a, b, c) = range(3); print(a, b, c)
+(a, (b, c)) = [-1, range(2)]; print(a, b, c)
# lists