summaryrefslogtreecommitdiffstatshomepage
path: root/tests
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
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')
-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
-rw-r--r--tests/cmdline/cmd_showbc.py17
-rw-r--r--tests/cmdline/cmd_showbc.py.exp138
-rw-r--r--tests/cmdline/cmd_verbose.py.exp8
-rw-r--r--tests/cmdline/repl_basic.py1
-rw-r--r--tests/cmdline/repl_basic.py.exp2
-rw-r--r--tests/extmod/btree1.py20
-rw-r--r--tests/extmod/btree1.py.exp6
-rw-r--r--tests/extmod/machine_pulse.py54
-rw-r--r--tests/extmod/machine_pulse.py.exp9
-rw-r--r--tests/extmod/ujson_load.py11
-rw-r--r--tests/extmod/urandom_basic.py6
-rw-r--r--tests/extmod/urandom_extra.py37
-rw-r--r--tests/extmod/uzlib_decompio_gz.py39
-rw-r--r--tests/extmod/uzlib_decompio_gz.py.exp11
-rw-r--r--tests/extmod/uzlib_decompress.py2
-rw-r--r--tests/extmod/vfs_fat_ramdisk.py53
-rw-r--r--tests/extmod/vfs_fat_ramdisk.py.exp19
-rw-r--r--tests/float/float1.py4
-rw-r--r--tests/import/import2a.py3
-rw-r--r--tests/import/import_pkg1.py5
-rw-r--r--tests/io/bytesio_ext.py5
-rw-r--r--tests/io/write_ext.py2
-rw-r--r--tests/micropython/const.py2
-rw-r--r--tests/micropython/const2.py34
-rw-r--r--tests/micropython/const2.py.exp4
-rw-r--r--tests/micropython/const_error.py2
-rw-r--r--tests/micropython/emg_exc.py20
-rw-r--r--tests/micropython/emg_exc.py.exp1
-rw-r--r--tests/micropython/heap_lock.py14
-rw-r--r--tests/micropython/heap_lock.py.exp2
-rw-r--r--tests/micropython/heapalloc.py13
-rw-r--r--tests/micropython/opt_level.py14
-rw-r--r--tests/micropython/opt_level.py.exp4
-rw-r--r--tests/micropython/viper_args.py8
-rw-r--r--tests/misc/non_compliant.py31
-rw-r--r--tests/misc/non_compliant.py.exp6
-rw-r--r--tests/pyb/extint.py9
-rw-r--r--tests/pyb/extint.py.exp1
-rwxr-xr-xtests/run-tests37
-rw-r--r--tests/unicode/unicode.py5
64 files changed, 798 insertions, 87 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
diff --git a/tests/cmdline/cmd_showbc.py b/tests/cmdline/cmd_showbc.py
index 9989a7229a..2f4e953bb2 100644
--- a/tests/cmdline/cmd_showbc.py
+++ b/tests/cmdline/cmd_showbc.py
@@ -34,12 +34,14 @@ def f():
# subscript
p = b[0]
b[0] = p
+ b[0] += p
# slice
a = b[::]
# sequenc unpacking
a, b = c
+ a, *a = a
# tuple swapping
a, b = b, a
@@ -79,6 +81,7 @@ def f():
b
while not a:
b
+ a = a or a
# for loop
for a in b:
@@ -92,6 +95,11 @@ def f():
b
finally:
c
+ while a:
+ try:
+ break
+ except:
+ pass
# with
with a:
@@ -117,6 +125,12 @@ def f():
return
return 1
+# function with lots of locals
+def f():
+ l1 = l2 = l3 = l4 = l5 = l6 = l7 = l8 = l9 = l10 = 1
+ m1 = m2 = m3 = m4 = m5 = m6 = m7 = m8 = m9 = m10 = 2
+ l10 + m10
+
# functions with default args
def f(a=1):
pass
@@ -133,3 +147,6 @@ def f():
# class
class Class:
pass
+
+# delete name
+del Class
diff --git a/tests/cmdline/cmd_showbc.py.exp b/tests/cmdline/cmd_showbc.py.exp
index 10be688388..1f0c054cf9 100644
--- a/tests/cmdline/cmd_showbc.py.exp
+++ b/tests/cmdline/cmd_showbc.py.exp
@@ -5,11 +5,13 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
arg names:
(N_STATE 3)
(N_EXC_STACK 0)
- bc=-3 line=1
+ bc=-1 line=1
########
- bc=\\d\+ line=134
+ bc=\\d\+ line=152
00 MAKE_FUNCTION \.\+
\\d\+ STORE_NAME f
+\\d\+ MAKE_FUNCTION \.\+
+\\d\+ STORE_NAME f
\\d\+ LOAD_CONST_SMALL_INT 1
\\d\+ BUILD_TUPLE 1
\\d\+ LOAD_NULL
@@ -22,21 +24,21 @@ arg names:
\\d\+ LOAD_CONST_STRING 'Class'
\\d\+ CALL_FUNCTION n=2 nkw=0
\\d\+ STORE_NAME Class
+\\d\+ DELETE_NAME Class
\\d\+ LOAD_CONST_NONE
\\d\+ RETURN_VALUE
File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ bytes)
Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
########
-\.\+5b
-arg names:
+\.\+rg names:
(N_STATE 22)
(N_EXC_STACK 2)
(INIT_CELL 14)
(INIT_CELL 15)
(INIT_CELL 16)
- bc=-6 line=1
+ bc=-4 line=1
########
- bc=\\d\+ line=118
+ bc=\\d\+ line=126
00 LOAD_CONST_NONE
01 LOAD_CONST_FALSE
02 BINARY_OP 5 __add__
@@ -86,8 +88,7 @@ arg names:
\\d\+ UNARY_OP 4
\\d\+ STORE_FAST 9
\\d\+ LOAD_FAST 0
-\\d\+ UNARY_OP 0
-\\d\+ NOT
+\\d\+ UNARY_OP 6
\\d\+ STORE_FAST 10
\\d\+ LOAD_FAST 0
\\d\+ LOAD_DEREF 14
@@ -108,8 +109,7 @@ arg names:
\\d\+ LOAD_DEREF 14
\\d\+ LOAD_FAST 1
\\d\+ BINARY_OP 27 __eq__
-\\d\+ UNARY_OP 0
-\\d\+ NOT
+\\d\+ UNARY_OP 6
\\d\+ STORE_FAST 10
\\d\+ LOAD_DEREF 14
\\d\+ LOAD_ATTR c (cache=0)
@@ -126,6 +126,14 @@ arg names:
\\d\+ LOAD_CONST_SMALL_INT 0
\\d\+ STORE_SUBSCR
\\d\+ LOAD_DEREF 14
+\\d\+ LOAD_CONST_SMALL_INT 0
+\\d\+ DUP_TOP_TWO
+\\d\+ LOAD_SUBSCR
+\\d\+ LOAD_FAST 12
+\\d\+ BINARY_OP 18 __iadd__
+\\d\+ ROT_THREE
+\\d\+ STORE_SUBSCR
+\\d\+ LOAD_DEREF 14
\\d\+ LOAD_CONST_NONE
\\d\+ LOAD_CONST_NONE
\\d\+ BUILD_SLICE 2
@@ -135,6 +143,10 @@ arg names:
\\d\+ UNPACK_SEQUENCE 2
\\d\+ STORE_FAST 0
\\d\+ STORE_DEREF 14
+\\d\+ LOAD_FAST 0
+\\d\+ UNPACK_EX 1
+\\d\+ STORE_FAST 0
+\\d\+ STORE_FAST 0
\\d\+ LOAD_DEREF 14
\\d\+ LOAD_FAST 0
\\d\+ ROT_TWO
@@ -228,6 +240,10 @@ arg names:
\\d\+ POP_TOP
\\d\+ LOAD_FAST 0
\\d\+ POP_JUMP_IF_FALSE \\d\+
+\\d\+ LOAD_FAST 0
+\\d\+ JUMP_IF_TRUE_OR_POP \\d\+
+\\d\+ LOAD_FAST 0
+\\d\+ STORE_FAST 0
\\d\+ LOAD_DEREF 14
\\d\+ GET_ITER
\\d\+ FOR_ITER \\d\+
@@ -244,8 +260,6 @@ arg names:
\\d\+ POP_BLOCK
\\d\+ JUMP \\d\+
\\d\+ POP_TOP
-\\d\+ POP_TOP
-\\d\+ POP_TOP
\\d\+ LOAD_DEREF 14
\\d\+ POP_TOP
\\d\+ POP_EXCEPT
@@ -256,6 +270,17 @@ arg names:
\\d\+ LOAD_FAST 1
\\d\+ POP_TOP
\\d\+ END_FINALLY
+\\d\+ JUMP \\d\+
+\\d\+ SETUP_EXCEPT \\d\+
+\\d\+ UNWIND_JUMP \\d\+ 1
+\\d\+ POP_BLOCK
+\\d\+ JUMP \\d\+
+\\d\+ POP_TOP
+\\d\+ POP_EXCEPT
+\\d\+ JUMP \\d\+
+\\d\+ END_FINALLY
+\\d\+ LOAD_FAST 0
+\\d\+ POP_JUMP_IF_TRUE \\d\+
\\d\+ LOAD_FAST 0
\\d\+ SETUP_WITH \\d\+
\\d\+ POP_TOP
@@ -296,13 +321,68 @@ arg names:
File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ bytes)
Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
########
+\.\+rg names:
+(N_STATE 22)
+(N_EXC_STACK 0)
+ bc=-1 line=1
+########
+ bc=\\d\+ line=132
+00 LOAD_CONST_SMALL_INT 1
+01 DUP_TOP
+02 STORE_FAST 0
+03 DUP_TOP
+04 STORE_FAST 1
+05 DUP_TOP
+06 STORE_FAST 2
+07 DUP_TOP
+08 STORE_FAST 3
+09 DUP_TOP
+10 STORE_FAST 4
+11 DUP_TOP
+12 STORE_FAST 5
+13 DUP_TOP
+14 STORE_FAST 6
+15 DUP_TOP
+16 STORE_FAST 7
+17 DUP_TOP
+18 STORE_FAST 8
+19 STORE_FAST 9
+20 LOAD_CONST_SMALL_INT 2
+21 DUP_TOP
+22 STORE_FAST 10
+23 DUP_TOP
+24 STORE_FAST 11
+25 DUP_TOP
+26 STORE_FAST 12
+27 DUP_TOP
+28 STORE_FAST 13
+29 DUP_TOP
+30 STORE_FAST 14
+31 DUP_TOP
+32 STORE_FAST 15
+33 DUP_TOP
+34 STORE_FAST_N 16
+36 DUP_TOP
+37 STORE_FAST_N 17
+39 DUP_TOP
+40 STORE_FAST_N 18
+42 STORE_FAST_N 19
+44 LOAD_FAST 9
+45 LOAD_FAST_N 19
+47 BINARY_OP 5 __add__
+48 POP_TOP
+49 LOAD_CONST_NONE
+50 RETURN_VALUE
+File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ bytes)
+Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
+########
\.\+5b
arg names: a
(N_STATE 5)
(N_EXC_STACK 0)
(INIT_CELL 0)
########
- bc=\\d\+ line=124
+ bc=\\d\+ line=138
00 LOAD_CONST_SMALL_INT 2
01 BUILD_TUPLE 1
03 LOAD_NULL
@@ -318,10 +398,10 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
arg names:
(N_STATE 2)
(N_EXC_STACK 0)
- bc=-3 line=1
- bc=0 line=129
- bc=3 line=130
- bc=6 line=131
+ bc=-1 line=1
+ bc=0 line=143
+ bc=3 line=144
+ bc=6 line=145
00 LOAD_CONST_NONE
01 YIELD_VALUE
02 POP_TOP
@@ -342,14 +422,14 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
arg names:
(N_STATE 1)
(N_EXC_STACK 0)
- bc=-3 line=1
- bc=10 line=135
+ bc=-1 line=1
+ bc=13 line=149
00 LOAD_NAME __name__ (cache=0)
-03 STORE_NAME __module__
-05 LOAD_CONST_STRING 'Class'
-08 STORE_NAME __qualname__
-10 LOAD_CONST_NONE
-11 RETURN_VALUE
+04 STORE_NAME __module__
+07 LOAD_CONST_STRING 'Class'
+10 STORE_NAME __qualname__
+13 LOAD_CONST_NONE
+14 RETURN_VALUE
File cmdline/cmd_showbc.py, code block '<genexpr>' (descriptor: \.\+, bytecode @\.\+ bytes)
Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
########
@@ -384,7 +464,7 @@ arg names: * * *
07 LOAD_DEREF 1
09 POP_JUMP_IF_FALSE 3
12 LOAD_DEREF 0
-14 LIST_APPEND 2
+14 STORE_COMP 8
16 JUMP 3
19 RETURN_VALUE
File cmdline/cmd_showbc.py, code block '<dictcomp>' (descriptor: \.\+, bytecode @\.\+ bytes)
@@ -404,7 +484,7 @@ arg names: * * *
09 POP_JUMP_IF_FALSE 3
12 LOAD_DEREF 0
14 LOAD_DEREF 0
-16 MAP_ADD 2
+16 STORE_COMP 13
18 JUMP 3
21 RETURN_VALUE
File cmdline/cmd_showbc.py, code block 'closure' (descriptor: \.\+, bytecode @\.\+ bytes)
@@ -416,7 +496,7 @@ arg names: *
(N_EXC_STACK 0)
bc=-\\d\+ line=1
########
- bc=\\d\+ line=105
+ bc=\\d\+ line=113
00 LOAD_DEREF 0
02 LOAD_CONST_SMALL_INT 1
03 BINARY_OP 5 __add__
@@ -435,7 +515,7 @@ arg names: * b
(N_EXC_STACK 0)
bc=-\\d\+ line=1
########
- bc=\\d\+ line=125
+ bc=\\d\+ line=139
00 LOAD_FAST 1
01 LOAD_DEREF 0
03 BINARY_OP 5 __add__
@@ -443,4 +523,4 @@ arg names: * b
mem: total=\\d\+, current=\\d\+, peak=\\d\+
stack: \\d\+ out of \\d\+
GC: total: \\d\+, used: \\d\+, free: \\d\+
- No. of 1-blocks: \\d\+, 2-blocks: \\d\+, max blk sz: \\d\+
+ No. of 1-blocks: \\d\+, 2-blocks: \\d\+, max blk sz: \\d\+, max free sz: \\d\+
diff --git a/tests/cmdline/cmd_verbose.py.exp b/tests/cmdline/cmd_verbose.py.exp
index 3e115f9ae6..f56226129e 100644
--- a/tests/cmdline/cmd_verbose.py.exp
+++ b/tests/cmdline/cmd_verbose.py.exp
@@ -1,13 +1,12 @@
-1
File cmdline/cmd_verbose.py, code block '<module>' (descriptor: \.\+, bytecode \.\+ bytes)
Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
- 08 \.\+
+ 02 \.\+
########
\.\+5b
arg names:
(N_STATE 2)
(N_EXC_STACK 0)
- bc=-3 line=1
+ bc=-1 line=1
bc=0 line=3
00 LOAD_NAME print (cache=0)
04 LOAD_CONST_SMALL_INT 1
@@ -15,7 +14,8 @@ arg names:
07 POP_TOP
08 LOAD_CONST_NONE
09 RETURN_VALUE
+1
mem: total=\\d\+, current=\\d\+, peak=\\d\+
stack: \\d\+ out of \\d\+
GC: total: \\d\+, used: \\d\+, free: \\d\+
- No. of 1-blocks: \\d\+, 2-blocks: \\d\+, max blk sz: \\d\+
+ No. of 1-blocks: \\d\+, 2-blocks: \\d\+, max blk sz: \\d\+, max free sz: \\d\+
diff --git a/tests/cmdline/repl_basic.py b/tests/cmdline/repl_basic.py
index b416493dce..cbd5d3a4ac 100644
--- a/tests/cmdline/repl_basic.py
+++ b/tests/cmdline/repl_basic.py
@@ -1,3 +1,4 @@
# basic REPL tests
print(1)

+2
diff --git a/tests/cmdline/repl_basic.py.exp b/tests/cmdline/repl_basic.py.exp
index 96b8c28dce..2b390ea98b 100644
--- a/tests/cmdline/repl_basic.py.exp
+++ b/tests/cmdline/repl_basic.py.exp
@@ -5,4 +5,6 @@ Use \.\+
1
>>> print(1)
1
+>>> 2
+2
>>>
diff --git a/tests/extmod/btree1.py b/tests/extmod/btree1.py
index c96cce92d6..6629837661 100644
--- a/tests/extmod/btree1.py
+++ b/tests/extmod/btree1.py
@@ -1,6 +1,7 @@
try:
import btree
import uio
+ import uerrno
except ImportError:
print("SKIP")
import sys
@@ -15,6 +16,9 @@ db[b"foo1"] = b"bar1"
db[b"foo2"] = b"bar2"
db[b"bar1"] = b"foo1"
+dbstr = str(db)
+print(dbstr[:7], dbstr[-1:])
+
print(db[b"foo2"])
try:
print(db[b"foo"])
@@ -56,14 +60,30 @@ print("---")
for k, v in db.items(None, None, btree.DESC):
print((k, v))
+print(db.seq(1, b"foo1"))
+print(db.seq(1, b"qux"))
+
+try:
+ db.seq(b"foo1")
+except OSError as e:
+ print(e.args[0] == uerrno.EINVAL)
+
print(list(db.keys()))
print(list(db.values()))
for k in db:
print(k)
+db.put(b"baz1", b"qux1")
+
print("foo1", "foo1" in db)
print("foo2", "foo2" in db)
+print("baz1", "baz1" in db)
+
+try:
+ print(db + db[b"foo1"])
+except TypeError:
+ print("TypeError")
db.close()
f.close()
diff --git a/tests/extmod/btree1.py.exp b/tests/extmod/btree1.py.exp
index 2983a09874..a467252300 100644
--- a/tests/extmod/btree1.py.exp
+++ b/tests/extmod/btree1.py.exp
@@ -1,3 +1,4 @@
+<btree >
b'bar2'
KeyError
None
@@ -25,6 +26,9 @@ KeyError
(b'foo3', b'bar3')
(b'foo1', b'bar1')
(b'bar1', b'foo1')
+(b'foo1', b'bar1')
+None
+True
[b'bar1', b'foo1', b'foo3']
[b'foo1', b'bar1', b'bar3']
b'bar1'
@@ -32,3 +36,5 @@ b'foo1'
b'foo3'
foo1 True
foo2 False
+baz1 True
+TypeError
diff --git a/tests/extmod/machine_pulse.py b/tests/extmod/machine_pulse.py
new file mode 100644
index 0000000000..b6e1264351
--- /dev/null
+++ b/tests/extmod/machine_pulse.py
@@ -0,0 +1,54 @@
+try:
+ import umachine as machine
+except ImportError:
+ import machine
+try:
+ machine.PinBase
+ machine.time_pulse_us
+except AttributeError:
+ print("SKIP")
+ import sys
+ sys.exit()
+
+
+class ConstPin(machine.PinBase):
+
+ def __init__(self, value):
+ self.v = value
+
+ def value(self, v=None):
+ if v is None:
+ return self.v
+ else:
+ self.v = v
+
+
+class TogglePin(machine.PinBase):
+
+ def __init__(self):
+ self.v = 0
+
+ def value(self, v=None):
+ if v is None:
+ self.v = 1 - self.v
+ print("value:", self.v)
+ return self.v
+
+
+p = TogglePin()
+
+t = machine.time_pulse_us(p, 1)
+print(type(t))
+t = machine.time_pulse_us(p, 0)
+print(type(t))
+
+p = ConstPin(0)
+try:
+ machine.time_pulse_us(p, 1, 10)
+except OSError:
+ print("OSError")
+
+try:
+ machine.time_pulse_us(p, 0, 10)
+except OSError:
+ print("OSError")
diff --git a/tests/extmod/machine_pulse.py.exp b/tests/extmod/machine_pulse.py.exp
new file mode 100644
index 0000000000..f9a4742181
--- /dev/null
+++ b/tests/extmod/machine_pulse.py.exp
@@ -0,0 +1,9 @@
+value: 1
+value: 0
+<class 'int'>
+value: 1
+value: 0
+value: 1
+<class 'int'>
+OSError
+OSError
diff --git a/tests/extmod/ujson_load.py b/tests/extmod/ujson_load.py
new file mode 100644
index 0000000000..bf484a2074
--- /dev/null
+++ b/tests/extmod/ujson_load.py
@@ -0,0 +1,11 @@
+try:
+ from uio import StringIO
+ import ujson as json
+except:
+ from io import StringIO
+ import json
+
+print(json.load(StringIO('null')))
+print(json.load(StringIO('"abc\\u0064e"')))
+print(json.load(StringIO('[false, true, 1, -2]')))
+print(json.load(StringIO('{"a":true}')))
diff --git a/tests/extmod/urandom_basic.py b/tests/extmod/urandom_basic.py
index 7e4d8bf34c..bf00035bd5 100644
--- a/tests/extmod/urandom_basic.py
+++ b/tests/extmod/urandom_basic.py
@@ -17,3 +17,9 @@ random.seed(1)
r = random.getrandbits(16)
random.seed(1)
print(random.getrandbits(16) == r)
+
+# check that it throws an error for zero bits
+try:
+ random.getrandbits(0)
+except ValueError:
+ print('ValueError')
diff --git a/tests/extmod/urandom_extra.py b/tests/extmod/urandom_extra.py
index a9ecd881de..004fb10cc4 100644
--- a/tests/extmod/urandom_extra.py
+++ b/tests/extmod/urandom_extra.py
@@ -16,6 +16,31 @@ for i in range(50):
assert 2 <= random.randrange(2, 6) < 6
assert -2 <= random.randrange(-2, 2) < 2
assert random.randrange(1, 9, 2) in (1, 3, 5, 7)
+ assert random.randrange(2, 1, -1) in (1, 2)
+
+# empty range
+try:
+ random.randrange(0)
+except ValueError:
+ print('ValueError')
+
+# empty range
+try:
+ random.randrange(2, 1)
+except ValueError:
+ print('ValueError')
+
+# zero step
+try:
+ random.randrange(2, 1, 0)
+except ValueError:
+ print('ValueError')
+
+# empty range
+try:
+ random.randrange(2, 1, 1)
+except ValueError:
+ print('ValueError')
print('randint')
for i in range(50):
@@ -23,11 +48,23 @@ for i in range(50):
assert 2 <= random.randint(2, 6) <= 6
assert -2 <= random.randint(-2, 2) <= 2
+# empty range
+try:
+ random.randint(2, 1)
+except ValueError:
+ print('ValueError')
+
print('choice')
lst = [1, 2, 5, 6]
for i in range(50):
assert random.choice(lst) in lst
+# empty sequence
+try:
+ random.choice([])
+except IndexError:
+ print('IndexError')
+
print('random')
for i in range(50):
assert 0 <= random.random() < 1
diff --git a/tests/extmod/uzlib_decompio_gz.py b/tests/extmod/uzlib_decompio_gz.py
new file mode 100644
index 0000000000..c7aac04e8e
--- /dev/null
+++ b/tests/extmod/uzlib_decompio_gz.py
@@ -0,0 +1,39 @@
+try:
+ import zlib
+except ImportError:
+ import uzlib as zlib
+import uio as io
+
+
+# gzip bitstream
+buf = io.BytesIO(b'\x1f\x8b\x08\x08\x99\x0c\xe5W\x00\x03hello\x00\xcbH\xcd\xc9\xc9\x07\x00\x86\xa6\x106\x05\x00\x00\x00')
+inp = zlib.DecompIO(buf, 16 + 8)
+print(buf.seek(0, 1))
+print(inp.read(1))
+print(buf.seek(0, 1))
+print(inp.read(2))
+print(inp.read())
+print(buf.seek(0, 1))
+print(inp.read(1))
+print(inp.read())
+print(buf.seek(0, 1))
+
+# broken header
+buf = io.BytesIO(b'\x1f\x8c\x08\x08\x99\x0c\xe5W\x00\x03hello\x00\xcbH\xcd\xc9\xc9\x07\x00\x86\xa6\x106\x05\x00\x00\x00')
+try:
+ inp = zlib.DecompIO(buf, 16 + 8)
+except ValueError:
+ print("ValueError")
+
+# broken crc32
+buf = io.BytesIO(b'\x1f\x8b\x08\x08\x99\x0c\xe5W\x00\x03hello\x00\xcbH\xcd\xc9\xc9\x07\x00\x86\xa7\x106\x05\x00\x00\x00')
+inp = zlib.DecompIO(buf, 16 + 8)
+try:
+ inp.read(6)
+except OSError as e:
+ print(repr(e))
+
+# broken uncompressed size - not checked so far
+#buf = io.BytesIO(b'\x1f\x8b\x08\x08\x99\x0c\xe5W\x00\x03hello\x00\xcbH\xcd\xc9\xc9\x07\x00\x86\xa6\x106\x06\x00\x00\x00')
+#inp = zlib.DecompIO(buf, 16 + 8)
+#inp.read(6)
diff --git a/tests/extmod/uzlib_decompio_gz.py.exp b/tests/extmod/uzlib_decompio_gz.py.exp
new file mode 100644
index 0000000000..2330580f8c
--- /dev/null
+++ b/tests/extmod/uzlib_decompio_gz.py.exp
@@ -0,0 +1,11 @@
+16
+b'h'
+18
+b'el'
+b'lo'
+31
+b''
+b''
+31
+ValueError
+OSError(22,)
diff --git a/tests/extmod/uzlib_decompress.py b/tests/extmod/uzlib_decompress.py
index 468335a0d1..6892808cb4 100644
--- a/tests/extmod/uzlib_decompress.py
+++ b/tests/extmod/uzlib_decompress.py
@@ -10,6 +10,8 @@ PATTERNS = [
(b'0' * 100, b'x\x9c30\xa0=\x00\x00\xb3q\x12\xc1'),
(bytes(range(64)), b'x\x9cc`dbfaec\xe7\xe0\xe4\xe2\xe6\xe1\xe5\xe3\x17\x10\x14\x12\x16\x11\x15\x13\x97\x90\x94\x92\x96\x91\x95\x93WPTRVQUS\xd7\xd0\xd4\xd2\xd6\xd1\xd5\xd370426153\xb7\xb0\xb4\xb2\xb6\xb1\xb5\xb3\x07\x00\xaa\xe0\x07\xe1'),
(b'hello', b'x\x01\x01\x05\x00\xfa\xffhello\x06,\x02\x15'), # compression level 0
+ # adaptive/dynamic huffman tree
+ (b'13371813150|13764518736|12345678901', b'x\x9c\x05\xc1\x81\x01\x000\x04\x04\xb1\x95\\\x1f\xcfn\x86o\x82d\x06Qq\xc8\x9d\xc5X}<e\xb5g\x83\x0f\x89X\x07\xab')
]
for unpacked, packed in PATTERNS:
diff --git a/tests/extmod/vfs_fat_ramdisk.py b/tests/extmod/vfs_fat_ramdisk.py
index 57c8eeba89..6380761c6d 100644
--- a/tests/extmod/vfs_fat_ramdisk.py
+++ b/tests/extmod/vfs_fat_ramdisk.py
@@ -41,10 +41,11 @@ except MemoryError:
uos.VfsFat.mkfs(bdev)
-assert b"FOO_FILETXT" not in bdev.data
-assert b"hello!" not in bdev.data
+print(b"FOO_FILETXT" not in bdev.data)
+print(b"hello!" not in bdev.data)
vfs = uos.VfsFat(bdev, "/ramdisk")
+print("statvfs:", vfs.statvfs("/ramdisk"))
print("getcwd:", vfs.getcwd())
@@ -56,44 +57,66 @@ f2 = vfs.open("foo_file.txt")
print(f2.read())
f2.close()
-assert b"FOO_FILETXT" in bdev.data
-assert b"hello!" in bdev.data
+print(b"FOO_FILETXT" in bdev.data)
+print(b"hello!" in bdev.data)
-assert vfs.listdir() == ['foo_file.txt']
+print(vfs.listdir())
+
+try:
+ vfs.rmdir("foo_file.txt")
+except OSError as e:
+ print(e.args[0] == 20) # uerrno.ENOTDIR
vfs.remove('foo_file.txt')
-assert vfs.listdir() == []
+print(vfs.listdir())
vfs.mkdir("foo_dir")
-assert vfs.listdir() == ['foo_dir']
+print(vfs.listdir())
+
+try:
+ vfs.remove("foo_dir")
+except OSError as e:
+ print(e.args[0] == uerrno.EISDIR)
+
f = vfs.open("foo_dir/file-in-dir.txt", "w")
f.write("data in file")
f.close()
-assert vfs.listdir("foo_dir") == ['file-in-dir.txt']
+print(vfs.listdir("foo_dir"))
vfs.rename("foo_dir/file-in-dir.txt", "moved-to-root.txt")
-assert vfs.listdir() == ['foo_dir', 'moved-to-root.txt']
+print(vfs.listdir())
vfs.chdir("foo_dir")
print("getcwd:", vfs.getcwd())
-assert vfs.listdir() == []
+print(vfs.listdir())
with vfs.open("sub_file.txt", "w") as f:
f.write("test2")
-assert vfs.listdir() == ["sub_file.txt"]
+print(vfs.listdir())
+
+try:
+ vfs.chdir("sub_file.txt")
+except OSError as e:
+ print(e.args[0] == uerrno.ENOENT)
vfs.chdir("..")
print("getcwd:", vfs.getcwd())
+try:
+ vfs.rmdir("foo_dir")
+except OSError as e:
+ print(e.args[0] == uerrno.EACCES)
+
+vfs.remove("foo_dir/sub_file.txt")
+vfs.rmdir("foo_dir")
+print(vfs.listdir())
vfs.umount()
try:
vfs.listdir()
except OSError as e:
- assert e.args[0] == uerrno.ENODEV
-else:
- raise AssertionError("expected OSError not thrown")
+ print(e.args[0] == uerrno.ENODEV)
vfs = uos.VfsFat(bdev, "/ramdisk")
-assert vfs.listdir() == ['foo_dir', 'moved-to-root.txt']
+print(vfs.listdir())
diff --git a/tests/extmod/vfs_fat_ramdisk.py.exp b/tests/extmod/vfs_fat_ramdisk.py.exp
index b6079ad3b6..8a498b2fc4 100644
--- a/tests/extmod/vfs_fat_ramdisk.py.exp
+++ b/tests/extmod/vfs_fat_ramdisk.py.exp
@@ -1,4 +1,23 @@
+True
+True
+statvfs: (512, 512, 14, 14, 14, 0, 0, 0, 0, 255)
getcwd: /ramdisk
hello!
+True
+True
+['foo_file.txt']
+True
+[]
+['foo_dir']
+True
+['file-in-dir.txt']
+['foo_dir', 'moved-to-root.txt']
getcwd: /ramdisk/foo_dir
+[]
+['sub_file.txt']
+True
getcwd: /ramdisk
+True
+['moved-to-root.txt']
+True
+['moved-to-root.txt']
diff --git a/tests/float/float1.py b/tests/float/float1.py
index 27fe26205b..f21f5bcdd3 100644
--- a/tests/float/float1.py
+++ b/tests/float/float1.py
@@ -23,6 +23,10 @@ print(float("INFINITY"))
print(float("nan"))
print(float("NaN"))
try:
+ float("")
+except ValueError:
+ print("ValueError")
+try:
float("1e+")
except ValueError:
print("ValueError")
diff --git a/tests/import/import2a.py b/tests/import/import2a.py
index ce32b10b1b..def6aeb6aa 100644
--- a/tests/import/import2a.py
+++ b/tests/import/import2a.py
@@ -1,2 +1,5 @@
from import1b import var
print(var)
+
+from import1b import var as var2
+print(var2)
diff --git a/tests/import/import_pkg1.py b/tests/import/import_pkg1.py
index 8cd77af79d..fe6e4473e3 100644
--- a/tests/import/import_pkg1.py
+++ b/tests/import/import_pkg1.py
@@ -9,3 +9,8 @@ pkg_ = __import__("pkg.mod")
print(pkg_ is not pkg.mod)
print(pkg_ is pkg)
print(pkg_.mod is pkg.mod)
+
+# import using "as"
+import pkg.mod as mm
+print(mm is pkg.mod)
+print(mm.foo())
diff --git a/tests/io/bytesio_ext.py b/tests/io/bytesio_ext.py
index 30d79fcfcd..e827d1409c 100644
--- a/tests/io/bytesio_ext.py
+++ b/tests/io/bytesio_ext.py
@@ -17,3 +17,8 @@ print(a.getvalue())
a.flush()
print(a.getvalue())
+
+a.seek(0)
+arr = bytearray(10)
+print(a.readinto(arr))
+print(arr)
diff --git a/tests/io/write_ext.py b/tests/io/write_ext.py
index f4ed0d3685..19b616174b 100644
--- a/tests/io/write_ext.py
+++ b/tests/io/write_ext.py
@@ -1,3 +1,5 @@
+# This tests extended (MicroPython-specific) form of write:
+# write(buf, len) and write(buf, offset, len)
import uio
try:
diff --git a/tests/micropython/const.py b/tests/micropython/const.py
index 09717fd147..660a095f2c 100644
--- a/tests/micropython/const.py
+++ b/tests/micropython/const.py
@@ -1,5 +1,7 @@
# test constant optimisation
+from micropython import const
+
X = const(123)
Y = const(X + 456)
diff --git a/tests/micropython/const2.py b/tests/micropython/const2.py
new file mode 100644
index 0000000000..60085a1e04
--- /dev/null
+++ b/tests/micropython/const2.py
@@ -0,0 +1,34 @@
+# check that consts are not replaced in anything except standalone identifiers
+
+from micropython import const
+
+X = const(1)
+Y = const(2)
+Z = const(3)
+
+# import that uses a constant
+import micropython as X
+print(globals()['X'])
+
+# function name that matches a constant
+def X():
+ print('function X', X)
+globals()['X']()
+
+# arguments that match a constant
+def f(X, *Y, **Z):
+ pass
+f(1)
+
+# class name that matches a constant
+class X:
+ def f(self):
+ print('class X', X)
+globals()['X']().f()
+
+# constant within a class
+class A:
+ C1 = const(4)
+ def X(self):
+ print('method X', Y, C1, self.C1)
+A().X()
diff --git a/tests/micropython/const2.py.exp b/tests/micropython/const2.py.exp
new file mode 100644
index 0000000000..0568f91ce2
--- /dev/null
+++ b/tests/micropython/const2.py.exp
@@ -0,0 +1,4 @@
+<module 'micropython'>
+function X 1
+class X 1
+method X 2 4 4
diff --git a/tests/micropython/const_error.py b/tests/micropython/const_error.py
index b46efcae27..6d3d135b56 100644
--- a/tests/micropython/const_error.py
+++ b/tests/micropython/const_error.py
@@ -1,5 +1,7 @@
# make sure syntax error works correctly for bad const definition
+from micropython import const
+
def test_syntax(code):
try:
exec(code)
diff --git a/tests/micropython/emg_exc.py b/tests/micropython/emg_exc.py
new file mode 100644
index 0000000000..d228e6faab
--- /dev/null
+++ b/tests/micropython/emg_exc.py
@@ -0,0 +1,20 @@
+# test that emergency exceptions work
+
+import micropython
+import sys
+
+# some ports need to allocate heap for the emg exc
+try:
+ micropython.alloc_emergency_exception_buf(256)
+except AttributeError:
+ pass
+
+def f():
+ micropython.heap_lock()
+ try:
+ raise ValueError(1)
+ except ValueError as er:
+ sys.print_exception(er)
+ micropython.heap_unlock()
+
+f()
diff --git a/tests/micropython/emg_exc.py.exp b/tests/micropython/emg_exc.py.exp
new file mode 100644
index 0000000000..82b10b5f54
--- /dev/null
+++ b/tests/micropython/emg_exc.py.exp
@@ -0,0 +1 @@
+ValueError:
diff --git a/tests/micropython/heap_lock.py b/tests/micropython/heap_lock.py
new file mode 100644
index 0000000000..0f0a70eff1
--- /dev/null
+++ b/tests/micropython/heap_lock.py
@@ -0,0 +1,14 @@
+# check that heap_lock/heap_unlock work as expected
+
+import micropython
+
+micropython.heap_lock()
+
+try:
+ print([])
+except MemoryError:
+ print('MemoryError')
+
+micropython.heap_unlock()
+
+print([])
diff --git a/tests/micropython/heap_lock.py.exp b/tests/micropython/heap_lock.py.exp
new file mode 100644
index 0000000000..67b208cfc5
--- /dev/null
+++ b/tests/micropython/heap_lock.py.exp
@@ -0,0 +1,2 @@
+MemoryError
+[]
diff --git a/tests/micropython/heapalloc.py b/tests/micropython/heapalloc.py
index 2dc7fa5e7e..a651158ca5 100644
--- a/tests/micropython/heapalloc.py
+++ b/tests/micropython/heapalloc.py
@@ -1,6 +1,6 @@
# check that we can do certain things without allocating heap memory
-import gc
+import micropython
def f1(a):
print(a)
@@ -28,12 +28,7 @@ def test():
f2(i, i) # 2 args
f3(1, 2, 3, 4) # function with lots of local state
-# call h with heap allocation disabled and all memory used up
-gc.disable()
-try:
- while True:
- 'a'.lower # allocates 1 cell for boundmeth
-except MemoryError:
- pass
+# call test() with heap allocation disabled
+micropython.heap_lock()
test()
-gc.enable()
+micropython.heap_unlock()
diff --git a/tests/micropython/opt_level.py b/tests/micropython/opt_level.py
new file mode 100644
index 0000000000..4e2f2f4ea3
--- /dev/null
+++ b/tests/micropython/opt_level.py
@@ -0,0 +1,14 @@
+import micropython as micropython
+
+# check we can get and set the level
+micropython.opt_level(0)
+print(micropython.opt_level())
+micropython.opt_level(1)
+print(micropython.opt_level())
+
+# check that the optimisation levels actually differ
+micropython.opt_level(0)
+exec('print(__debug__)')
+micropython.opt_level(1)
+exec('print(__debug__)')
+exec('assert 0')
diff --git a/tests/micropython/opt_level.py.exp b/tests/micropython/opt_level.py.exp
new file mode 100644
index 0000000000..74b3dd74e8
--- /dev/null
+++ b/tests/micropython/opt_level.py.exp
@@ -0,0 +1,4 @@
+0
+1
+True
+False
diff --git a/tests/micropython/viper_args.py b/tests/micropython/viper_args.py
index ca2a5e6704..2aebe1b048 100644
--- a/tests/micropython/viper_args.py
+++ b/tests/micropython/viper_args.py
@@ -26,3 +26,11 @@ def f4(x1:int, x2:int, x3:int, x4:int):
f4(1, 2, 3, 4)
# only up to 4 arguments currently supported
+
+# test compiling *x, **x, * args (currently unsupported at runtime)
+@micropython.viper
+def f(*x, **y):
+ pass
+@micropython.viper
+def f(*):
+ pass
diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py
index ba2dd15c6a..677438b832 100644
--- a/tests/misc/non_compliant.py
+++ b/tests/misc/non_compliant.py
@@ -1,6 +1,19 @@
# tests for things that are not implemented, or have non-compliant behaviour
import array
+import ustruct
+
+# when super can't find self
+try:
+ exec('def f(): super()')
+except SyntaxError:
+ print('SyntaxError')
+
+# store to exception attribute is not allowed
+try:
+ ValueError().x = 0
+except AttributeError:
+ print('AttributeError')
# array deletion not implemented
try:
@@ -16,6 +29,12 @@ try:
except NotImplementedError:
print('NotImplementedError')
+# containment, looking for integer not implemented
+try:
+ print(1 in array.array('B', b'12'))
+except NotImplementedError:
+ print('NotImplementedError')
+
# should raise type error
try:
print(set('12') >= '1')
@@ -58,6 +77,12 @@ try:
except NotImplementedError:
print('NotImplementedError')
+# str subscr with step!=1 not implemented
+try:
+ print('abc'[1:2:3])
+except NotImplementedError:
+ print('NotImplementedError')
+
# bytes(...) with keywords not implemented
try:
bytes('abc', encoding='utf8')
@@ -87,3 +112,9 @@ try:
del [][2:3:4]
except NotImplementedError:
print('NotImplementedError')
+
+# struct pack with too many args, not checked by uPy
+print(ustruct.pack('bb', 1, 2, 3))
+
+# struct pack with too few args, not checked by uPy
+print(ustruct.pack('bb', 1))
diff --git a/tests/misc/non_compliant.py.exp b/tests/misc/non_compliant.py.exp
index 5937ccb2fb..737650e9e9 100644
--- a/tests/misc/non_compliant.py.exp
+++ b/tests/misc/non_compliant.py.exp
@@ -1,5 +1,8 @@
+SyntaxError
+AttributeError
TypeError
NotImplementedError
+NotImplementedError
True
True
TypeError, ValueError
@@ -12,3 +15,6 @@ NotImplementedError
NotImplementedError
NotImplementedError
NotImplementedError
+NotImplementedError
+b'\x01\x02'
+b'\x01\x00'
diff --git a/tests/pyb/extint.py b/tests/pyb/extint.py
index 47d84c8b5e..a8ba484b1c 100644
--- a/tests/pyb/extint.py
+++ b/tests/pyb/extint.py
@@ -1,8 +1,17 @@
import pyb
+# test basic functionality
ext = pyb.ExtInt('X1', pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_DOWN, lambda l:print('line:', l))
ext.disable()
ext.enable()
print(ext.line())
ext.swint()
+
+# test swint while disabled, then again after re-enabled
+ext.disable()
+ext.swint()
+ext.enable()
+ext.swint()
+
+# disable now that the test is finished
ext.disable()
diff --git a/tests/pyb/extint.py.exp b/tests/pyb/extint.py.exp
index 28019d75c6..daed01c7f6 100644
--- a/tests/pyb/extint.py.exp
+++ b/tests/pyb/extint.py.exp
@@ -1,2 +1,3 @@
0
line: 0
+line: 0
diff --git a/tests/run-tests b/tests/run-tests
index 059e4e910f..4ac7d8e28f 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -18,6 +18,9 @@ else:
CPYTHON3 = os.getenv('MICROPY_CPYTHON3', 'python3')
MICROPYTHON = os.getenv('MICROPY_MICROPYTHON', '../unix/micropython')
+# mpy-cross is only needed if --via-mpy command-line arg is passed
+MPYCROSS = os.getenv('MICROPY_MPYCROSS', '../mpy-cross/mpy-cross')
+
# Set PYTHONIOENCODING so that CPython will use utf-8 on systems which set another encoding in the locale
os.environ['PYTHONIOENCODING'] = 'utf-8'
os.environ['MICROPYPATH'] = ''
@@ -105,15 +108,30 @@ def run_micropython(pyb, args, test_file):
return b'CRASH'
else:
- # a standard test
- try:
- cmdlist = [MICROPYTHON, '-X', 'emit=' + args.emit]
- if args.heapsize is not None:
- cmdlist.extend(['-X', 'heapsize=' + args.heapsize])
+ # a standard test run on PC
+
+ # create system command
+ cmdlist = [MICROPYTHON, '-X', 'emit=' + args.emit]
+ if args.heapsize is not None:
+ cmdlist.extend(['-X', 'heapsize=' + args.heapsize])
+
+ # if running via .mpy, first compile the .py file
+ if args.via_mpy:
+ subprocess.check_output([MPYCROSS, '-mcache-lookup-bc', '-o', 'mpytest.mpy', test_file])
+ cmdlist.extend(['-m', 'mpytest'])
+ else:
cmdlist.append(test_file)
+
+ # run the actual test
+ try:
output_mupy = subprocess.check_output(cmdlist)
except subprocess.CalledProcessError:
output_mupy = b'CRASH'
+
+ # clean up if we had an intermediate .mpy file
+ if args.via_mpy:
+ rm_f('mpytest.mpy')
+
else:
# run on pyboard
import pyboard
@@ -187,11 +205,6 @@ def run_tests(pyb, tests, args):
if not 'True' in str(t, 'ascii'):
skip_tests.add('cmdline/repl_emacs_keys.py')
- # These tests are now broken because showbc uses buffered printf
- if True:
- skip_tests.add('cmdline/cmd_verbose.py')
- skip_tests.add('cmdline/cmd_showbc.py')
-
upy_byteorder = run_micropython(pyb, args, 'feature_check/byteorder.py')
has_complex = run_micropython(pyb, args, 'feature_check/complex.py') == b'complex\n'
cpy_byteorder = subprocess.check_output([CPYTHON3, 'feature_check/byteorder.py'])
@@ -224,7 +237,6 @@ def run_tests(pyb, tests, args):
skip_tests.add('float/float_divmod.py') # tested by float/float_divmod_relaxed.py instead
skip_tests.add('float/float2int_doubleprec.py') # requires double precision floating point to work
skip_tests.add('micropython/meminfo.py') # output is very different to PC output
- skip_tests.add('extmod/machine1.py') # raw memory access not supported
skip_tests.add('extmod/machine_mem.py') # raw memory access not supported
if args.target == 'wipy':
@@ -260,7 +272,7 @@ def run_tests(pyb, tests, args):
if args.emit == 'native':
skip_tests.update({'basics/%s.py' % t for t in 'gen_yield_from gen_yield_from_close gen_yield_from_ducktype gen_yield_from_exc gen_yield_from_iter gen_yield_from_send gen_yield_from_stopped gen_yield_from_throw generator1 generator2 generator_args generator_close generator_closure generator_exc generator_return generator_send'.split()}) # require yield
skip_tests.update({'basics/%s.py' % t for t in 'bytes_gen class_store_class globals_del string_join'.split()}) # require yield
- skip_tests.update({'basics/async_%s.py' % t for t in 'await await2 for for2 with with2'.split()}) # require yield
+ skip_tests.update({'basics/async_%s.py' % t for t in 'def await await2 for for2 with with2'.split()}) # require yield
skip_tests.update({'basics/%s.py' % t for t in 'try_reraise try_reraise2'.split()}) # require raise_varargs
skip_tests.update({'basics/%s.py' % t for t in 'with_break with_continue with_return'.split()}) # require complete with support
skip_tests.add('basics/array_construct2.py') # requires generators
@@ -365,6 +377,7 @@ def main():
cmd_parser.add_argument('--write-exp', action='store_true', help='save .exp files to run tests w/o CPython')
cmd_parser.add_argument('--emit', default='bytecode', help='MicroPython emitter to use (bytecode or native)')
cmd_parser.add_argument('--heapsize', help='heapsize to use (use default if not specified)')
+ cmd_parser.add_argument('--via-mpy', action='store_true', help='compile .py files to .mpy first')
cmd_parser.add_argument('files', nargs='*', help='input test files')
args = cmd_parser.parse_args()
diff --git a/tests/unicode/unicode.py b/tests/unicode/unicode.py
index b31f064e9c..5f29bc1c95 100644
--- a/tests/unicode/unicode.py
+++ b/tests/unicode/unicode.py
@@ -18,8 +18,9 @@ enc = s.encode()
print(enc, enc.decode() == s)
# printing of unicode chars using repr
-# TODO we don't do this correctly
-#print(repr(s))
+# NOTE: for some characters (eg \u10ff) we differ to CPython
+print(repr('a\uffff'))
+print(repr('a\U0001ffff'))
# test invalid escape code
try: