aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2019-01-27py: Add optional support for 2-argument version of built-in next().stijn
Configurable via MICROPY_PY_BUILTINS_NEXT2, disabled by default.
2018-12-13tests/basics/special_methods2: Typo fix in comment.Paul Sokolovsky
2018-12-10tests/extmod/uctypes_error: Add test for unsupported unary op.Damien George
2018-12-10tests/extmod/uctypes_ptr_le: Test int() operation on a pointer field.Paul Sokolovsky
2018-12-07tests/basics/special_methods: Add testcases for __int__.Paul Sokolovsky
2018-12-06py/objboundmeth: Support loading generic attrs from the method.Damien George
Instead of assuming that the method is a bytecode object, and only supporting load of __name__, make the operation generic by delegating the load to the method object itself. Saves a bit of code size and fixes the case of attempting to load __name__ on a native method, see issue #4028.
2018-12-05stm32/uart: Add rxbuf keyword arg to UART constructor and init method.Damien George
As per the machine.UART documentation, this is used to set the length of the RX buffer. The legacy read_buf_len argument is retained for backwards compatibility, with rxbuf overriding it if provided.
2018-12-04stm32/uart: Always show the flow setting when printing a UART object.Damien George
Also change the order of printing of flow so it is after stop (so bits, parity, stop are one after the other), and reduce code size by using mp_print_str instead of mp_printf where possible. See issue #1981.
2018-11-26tests/io: Update tests to use uos.remove() instead of uos.unlink().Paul Sokolovsky
After Unix port switches from one to another, to be consistent with baremetal ports.
2018-11-26py/unicode: Fix check for valid utf8 being stricter about contn chars.Damien George
2018-11-01tests/import_long_dyn: Test for "import *" of a long dynamic name.Paul Sokolovsky
Such names aren't stored as qstr in module dict, and there was a bug in "import *" handling which assumed any name in a module dict is a qstr.
2018-10-30tests/extmod: Skip uselect test when CPython doesn't have poll().stijn
CPython does not have an implementation of select.poll() on some operating systems (Windows, OSX depending on version) so skip the test in those cases instead of failing it.
2018-10-28py/compile: Fix case of eager implicit conversion of local to nonlocal.Damien George
This ensures that implicit variables are only converted to implicit closed-over variables (nonlocals) at the very end of the function scope. If variables are closed-over when first used (read from, as was done prior to this commit) then this can be incorrect because the variable may be assigned to later on in the function which means they are just a plain local, not closed over. Fixes issue #4272.
2018-10-27tests/cmdline/cmd_showbc.py: Fix test to explicitly declare nonlocal.Damien George
The way it was written previously the variable x was not an implicit nonlocal, it was just a normal local (but the compiler has a bug which incorrectly makes it a nonlocal).
2018-10-23tests/import: Add .exp file for module_getattr.py to not require Py 3.7.Damien George
2018-10-23tests/extmod/uctypes_sizeof_layout: Test for sizeof of different layout.Paul Sokolovsky
On almost all realistic platforms, native layout should be larger (or equal) than packed layout.
2018-10-23py/objmodule: Implement PEP 562's __getattr__ for modules.Paul m. p. P
Configurable via MICROPY_MODULE_GETATTR, disabled by default. Among other things __getattr__ for modules can help to build lazy loading / code unloading at runtime.
2018-10-22tests: Make bytes/str.count() tests skippable.Paul Sokolovsky
2018-10-18tests/basics/class_getattr: Remove invalid test for __getattribute__.Damien George
Part of this test was trying to test some functionality of __getattribute__ but this method name was misspelt so it wasn't doing anything useful. Fixing the typo in this name makes the test fail because MicroPython doesn't support user defined __getattribute__ methods. So this part of the test is removed. The remaining tests are modified slightly to make it clearer what they are testing.
2018-10-18py/objtype: Remove comment about catching exc from user __getattr__.Damien George
Any exception raised in a user __getattr__ should be propagated out. A test is added to verify these semantics.
2018-10-13tests/uctypes_sizeof_od: Test for using OrderedDict as struct descriptorPaul Sokolovsky
Just a copy of uctypes_sizeof.py with minimal changes.
2018-10-05tests/uselect_poll_basic: Add basic test for uselect.poll invariants.Paul Sokolovsky
This test doesn't check the actual I/O behavior, just "static" invariants like behavior on duplicate calls or calls when I/O object is not registered with poller.
2018-10-05tests/unix/ffi_float: Skip if strtof() is not available.Paul Sokolovsky
As the case for e.g. Android's Bionic Libc.
2018-10-01tests/run-tests: Enabled native tests that pass now that yield works.Damien George
2018-09-28py/objtype: Support full object model for get/set/delitem special meths.Damien George
This makes these special methods have the same calling behaviour as other methods in a class instance (mp_convert_member_lookup() is already called by mp_obj_class_lookup()).
2018-09-28py/vm: Fix case of throwing GeneratorExit type into yield-from.Damien George
mp_make_raise_obj must be used to convert a possible exception type to an instance object, otherwise the VM may raise a non-exception object. An existing test is adjusted to test this case, with the original test already moved to generator_throw.py.
2018-09-28tests/basics: Split out gen throw tests from yield-from-throw tests.Damien George
2018-09-27tests/micropython: Test loading const objs in native and viper funcs.Damien George
2018-09-27py/objfloat: Fix abs(-0.0) so it returns 0.0.Damien George
Nan and inf (signed and unsigned) are also handled correctly by using signbit (they were also handled correctly with "val<0", but that didn't handle -0.0 correctly). A test case is added for this behaviour.
2018-09-27py/objgenerator: Remove TODO about returning gen being called again.Damien George
The code implements correct behaviour, as tested by the new test case added in this commit.
2018-09-26tests/cpydiff: Add case for difference in behaviour of bytes.format().Paul Sokolovsky
2018-09-26py/modmath: Add math.factorial, optimised and non-opt implementations.Christopher Swenson
This commit adds the math.factorial function in two variants: - squared difference, which is faster than the naive version, relatively compact, and non-recursive; - a mildly optimised recursive version, faster than the above one. There are some more optimisations that could be done, but they tend to take more code, and more storage space. The recursive version seems like a sensible compromise. The new function is disabled by default, and uses the non-optimised version by default if it is enabled. The options are MICROPY_PY_MATH_FACTORIAL and MICROPY_OPT_MATH_FACTORIAL.
2018-09-20tests/float/float_parse.py: Add tests for accuracy of small decimals.Damien George
2018-09-20py/objgenerator: Implement PEP479, StopIteration convs to RuntimeError.Damien George
This commit implements PEP479 which disallows raising StopIteration inside a generator to signal that it should be finished. Instead, the generator should simply return when it is complete. See https://www.python.org/dev/peps/pep-0479/ for details.
2018-09-20py: Shorten error messages by using contractions and some rewording.Damien George
2018-09-15py/emitnative: Make viper funcs run with their correct globals context.Damien George
Viper functions will now capture the globals at the point they were defined and use these globals when executing.
2018-09-15py/emitnative: Support arbitrary number of arguments to viper functions.Damien George
2018-09-15py/compile: Factor code that compiles viper type annotations.Damien George
2018-09-13py: Fix native functions so they run with their correct globals context.Damien George
Prior to this commit a function compiled with the native decorator @micropython.native would not work correctly when accessing global variables, because the globals dict was not being set upon function entry. This commit fixes this problem by, upon function entry, setting as the current globals dict the globals dict context the function was defined within, as per normal Python semantics, and as bytecode does. Upon function exit the original globals dict is restored. In order to restore the globals dict when an exception is raised the native function must guard its internals with an nlr_push/nlr_pop pair. Because this push/pop is relatively expensive, in both C stack usage for the nlr_buf_t and CPU execution time, the implementation here optimises things as much as possible. First, the compiler keeps track of whether a function even needs to access global variables. Using this information the native emitter then generates three different kinds of code: 1. no globals used, no exception handlers: no nlr handling code and no setting of the globals dict. 2. globals used, no exception handlers: an nlr_buf_t is allocated on the C stack but it is not used if the globals dict is unchanged, saving execution time because nlr_push/nlr_pop don't need to run. 3. function has exception handlers, may use globals: an nlr_buf_t is allocated and nlr_push/nlr_pop are always called. In the end, native functions that don't access globals and don't have exception handlers will run more efficiently than those that do. Fixes issue #1573.
2018-09-11py/emitnative: Fix try-finally in outer scope, so finally is cancelled.Damien George
2018-09-11py/objarray: bytearray: Allow 2nd/3rd arg to constructor.Paul Sokolovsky
If bytearray is constructed from str, a second argument of encoding is required (in CPython), and third arg of Unicode error handling is allowed, e.g.: bytearray("str", "utf-8", "strict") This is similar to bytes: bytes("str", "utf-8", "strict") This patch just allows to pass 2nd/3rd arguments to bytearray, but doesn't try to validate them to not impact code size. (This is also similar to how bytes constructor is handled, though it does a bit more validation, e.g. check that in case of str arg, encoding argument is passed.)
2018-09-11tests/extmod/uhashlib_md5: Add coverage tests for MD5 algorithm.Paul Sokolovsky
Based on tests/extmod/uhashlib_sha1.
2018-09-05tests: Remove pyboard.py symlink and instead import from ../tools.Damien George
To eliminate the need for symlinks which don't work on systems like Windows.
2018-09-04tests/float: Test -inf and some larger values for special math funcs.Damien George
2018-09-04tests/float/cmath_fun.py: Fix truncation of small real part of complex.Damien George
2018-09-04tests/basics: Add test cases for context manager raising in enter/exit.Damien George
2018-09-04tests/basics: Add more tests for return within try-finally.Damien George
2018-09-04tests/run-tests: Enable native tests for unwinding jumps.Damien George
2018-09-03py/emitnative: Cancel caught exception once handled to prevent reraise.Damien George
The native emitter keeps the current exception in a slot in its C stack (instead of on its Python value stack), so when it catches an exception it must explicitly clear that slot so the same exception is not reraised later on.
2018-09-03py/vm: Fix handling of finally-return with complex nested finallys.Damien George
Back in 8047340d7532ec32bc9f2d603bffc0bc9544297f basic support was added in the VM to handle return statements within a finally block. But it didn't cover all cases, in particular when some finally's were active and others inactive when the "return" was executed. This patch adds further support for return-within-finally by correctly managing the currently_in_except_block flag, and should fix all cases. The main point is that finally handlers remain on the exception stack even if they are active (currently being executed), and the unwind return code should only execute those finally's which are inactive. New tests are added for the cases which now pass.