Commit Graph

1965 Commits

Author SHA1 Message Date
Paul Sokolovsky 3c483842db tests/cpydiff: Fix markup where "`" (xref) was used instead of "``" (code). 2017-12-03 15:32:09 +02:00
Paul Sokolovsky a289b24e25 tests/run-tests: "minimal": Skip recently added float/float_parse.py.
Fails for Zephyr qemu_x86 with:

-9e-36
+9.000001e-36
2017-11-28 14:11:19 +02:00
Damien George 63f47104fe tests/cpydiff: Add difference-test for second arg of builtin next(). 2017-11-28 10:50:53 +11:00
Damien George c3bc8d7b2b tests/basics/builtin_locals: Add test for using locals() in class body. 2017-11-27 14:14:57 +11:00
Damien George 84895f1a21 py/parsenum: Improve parsing of floating point numbers.
This patch improves parsing of floating point numbers by converting all the
digits (integer and fractional) together into a number 1 or greater, and
then applying the correct power of 10 at the very end.  In particular the
multiple "multiply by 0.1" operations to build a fraction are now combined
together and applied at the same time as the exponent, at the very end.

This helps to retain precision during parsing of floats, and also includes
a check that the number doesn't overflow during the parsing.  One benefit
is that a float will have the same value no matter where the decimal point
is located, eg 1.23 == 123e-2.
2017-11-27 12:51:52 +11:00
Damien George c7a0e1472d tests/basics/builtin_range: Add test for corner case of range slicing. 2017-11-24 15:30:12 +11:00
Damien George 505671b698 tests/basics: Add test for containment of a subclass of a native type. 2017-11-24 14:48:41 +11:00
Damien George 5e34a113ea py/runtime: Add MP_BINARY_OP_CONTAINS as reverse of MP_BINARY_OP_IN.
Before this patch MP_BINARY_OP_IN had two meanings: coming from bytecode it
meant that the args needed to be swapped, but coming from within the
runtime meant that the args were already in the correct order.  This lead
to some confusion in the code and comments stating how args were reversed.
It also lead to 2 bugs: 1) containment for a subclass of a native type
didn't work; 2) the expression "{True} in True" would illegally succeed and
return True.  In both of these cases it was because the args to
MP_BINARY_OP_IN ended up being reversed twice.

To fix these things this patch introduces MP_BINARY_OP_CONTAINS which
corresponds exactly to the __contains__ special method, and this is the
operator that built-in types should implement.  MP_BINARY_OP_IN is now only
emitted by the compiler and is converted to MP_BINARY_OP_CONTAINS by
swapping the arguments.
2017-11-24 14:48:23 +11:00
Damien George df078e8213 tests/net_hosted: Add test for socket connect() and poll() behaviour. 2017-11-23 10:45:12 +11:00
Damien George a07fc5b640 py/objfloat: Allow float() to parse anything with the buffer protocol.
This generalises and simplifies the code and follows CPython behaviour.
2017-11-21 15:01:38 +11:00
stijn 79ed58f87b py/objnamedtuple: Add _asdict function if OrderedDict is supported 2017-11-12 14:16:54 +02:00
Paul Sokolovsky 9b9dbc5815 py/objtype: Define all special methods if requested.
If MICROPY_PY_ALL_SPECIAL_METHODS is defined, actually define all special
methods (still subject to gating by e.g. MICROPY_PY_REVERSE_SPECIAL_METHODS).

This adds quite a number of qstr's, so should be used sparingly.
2017-10-27 20:06:35 +03:00
Damien George f36975b679 tests/net_inet: Update tls test to work with CPython and incl new site.
CPython only supports the server_hostname keyword arg via the SSLContext
object, so use that instead of the top-level ssl.wrap_socket.  This allows
the test to run on CPython the same as uPy.

Also add the "Host:" header to correctly make a GET request (for URLs that
are hosted on other servers).  This is not strictly needed to test the SSL
connection but helps to debug things when printing the response.
2017-10-26 12:29:24 +11:00
Damien George a3afa8cfc4 py/emitnative: Implement floor-division and modulo for viper emitter. 2017-10-11 18:54:34 +11:00
Damien George 08a196697c py/formatfloat: Don't print the negative sign of a NaN value.
NaN may have the sign bit set but it has no meaning, so don't print it out.
2017-10-10 16:01:13 +11:00
Damien George 25e140652b py/modmath: Add full checks for math domain errors.
This patch changes how most of the plain math functions are implemented:
there are now two generic math wrapper functions that take a pointer to a
math function (like sin, cos) and perform the necessary conversion to and
from MicroPython types.  This helps to reduce code size.  The generic
functions can also check for math domain errors in a generic way, by
testing if the result is NaN or infinity combined with finite inputs.

The result is that, with this patch, all math functions now have full
domain error checking (even gamma and lgamma) and code size has decreased
for most ports.  Code size changes in bytes for those with the math module
are:

   unix x64:  -432
unix nanbox:  -792
      stm32:   -88
    esp8266:   +12

Tests are also added to check domain errors are handled correctly.
2017-10-10 15:57:45 +11:00
Paul Sokolovsky 71c1a05d88 tests/run-tests: Close device under test using "finally".
We want to close communication object even if there were exceptions
somewhere in the code. This is important for --device exec:/execpty:
which may otherwise leave processing running in the background.
2017-10-07 15:49:58 +03:00
Damien George 98dd126e98 tests/extmod: Add test for '-' in character class in regex. 2017-10-05 11:33:49 +11:00
Damien George 0864a6957f py: Clean up unary and binary enum list to keep groups together.
2 non-bytecode binary ops (NOT_IN and IN_NOT) are moved out of the
bytecode group, so this change will change the bytecode format.
2017-10-05 10:49:44 +11:00
Damien George dfa563c71f py/objstr: Make empty bytes object have a null-terminating byte.
Because a lot of string processing functions assume there is a null
terminating byte, so they can work in an efficient way.

Fixes issue #3334.
2017-10-04 17:59:22 +11:00
Damien George 1394258f37 py/objset: Include the failed key in a KeyError raised from set.remove. 2017-10-03 18:03:06 +11:00
Damien George 2ac1364688 py/objset: Check that RHS of a binary op is a set/frozenset.
CPython docs explicitly state that the RHS of a set/frozenset binary op
must be a set to prevent user errors.  It also preserves commutativity of
the ops, eg: "abc" & set() is a TypeError, and so should be set() & "abc".

This change actually decreases unix (x64) code by 160 bytes; it increases
stm32 by 4 bytes and esp8266 by 28 bytes (but previous patch already
introduced a much large saving).
2017-10-03 17:56:27 +11:00
Paul Sokolovsky 8e0b9f495b tests/extmod: Add test for ure regexes leading to infinite recursion.
These now should be caught properly and lead to RuntimeError instead of
crash.
2017-10-03 00:24:32 +03:00
Damien George bdc6e86e07 py/objfloat: Support raising a negative number to a fractional power.
This returns a complex number, following CPython behaviour.  For ports that
don't have complex numbers enabled this will raise a ValueError which gives
a fail-safe for scripts that were written assuming complex numbers exist.
2017-09-26 12:57:51 +10:00
David Lechner 62849b7010 py: Add config option to print warnings/errors to stderr.
This adds a new configuration option to print runtime warnings and errors to
stderr. On Unix, CPython prints warnings and unhandled exceptions to stderr,
so the unix port here is configured to use this option.

The unix port already printed unhandled exceptions on the main thread to
stderr. This patch fixes unhandled exceptions on other threads and warnings
(issue #2838) not printing on stderr.

Additionally, a couple tests needed to be fixed to handle this new behavior.
This is done by also capturing stderr when running tests.
2017-09-26 11:59:11 +10:00
Paul Sokolovsky 9d836fedbd py: Clarify which mp_unary_op_t's may appear in the bytecode.
Not all can, so we don't need to reserve bytecodes for them, and can
use free slots for something else later.
2017-09-25 16:35:19 -07:00
Damien George ede8a0235b py/vstr: Raise a RuntimeError if fixed vstr buffer overflows.
Current users of fixed vstr buffers (building file paths) assume that there
is no overflow and do not check for overflow after building the vstr.  This
has the potential to lead to NULL pointer dereferences
(when vstr_null_terminated_str returns NULL because it can't allocate RAM
for the terminating byte) and stat'ing and loading invalid path names (due
to the path being truncated).  The safest and simplest thing to do in these
cases is just raise an exception if a write goes beyond the end of a fixed
vstr buffer, which is what this patch does.  It also simplifies the vstr
code.
2017-09-21 20:29:41 +10:00
Damien George 96fd80db13 py/objexcept: Prevent infinite recursion when allocating exceptions.
The aim of this patch is to rewrite the functions that create exception
instances (mp_obj_exception_make_new and mp_obj_new_exception_msg_varg) so
that they do not call any functions that may raise an exception.  Otherwise
it's possible to create infinite recursion with an exception being raised
while trying to create an exception object.

The two main things that are done to accomplish this are:
1. Change mp_obj_new_exception_msg_varg to just format the string, then
   call mp_obj_exception_make_new to actually create the exception object.
2. In mp_obj_exception_make_new and mp_obj_new_exception_msg_varg try to
   allocate all memory first using functions that don't raise exceptions
   If any of the memory allocations fail (return NULL) then degrade
   gracefully by trying other options for memory allocation, eg using the
   emergency exception buffer.
3. Use a custom printer backend to conservatively format strings: if it
   can't allocate memory then it just truncates the string.

As part of this rewrite, raising an exception without a message, like
KeyError(123), will now use the emergency buffer to store the arg and
traceback data if there is no heap memory available.

Memory use with this patch is unchanged.  Code size is increased by:

   bare-arm:  +136
minimal x86:  +124
   unix x64:   +72
unix nanbox:   +96
      stm32:   +88
    esp8266:   +92
     cc3200:   +80
2017-09-21 15:24:57 +10:00
Paul Sokolovsky fc9a6dd09e py/objstr: strip: Don't strip "\0" by default.
An issue was due to incorrectly taking size of default strip characters
set.
2017-09-19 21:21:12 +03:00
Paul Sokolovsky 9dce823cfd py/modbuiltins: Implement abs() by dispatching to MP_UNARY_OP_ABS.
This allows user classes to implement __abs__ special method, and saves
code size (104 bytes for x86_64), even though during refactor, an issue
was fixed and few optimizations were made:

* abs() of minimum (negative) small int value is calculated properly.
* objint_longlong and objint_mpz avoid allocating new object is the
  argument is already non-negative.
2017-09-18 00:06:43 +03:00
Paul Sokolovsky 75163325ae tests/cpydiff: Add cases for locals() discrepancies.
MicroPython doesn't maintain local symbolic environment, so any feature
depending on it won't work as expected.
2017-09-16 13:05:15 +03:00
Paul Sokolovsky f54b3527f2 tests/run-tests: Fix copy-paste mistake in var name. 2017-09-10 22:38:18 +03:00
Paul Sokolovsky d1f909005a tests/run-tests: Skip class_inplace_op for minimal profile.
Don't assume that MICROPY_PY_ALL_SPECIAL_METHODS is defined, as required
for inplace special methods.

Fixes Zephyr tests.
2017-09-10 22:32:08 +03:00
Paul Sokolovsky d6f9d64d97 tests/class_reverse_op: Test for reverse arith ops special methods.
This test should be run only if support for reverse ops is enabled, so
the corresponding feature_check is added to run-tests.
2017-09-10 17:05:57 +03:00
Damien George 0708dd495f tests/run-bench-tests: Update locations of executables, now in ports/. 2017-09-08 12:11:15 +10:00
Paul Sokolovsky b8ee7ab5b9 py/runtime0.h: Put inplace arith ops in front of normal operations.
This is to allow to place reverse ops immediately after normal ops, so
they can be tested as one range (which is optimization for reverse ops
introduction in the next patch).
2017-09-08 00:10:10 +03:00
Paul Sokolovsky 50b9329eba py/runtime0.h: Move MP_BINARY_OP_DIVMOD to the end of mp_binary_op_t.
It starts a dichotomy of mp_binary_op_t values which can't appear in the
bytecode. Another reason to move it is to VALUES of OP_* and OP_INPLACE_*
nicely adjacent. This also will be needed for OP_REVERSE_*, to be soon
introduced.
2017-09-07 11:26:42 +03:00
Paul Sokolovsky d4d1c45a55 py/runtime0.h: Move relational ops to the beginning of mp_binary_op_t.
This is to allow to encode arithmetic operations more efficiently, in
preparation to introduction of __rOP__ method support.
2017-09-07 10:55:43 +03:00
Paul Sokolovsky 5c603bd0fd py/objlist: Properly implement comparison with incompatible types.
Should raise TypeError, unless it's (in)equality comparison.
2017-09-07 00:10:10 +03:00
tll 68c28174d0 py/objstr: Add check for valid UTF-8 when making a str from bytes.
This patch adds a function utf8_check() to check for a valid UTF-8 encoded
string, and calls it when constructing a str from raw bytes.  The feature
is selectable at compile time via MICROPY_PY_BUILTINS_STR_UNICODE_CHECK and
is enabled if unicode is enabled.  It costs about 110 bytes on Thumb-2, 150
bytes on Xtensa and 170 bytes on x86-64.
2017-09-06 16:43:09 +10:00
Damien George 4a93801c12 all: Update Makefiles and others to build with new ports/ dir layout.
Also renames "stmhal" to "stm32" in documentation and everywhere else.
2017-09-06 14:09:13 +10:00
Paul Sokolovsky 1aaba5cabe py/objtuple: Properly implement comparison with incompatible types.
Should raise TypeError, unless it's (in)equality comparison.
2017-09-06 00:23:41 +03:00
Paul Sokolovsky 376618cd8a tests/class_inplace_op: Test for inplace op fallback to normal one. 2017-09-04 16:44:38 +03:00
Damien George d4b75f6b68 py/obj: Fix comparison of float/complex NaN with itself.
IEEE floating point is specified such that a comparison of NaN with itself
returns false, and Python respects these semantics.  This patch makes uPy
also have these semantics.  The fix has a minor impact on the speed of the
object-equality fast-path, but that seems to be unavoidable and it's much
more important to have correct behaviour (especially in this case where
the wrong answer for nan==nan is silently returned).
2017-09-04 14:16:27 +10:00
Paul Sokolovsky 9950865c39 py/objfloat: Fix binary ops with incompatible objects.
These are now returned as "operation not supported" instead of raising
TypeError. In particular, this fixes equality for float vs incompatible
types, which now properly results in False instead of exception. This
also paves the road to support reverse operation (e.g. __radd__) with
float objects.

This is achieved by introducing mp_obj_get_float_maybe(), similar to
existing mp_obj_get_int_maybe().
2017-09-02 23:05:24 +03:00
Damien George 2daacc5cee py/modstruct: Check and prevent buffer-write overflow in struct packing.
Prior to this patch, the size of the buffer given to pack_into() was checked
for being too small by using the count of the arguments, not their actual
size.  For example, a format spec of '4I' would only check that there was 4
bytes available, not 16; and 'I' would check for 1 byte, not 4.

The pack() function is ok because its buffer is created to be exactly the
correct size.

The fix in this patch calculates the total size of the format spec at the
start of pack_into() and verifies that the buffer is large enough.  This
adds some computational overhead, to iterate through the whole format spec.
The alternative is to check during the packing, but that requires extra
code to handle alignment, and the check is anyway not needed for pack().
So to maintain minimal code size the check is done using struct_calcsize.
2017-09-01 11:11:09 +10:00
Damien George 79d5acbd01 py/modstruct: Check and prevent buffer-read overflow in struct unpacking
Prior to this patch, the size of the buffer given to unpack/unpack_from was
checked for being too small by using the count of the arguments, not their
actual size.  For example, a format spec of '4I' would only check that
there was 4 bytes available, not 16; and 'I' would check for 1 byte, not 4.

This bug is fixed in this patch by calculating the total size of the format
spec at the start of the unpacking function.  This function anyway needs to
calculate the number of items at the start, so calculating the total size
can be done at the same time.
2017-09-01 10:53:29 +10:00
Damien George 793d826d9d py/modstruct: In struct.pack, stop converting if there are no args left.
This patch makes a repeat counter behave the same as repeating the
typecode, when there are not enough args.  For example:
struct.pack('2I', 1) now behave the same as struct.pack('II', 1).
2017-09-01 10:10:51 +10:00
Paul Sokolovsky b349479a49 tests/class_new: Add another testcase for __new__/__init__ interaction.
Similar to the existing testcase, but test that returning both value of
native type and instance of another user class from __new__ lead to
__init__ not being called, for better coverage.
2017-09-01 00:43:52 +03:00
Paul Sokolovsky 35be9e805f tests/class_new: Add checks for __init__ being called and other improvements. 2017-08-30 21:33:42 +03:00
Paul Sokolovsky b565c36963 tests/object_new: Better messages, check user __new__() method.
Make messages more verbose and easier to follow and check that user class'
__new__() is not called by object.__new__(user_class).
2017-08-30 21:29:23 +03:00
Paul Sokolovsky 784909ce16 py/objtype: Handle NotImplemented return from binary special methods.
NotImplemented means "try other fallbacks (like calling __rop__
instead of __op__) and if nothing works, raise TypeError". As
MicroPython doesn't implement any fallbacks, signal to raise
TypeError right away.
2017-08-30 01:39:24 +03:00
Paul Sokolovsky 37379a2974 py/objstr: startswith, endswith: Check arg to be a string.
Otherwise, it will silently get incorrect result on other values types,
including CPython tuple form like "foo.png".endswith(("png", "jpg"))
(which MicroPython doesn't support for unbloatedness).
2017-08-29 00:06:21 +03:00
Paul Sokolovsky e3383e9352 py/stream: seek: Consistently handle negative offset for SEEK_SET.
Per POSIX, this is EINVAL, so raises OSError(EINVAL).
2017-08-20 22:02:41 +03:00
Alex Robbins c89254fd0f extmod/modubinascii: Rewrite mod_binascii_a2b_base64.
This implementation ignores invalid characters in the input. This allows
it to decode the output of b2a_base64, and also mimics the behavior of
CPython.
2017-08-17 09:25:51 +03:00
Damien George 025e5f2b33 py/binary: Change internal bytearray typecode from 0 to 1.
The value of 0 can't be used because otherwise mp_binary_get_size will let
a null byte through as the type code (intepreted as byterray).  This can
lead to invalid type-specifier strings being let through without an error
in the struct module, and even buffer overruns.
2017-08-17 16:19:35 +10:00
Eric Poulsen d5191edf7f extmod/modussl_mbedtls.c: Add ussl.getpeercert() method.
Behaviour is as per CPython but only the binary form is implemented here.
A test is included.
2017-08-16 15:01:00 +10:00
Bas van Sisseren a14ce77b28 py/binary.c: Fix bug when packing big-endian 'Q' values.
Without bugfix:

    struct.pack('>Q', 16)
    b'\x00\x00\x00\x10\x00\x00\x00\x00'

With bugfix:

    struct.pack('>Q', 16)
    b'\x00\x00\x00\x00\x00\x00\x00\x10'
2017-08-15 11:33:43 +10:00
Paul Sokolovsky bfc2092dc5 py/modsys: Initial implementation of sys.getsizeof().
Implemented as a new MP_UNARY_OP. This patch adds support lists, dicts and
instances.
2017-08-11 09:43:07 +03:00
Damien George 3d25d9c7d9 py/objstr: Raise an exception for wrong type on RHS of str binary op.
The main case to catch is invalid types for the containment operator, of
the form str.__contains__(non-str).
2017-08-09 21:25:48 +10:00
Damien George eb2784e8a2 py/objtuple: Allow to use inplace-multiplication operator on tuples. 2017-08-09 21:20:42 +10:00
Alexander Steffen 55f33240f3 all: Use the name MicroPython consistently in comments
There were several different spellings of MicroPython present in comments,
when there should be only one.
2017-07-31 18:35:40 +10:00
Damien George 04552ff71b py: Implement raising a big-int to a negative power.
Before this patch raising a big-int to a negative power would just return
0.  Now it returns a floating-point number with the correct value.
2017-07-25 11:49:22 +10:00
Tom Collins 6cfe737597 tests/basics/builtin_exec: Test various globals/locals args to exec(). 2017-07-21 15:17:33 +10:00
Damien George 6c1b7e008d tests: Rename exec1.py to builtin_exec.py. 2017-07-21 15:11:24 +10:00
Paul Sokolovsky 4368ae3142 extmod/modussl_axtls: Allow to close ssl stream multiple times.
Make sure that 2nd close has no effect and operations on closed streams
are handled properly.
2017-07-20 00:20:53 +03:00
Damien George 761e4c7ff6 all: Remove trailing spaces, per coding conventions. 2017-07-19 13:12:10 +10:00
Paul Sokolovsky ad3abcd324 tests/cpydiff: Add case for str.ljust/rjust. 2017-07-09 15:04:26 +03:00
Paul Sokolovsky 0c5369a1f0 tests/cpydiff/: Improve wording, add more workarounds. 2017-07-09 14:33:55 +03:00
Paul Sokolovsky 5f65ad8c96 tests/cpydiff/core_class_supermultiple: Same cause as core_class_mro. 2017-07-09 13:47:23 +03:00
Paul Sokolovsky c5efb8159f tests/cpydiff/core_arguments: Move under Functions subsection.
This is the last "orphan" case.
2017-07-09 13:36:28 +03:00
Paul Sokolovsky b2979023ac tests/cpydiff/core_class_mro: Move under Classes, add workaround. 2017-07-09 13:32:17 +03:00
Damien George f69ab79ec8 py/objgenerator: Allow to hash generators and generator instances.
Adds nothing to the code size, since it uses existing empty slots in the
type structures.
2017-07-07 11:47:38 +10:00
Paul Sokolovsky ed52955c6b tests/cpydiff/modules_deque: Elaborate workaround. 2017-07-05 23:03:37 +03:00
Krzysztof Blazewicz 7feb7301b2 tests/basics: Add tests for arithmetic operators precedence. 2017-07-05 15:51:03 +10:00
Damien George 6b8b56f859 py/modmath: Check for zero division in log with 2 args. 2017-07-04 02:15:11 +10:00
Damien George b86c65d31c extmod/modubinascii: Add check for empty buffer passed to hexlify.
Previous to this patch hexlify(b'', b':') would lead to a bad crash due to
the computed length of the result being -1=0xffffffff.
2017-07-03 14:52:00 +10:00
Paul Sokolovsky 58b7b01cb5 extmod/modure: If input string is bytes, return bytes results too.
This applies to match.group() and split().

For ARM Thumb2, this increased code size by 12 bytes.
2017-07-01 01:25:45 +03:00
Damien George 369e7fd178 tests/unix/extra_coverage: Add test for mp_vprintf with bad fmt spec. 2017-06-30 12:25:42 +10:00
Damien George 8f6ef8de48 tests/basics/namedtuple1: Add test for creating with pos and kw args. 2017-06-29 17:50:09 +10:00
Damien George 409fc8f9c1 tests/import: Update comment now that uPy raises correct exception. 2017-06-28 12:21:29 +10:00
Damien George 3a9445c6b3 tests/import: Add a test for the builtin __import__ function. 2017-06-28 12:21:29 +10:00
Damien George 4a6c0fda78 tests: Auto detect floating point capabilites of the target.
The floating-point precision of the target is detected (0, 30, 32 or 64)
and only those tests which can run on the target will be run.
2017-06-26 13:47:00 +10:00
Paul Sokolovsky bc7659eb59 tests/connect_nonblock: Refactor towards real net_hosted test.
In the future, a special runner for such tests will import each test and
call test() function with an address of test server to use.
2017-06-23 21:27:05 +03:00
Paul Sokolovsky 3f9d59c87a tests/net_inet: Move tests which don't require full Internet to net_hosted.
The idea is that these tests can be run with just a test server running
on a test host, with device under test connecting to it, instead of
requiring Internet connection for testing.

Such setup is however WIP, and some tests in net_hosted/ are so far
written to connect to Internet, as there're not test server written
yet. This is expected to evolve over time.
2017-06-23 21:12:32 +03:00
Damien George 44922934f5 tests/basics: Add tests for for-else statement. 2017-06-22 14:02:14 +10:00
Damien George 458cbacb8f tests/net_inet: Add tests for accept and connect in nonblocking mode.
Some of these tests don't require an Internet connection, but here is a
good place to put them for now.
2017-06-21 12:25:10 +10:00
Paul Sokolovsky 4caa27ae0e tests/net_inet/test_tls_sites.py: Integration test for SSL connections.
This attempts to bootstrap network tests for MicroPython. This commits
sets test/net_inet/ as place for tests which require access to wide
Internet. They aren't intended to be run as part of the main testsuite,
instead to be run manually on demand.

test_tls_sites.py in particular check that it's possible to establish
SSL/TLS connection to select sites on the Internet: few references ones,
plus those for which problems were reported, and resolved.
2017-06-21 01:58:36 +03:00
Damien George e269cabe3e py/objint: In to_bytes(), allow length arg to be any int and check sign. 2017-06-15 14:21:02 +10:00
Damien George 8c5632a869 py/objint: Support "big" byte-order in int.to_bytes(). 2017-06-15 13:56:21 +10:00
Damien George 1e70fda69f py/compile: Raise SyntaxError if positional args are given after */**.
In CPython 3.4 this raises a SyntaxError.  In CPython 3.5+ having a
positional after * is allowed but uPy has the wrong semantics and passes
the arguments in the incorrect order.  To prevent incorrect use of a
function going unnoticed it is important to raise the SyntaxError in uPy,
until the behaviour is fixed to follow CPython 3.5+.
2017-06-14 18:18:01 +10:00
Damien George e374cfff80 py/modthread: Raise RuntimeError in release() if lock is not acquired. 2017-06-14 14:43:50 +10:00
Damien George 6ed4581f54 py/formatfloat: Fix number of digits and exponent sign when rounding.
This patch fixes 2 things when printing a floating-point number that
requires rounding up of the mantissa:
- retain the correct precision; eg 0.99 becomes 1.0, not 1.00
- if the exponent goes from -1 to 0 then render it as +0, not -0
2017-06-13 13:36:56 +10:00
Damien George f55dcddbc7 tests/extmod/vfs_basic: Allow test to pass on embedded targets. 2017-06-11 22:56:27 +10:00
Paul Sokolovsky 85d809d1f4 tests: Convert remaining "sys.exit()" to "raise SystemExit". 2017-06-10 20:34:38 +03:00
Paul Sokolovsky a2803b74f4 tests/basics: Convert "sys.exit()" to "raise SystemExit". 2017-06-10 20:03:01 +03:00
Paul Sokolovsky 07241cd37a py/objstringio: If created from immutable object, follow copy on write policy.
Don't create copy of immutable object's contents until .write() is called
on BytesIO.
2017-06-09 17:33:01 +03:00
Paul Sokolovsky e094200750 tests/float/builtin_float_minmax: PEP8 fixes. 2017-06-08 17:23:22 +03:00
Damien George fde54350a8 tests/float: Convert "sys.exit()" to "raise SystemExit".
The latter is shorter and simpler because it doesn't require importing the
sys module.
2017-06-08 14:00:57 +10:00
Damien George f6ef8e3f17 extmod/vfs: Allow to statvfs the root directory. 2017-06-07 15:17:45 +10:00
Damien George 7400d88762 tests/basics/string_rsplit: Add tests for negative "maxsplit" argument. 2017-06-02 13:08:18 +10:00
Ville Skyttä ca16c38210 various: Spelling fixes 2017-05-29 11:36:05 +03:00
Damien George 8b13cd7e19 tests/basics: Add more tests for unwind jumps from within a try-finally.
These tests excercise cases that are fixed by the previous two commits.
2017-05-25 20:48:16 +10:00
Damien George 218a876f97 tests/basics/builtin_range: Add tests for negative slicing of range. 2017-05-18 17:32:42 +10:00
Damien George e1b0f2a16f tests/basics/list_slice_3arg: Add more tests for negative slicing. 2017-05-18 17:32:42 +10:00
Tom Collins 162a0f942b tests/io/bytesio_ext: Test read() after seek() past end of BytesIO object. 2017-05-15 23:58:06 +03:00
Paul Sokolovsky 054a381d7c tests/extmod/vfs_fat_more: Make skippable is uos is not available.
Fixes Zephyr tests.
2017-05-13 14:13:53 +03:00
Damien George cda09727b4 tests/extmod/vfs_fat: Add test for ilistdir of a non-existent directory. 2017-05-13 19:10:15 +10:00
Tom Collins 760aa0996f tests/basics/lexer: Add line continuation tests for lexer.
Tests for an issue with line continuation failing in paste mode due to the
lexer only checking for \n in the "following" character position, before
next_char() has had a chance to convert \r and \r\n to \n.
2017-05-12 15:14:25 +10:00
Damien George 852c215d76 tests/extmod/vfs: Update tests to reflect new ilistdir() method. 2017-05-10 11:39:29 +10:00
Damien George 9bd67d9fbc tests/extmod: Make some vfs tests fully unmount FSs before running.
Otherwise the existing FSs can interfere with the tests, and in some
cases the tests can write to the real FS on the device.
2017-05-09 15:50:40 +10:00
Tom Collins d00d062af2 tests/basics/lexer: Add lexer tests for input starting with newlines. 2017-05-09 14:48:00 +10:00
Damien George e711e2d44a tests/basics: Add memoryview test for big ints. 2017-05-09 10:49:19 +10:00
Damien George 2e9e14980d tests/basics: Update array test for big-int with lL typecodes. 2017-05-09 10:46:43 +10:00
Paul Sokolovsky 4a4490ffcc py/modio: resource_stream: Implement "package" param handling. 2017-05-06 18:42:35 +03:00
Damien George 084824f866 tests: Move super-as-local test from cpydiff to basic tests.
It's now possible to use the name "super" as a local variable.
2017-05-06 11:01:57 +10:00
Damien George dce7dd4259 tests/micropython: Add test for int.from_bytes with many zero bytes. 2017-05-06 10:29:09 +10:00
Damien George 1b3e372418 tests/extmod: Add some more VFS tests. 2017-05-05 20:15:10 +10:00
Damien George 6c8b57a902 tests/extmod: Add more tests for VFS FAT. 2017-05-05 20:15:10 +10:00
Paul Sokolovsky 12ea06567c tests/cpydiff/core_function_unpacking: Fill in workaround. 2017-05-04 00:48:48 +03:00
Paul Sokolovsky 92657c671f tests/cpydiff/core_import_split_ns_pkgs: Test for split namespace packages. 2017-05-03 17:16:19 +03:00
Paul Sokolovsky 3923f96dc6 tests/cpydiff/core_import_path: Test showing difference in package.__path__. 2017-05-03 12:22:53 +03:00
Paul Sokolovsky 7d4ba9d257 tests/io/resource_stream: Add test for uio.resource_stream(). 2017-05-03 01:47:14 +03:00
Paul Sokolovsky c1b19115e5 tests/cpydiff/core_import_prereg: Fill in cause and workaround. 2017-05-02 14:12:52 +03:00
Paul Sokolovsky 8bb84cc627 tests/cpydiff/core_function_userattr: Clarify, fill in cause and workaround. 2017-05-02 03:43:21 +03:00
Paul Sokolovsky 58ecbc7752 tests/cpydiff/core_arguments: Fill in cause/workaround. 2017-05-02 03:36:47 +03:00
Damien George 810133d97d tests/basics: Add tests for int.from_bytes when src has trailing zeros.
The trailing zeros should be truncated from the converted value.
2017-04-25 12:07:02 +10:00
Damien George 30badd1ce1 tests: Add tests for calling super and loading a method directly. 2017-04-22 23:39:38 +10:00
Damien George 5335942b59 py/compile: Refactor handling of special super() call.
This patch refactors the handling of the special super() call within the
compiler.  It removes the need for a global (to the compiler) state variable
which keeps track of whether the subject of an expression is super.  The
handling of super() is now done entirely within one function, which makes
the compiler a bit cleaner and allows to easily add more optimisations to
super calls.

Changes to the code size are:

   bare-arm: +12
    minimal:  +0
   unix x64: +48
unix nanbox: -16
     stmhal:  +4
     cc3200:  +0
    esp8266: -56
2017-04-22 21:46:32 +10:00
Paul Sokolovsky 9e8f316392 extmod/moductypes: Fix bigint handling for 32-bit ports. 2017-04-21 16:43:21 +03:00
Damien George c7c14f1634 tests/micropython: Add test for micropython.kbd_intr(). 2017-04-18 17:24:30 +10:00
Paul Sokolovsky 57b5ee2fcf tests/run-tests: Don't post-process CRASH result in any way.
If we got a CRASH result, return early, similar to SKIP. This is important
because previous refactor changed branching logic a bit, so CRASH now gets
post-processed into CRASH\n, which broke remote hardware tests.
2017-04-16 17:59:11 +03:00
Damien George 61616e84ce extmod/machine_signal: Rename "inverted" arg to "invert", it's shorter.
A shorter name takes less code size, less room in scripts and is faster to
type at the REPL.

Tests and HW-API examples are updated to reflect the change.
2017-04-15 21:01:47 +03:00
Paul Sokolovsky 5b8122f2bb tests/run-tests: Search feature checks wrt to main script location.
If run-tests script is run from another dir, we still want to look up
feature checks in run-tests' dir.
2017-04-14 17:07:13 +03:00
Damien George 967cad7434 tests/extmod/utimeq1: Improve coverage of utimeq module. 2017-04-13 23:34:28 +10:00
Damien George b6fff4186d tests/basics: Add test for tuple inplace add. 2017-04-05 12:38:18 +10:00
Damien George dcd8f52766 tests/basics: Add tests for raising ValueError when range() gets 0 step. 2017-04-05 10:52:29 +10:00
Peter Hinch 468c6f9da1 extmod/modframebuf: Make monochrome bitmap formats start with MONO_.
MONO_xxx is much easier to read if you're not familiar with the code.
MVLSB is deprecated but kept for backwards compatibility, for the time
being.

This patch also updates the associated docs and tests.
2017-04-04 17:38:33 +10:00
Damien George 805b1c8bc3 tests/run-tests: Update names of tests that may need skipping. 2017-04-04 12:26:43 +10:00
Damien George 677fb31015 tests/float: Add tests for hashing float and complex numbers. 2017-04-04 12:14:34 +10:00
Paul Sokolovsky 831e157226 tests/run-tests: Introduce generic "minimal" target.
Used e.g. by Zephyr port.
2017-04-03 10:20:48 +03:00
Paul Sokolovsky 806c07c898 tests/micropython/heapalloc_iter: Improve skippability. 2017-04-03 00:27:01 +03:00
Paul Sokolovsky 28876d3902 tests/float/byte*_construct: Skip on missing array module. 2017-04-03 00:17:43 +03:00
Paul Sokolovsky 499ea8b253 tests/extmod/vfs_fat_fileio*: Improve skippability.
Should be skipped on missing uso, uerrno modules.
2017-04-03 00:14:57 +03:00
Paul Sokolovsky b099aeb3ca run-tests: Add feature check for "const" keyword and skip related tests. 2017-04-02 22:52:18 +03:00
Paul Sokolovsky b9e9cfcfc1 tests: vfs_fat_fileio.py is too big to be parsed in 16K heap, split in 2.
This restores ability to run testsuite with 16K heap.
2017-04-02 22:02:11 +03:00
Paul Sokolovsky 5b2db4bb51 tests/run-tests: Be sure to close Pyboard object on completion.
So underlying device was properly closed too.
2017-04-02 20:49:16 +03:00
Damien George bf51e2ff98 tests/basics: Add tests for list and bytearray growing using themselves. 2017-04-02 17:31:32 +10:00
Damien George 734775524e tests/basics: Add test for super() when self is closed over. 2017-03-27 11:29:11 +11:00
Damien George bfb48c1620 tests/float: Add tests for round() of inf, nan and large number. 2017-03-24 11:00:45 +11:00
Damien George bacb52aa2d tests/float: Add tests for math funcs that return ints.
One should test bigint, inf and nan to make sure all cases are covered.
2017-03-23 23:54:10 +11:00
Paul Sokolovsky 4a4bb84e92 tests/heapalloc_str: Test no-replacement case for str.replace(). 2017-03-22 22:17:52 +03:00
Peter Hinch 231cfc84a7 extmod/modframebuf: Add support for monochrome horizontal format.
MHLSB and MHMSB formats are added to the framebuf module, which have 8
adjacent horizontal pixels represented in a single byte.
2017-03-20 16:21:47 +11:00
Damien George 74faf4c5fc unix/coverage: Enable scheduler and add tests for it. 2017-03-20 15:20:26 +11:00
Damien George c772817dee tests/micropython: Add tests for micropython.schedule(). 2017-03-20 15:20:26 +11:00
Damien George eeff0c3528 tests/basics/bytes_add: Add tests for optimised bytes addition. 2017-03-16 14:31:03 +11:00
Damien George ecb4357fe1 tests/basics: Move string-modulo-format int tests to dedicated file. 2017-03-15 17:34:47 +11:00
Damien George b154468b08 tests/basics: Add test for string module formatting with int argument. 2017-03-15 17:31:17 +11:00
Damien George 3a0b2be6e2 tests/basics/string_format2: Adjust comment now that tests succeed. 2017-03-15 17:25:46 +11:00
Damien George e29f704b67 tests/micropython/viper_error: Add more tests to improve coverage. 2017-03-14 23:05:41 +11:00
Rami Ali 8a57cacd78 tests/extmod: Improve tinfgzip.c test coverage. 2017-03-14 22:13:36 +11:00
Damien George a49a96bb5d tests/extmod/vfs_basic: Unmount all existing devices before doing test.
This is so the test can run successfully on targets that already have
something mounted.
2017-03-14 22:08:37 +11:00
Damien George 923ec1169f tests/run-tests: Re-instate skipping of doubleprec test on pyboard. 2017-03-14 22:07:52 +11:00
Damien George 05fec17d9b tests/basics/struct_micropython: Add test for 'S' typecode in ustruct.
The 'S' typecode is a uPy extension so it should be grouped with the other
extension (namely 'O' typecode).  Testing 'S' needs uctypes which is an
extmod module and not always available, so this test is made optional and
will only be run on ports that have (u)struct and uctypes.  Otherwise it
will be silently skipped.
2017-03-14 18:27:43 +11:00
Rami Ali 77cbd173df tests: Improve binary.c test coverage. 2017-03-14 18:27:29 +11:00
Rami Ali 4e86ca398f tests/extmod: Improve re1.5/recursiveloop.c test coverage. 2017-03-14 17:17:45 +11:00
Damien George 773b0bac41 tests/extmod/vfs_basic: Add more tests for basic VFS functionality. 2017-03-14 16:07:30 +11:00
Damien George 8891b2e700 tests/extmod: Add a test for core VFS functionality, sans any filesystem. 2017-03-13 21:42:02 +11:00
Paul Sokolovsky 3e321f1724 tests/misc/: Make few tests skippable. 2017-03-11 01:17:02 +01:00
Damien George f07a56fa3b tests/extmod: Rename websocket test to websocket_basic.
This is so that the filename of the test doesn't clash with the module name
itself (being "websocket"), and lead to potential problems executing the
test.
2017-03-10 15:05:08 +11:00
Paul Sokolovsky c9705cff68 tests/basics/fun_error: Split out skippable test. 2017-03-10 02:22:56 +01:00
Paul Sokolovsky 854bb322bf tests/feature_check/int_big: Rework "big int" detection.
MICROPY_LONGINT_IMPL_LONGLONG doesn't have overflow detection, so just
parsing a large number won't give an error, we need to print it out
to check that the whole number was parsed.
2017-03-10 02:11:43 +01:00
Paul Sokolovsky bc5bffbf65 tests/micropython/opt_level: Clarify the expected output for opt_level == 3. 2017-03-09 23:22:31 +01:00
Paul Sokolovsky 53018d5ad2 tests/micropython/heapalloc_traceback: Fix backtrace line # after refactor. 2017-03-09 12:51:45 +01:00
Paul Sokolovsky 1a71d30fb8 tests/micropython: Make uio-using tests skippable. 2017-03-09 10:26:31 +01:00
Paul Sokolovsky ce63a95a85 tests/dict_fromkeys: Split out skippable part. 2017-03-09 08:31:35 +01:00
Alex March ce0b5e078b tests/extmod: Add websocket tests.
These short unit tests test the base uPy methods as well as parts of the
websocket protocol, as implemented by uPy.

@dpgeorge converted the original socket based tests by @hosaka to ones
that only require io.BytesIO.
2017-03-09 16:47:41 +11:00
Damien George 38f063ea72 tests/extmod: Add very basic feature test for ussl module.
This test just tests that the basic functions/methods can be called with
the appropriate arguments.  There is no real test of underlying
functionality.

Thanks to @hosaka for the initial implementation of this test.
2017-03-09 13:42:34 +11:00
Paul Sokolovsky a0cbc108ba tests/float: Make various tests skippable. 2017-03-09 00:11:05 +01:00
Paul Sokolovsky 983144404b tests/basic: Make various tests skippable. 2017-03-09 00:07:19 +01:00
Paul Sokolovsky bdd48e67ee tests/uctypes_array_assign_native_le: Split off intbig part. 2017-03-07 08:40:03 +01:00
Paul Sokolovsky c98d7461a1 tests/micropython/: Split off intbig tests. 2017-03-07 07:12:58 +01:00
Krzysztof Blazewicz 1bd17de4b7 tests/basics/unpack1.py: Test if *a, = b copies b when b is a list. 2017-03-07 16:48:16 +11:00
Krzysztof Blazewicz 38c3778b27 tests/basics/string_join.py: Add test case where argument is not iterable. 2017-03-07 16:48:16 +11:00
Paul Sokolovsky 88ffe0d5cc tests/string_format_modulo2: Split off intbig test. 2017-03-07 00:13:36 +01:00
Paul Sokolovsky 4b03941f5e tests/float2int*: Suffix with _intbig, don't run on any other int type.
I.e. they don't run successfully with MICROPY_LONGINT_IMPL_NONE
and MICROPY_LONGINT_IMPL_LONGLONG (the problem is that they generate
different output than CPython, TODO to fix that).
2017-03-06 16:30:12 +01:00
Paul Sokolovsky 121fb88988 float/float2int*: Make actually be parsable for MICROPY_LONGINT_IMPL_NONE.
The use of large literal numbers is a big no-no when it comes to writing
programs which work with different int representations. Also, some checks
are pretty adhoc (e.g using struct module to check for 64-bitness). This
change bases entire detection on sys.maxsize and integer operarions, and
thus more correct, even if longer.

Note that this change doesn't mean that any of these tests can pass with
anything but MPZ - even despite checking for various int representations,
the tests aren't written to be portable among them.
2017-03-06 16:23:09 +01:00
Paul Sokolovsky 325c4473a5 tests/float/complex1: Split out intbig test. 2017-03-06 15:46:01 +01:00
Paul Sokolovsky 3ab6aa3a6d tests/basic: Split tests into working with small ints and not working.
Tests which don't work with small ints are suffixed with _intbig.py. Some
of these may still work with long long ints and need to be reclassified
later.
2017-03-04 00:13:27 +03:00
Paul Sokolovsky 89e570a5b4 tests/run-tests: Check for big int availability and skip related tests.
Big aka arbitrary-precision integers (implemented by MPZ module) are used
in tests starting with "int_big_" or ending with "_intbig".
2017-03-03 20:16:59 +03:00
Damien George 3d91c12d33 tests/basics: Add further tests for OrderedDict. 2017-03-03 11:23:54 +11:00
Damien George ecc635d551 tests/extmod: Add test for machine.Signal class. 2017-03-02 16:09:16 +11:00
Damien George f4a12dca58 py/objarray: Disallow slice-assignment to read-only memoryview.
Also comes with a test for this.  Fixes issue #2904.
2017-02-27 16:09:57 +11:00
Damien George 5255255fb9 py: Create str/bytes objects in the parser, not the compiler.
Previous to this patch any non-interned str/bytes objects would create a
special parse node that held a copy of the str/bytes data.  Then in the
compiler this data would be turned into a str/bytes object.  This actually
lead to 2 copies of the data, one in the parse node and one in the object.
The parse node's copy of the data would be freed at the end of the compile
stage but nevertheless it meant that the peak memory usage of the
parse/compile stage was higher than it needed to be (by an amount equal to
the number of bytes in all the non-interned str/bytes objects).

This patch changes the behaviour so that str/bytes objects are created
directly in the parser and the object stored in a const-object parse node
(which already exists for bignum, float and complex const objects).  This
reduces peak RAM usage of the parse/compile stage, simplifies the parser
and compiler, and reduces code size by about 170 bytes on Thumb2 archs,
and by about 300 bytes on Xtensa archs.
2017-02-24 13:43:43 +11:00
Damien George f62503dc47 tests/micropython: Add test for consts that are bignums. 2017-02-24 13:08:18 +11:00
Damien George 465a604547 tests/cpydiff: Add a test for storing iterable to a list slice. 2017-02-20 17:22:12 +11:00
Rami Ali 86c7507233 tests/cpydiff: Add initial set of tests for uPy-CPython differences.
These tests are intended to fail, as they provide a programatic record of
differences between uPy and CPython.  They also contain a special comment
at the start of the file which has meta-data describing the difference,
including known causes and known workarounds.
2017-02-20 16:50:34 +11:00
Damien George 89267886cc py/objlist: For list slice assignment, allow RHS to be a tuple or list.
Before this patch, assigning anything other than a list would lead to a
crash.  Fixes issue #2886.
2017-02-20 15:09:59 +11:00
Paul Sokolovsky 6fc6f10b1e tests/heapalloc_exc_raise.py: Heap alloc test for raising/catching exc. 2017-02-20 04:22:32 +03:00
Damien George d87c6b6768 tests/basics/string_join: Add more tests for string concatenation. 2017-02-17 12:30:27 +11:00
Damien George c889f01b8d tests/cmdline/cmd_parsetree: Update to work with changes to grammar. 2017-02-17 12:29:51 +11:00
Damien George 0ec957d7c5 tests/cmdline: Update cmd_parsetree test for changes to grammar order. 2017-02-16 19:45:07 +11:00
Damien George 7839b8b827 tests/micropython/heapalloc_iter: Add tests for contains and unpack. 2017-02-16 19:11:34 +11:00
Damien George 019048a6dc tests/micropython: Add test for iterating with the heap locked. 2017-02-16 19:11:34 +11:00
Damien George 86b3db9cd0 tests/cmdline/cmd_showbc: Update to work with recent changes. 2017-02-16 18:38:07 +11:00
Damien George 861b001783 tests/cmdline: Update tests to pass with latest changes to bytecode. 2017-02-16 18:38:07 +11:00
Damien George f4df3aaa72 py: Allow bytecode/native to put iter_buf on stack for simple for loops.
So that the "for x in it: ..." statement can now work without using the
heap (so long as the iterator argument fits in an iter_buf structure).
2017-02-16 18:38:06 +11:00
Paul Sokolovsky f980c70997 tests/basic/: Make various tests skippable.
To run the testsuite on small ports.
2017-02-15 18:11:16 +03:00
Paul Sokolovsky b737c9cbc8 tests/gen_yield_from_close: Use range() instead of reversed().
As a "more basic" builtin iterator, present even in smaller ports.
2017-02-15 17:05:27 +03:00
Damien George 06a12ada48 tests/thread: Add stress-test for creating many threads. 2017-02-15 11:12:37 +11:00
Damien George 2847d7431d tests/thread: Replace busy waiting loops with a loop that sleeps.
Depending on the thread scheduler, a busy-wait loop can hog the CPU and
make the tests very slow.  So convert such loops to loops that have an
explicit sleep, allowing the worker threads to do their job.
2017-02-15 11:12:37 +11:00
Paul Sokolovsky f2d732f459 tests/extmod: Make tests skippable. 2017-02-15 01:56:22 +03:00
Paul Sokolovsky 7bb146350e tests/dict_fromkeys: Revert to use reversed() to run in native codegen mode. 2017-02-15 01:30:16 +03:00
Paul Sokolovsky 83623b2fde tests/basic/[a-f]*: Make skippable.
For small ports which don't have all features enabled.
2017-02-15 00:57:56 +03:00
Paul Sokolovsky d61ce32022 tests/builtin_dir: The most expected thing in sys is exit, test for it. 2017-02-14 23:30:06 +03:00
Paul Sokolovsky 800b163cd8 tests/comprehension1, containment: Split set tests to separate files.
To make skippable.
2017-02-14 22:31:08 +03:00
Paul Sokolovsky ce2e0eeb7b tests/run-tests: Allow to skip tests using async/await keywords. 2017-02-14 22:03:25 +03:00
stijn c6fd9ba4f3 tests: Add option to not clear MICROPYPATH when running tests
This allows using the test runner for other scenarios than just
testing uPy itself.
The principle of comparing either to CPython or else to a .exp
file is really handy but to be able to test custom modules not
built into micropython.exe one needs to be able to specify the
module search path a.k.a MICROPYPATH.
2017-02-14 20:19:00 +03:00
Damien George e08395a35c tests/misc: Add test for line number printing with large bytecode chunk. 2017-02-10 12:02:02 +11:00
dmazzella 18e6569166 py/objtype: Implement __delattr__ and __setattr__.
This patch implements support for class methods __delattr__ and __setattr__
for customising attribute access.  It is controlled by the config option
MICROPY_PY_DELATTR_SETATTR and is disabled by default.
2017-02-09 12:40:15 +11:00
Damien George d3bb3e38df tests/pyb: Adjust tests so they can run on PYB and PYBLITE.
A few tests still fail on PYBLITE, and that's due to differences in the
available peripheral block numbers on the different MCUs (eg I2C(2)
exists on one, but it's I2C(3) on the other).
2017-02-06 13:50:34 +11:00
Damien George 27c149efe0 stmhal: Add pyb.fault_debug() function, to control hard-fault behaviour.
This new function controls what happens on a hard-fault:
- debugging disabled: board will do a reset
- debugging enabled: board will print registers and stack and flash LEDs

The default is disabled, ie to do a reset.  This is different to previous
behaviour which flashed the LEDs and waited indefinitely.
2017-02-06 13:22:17 +11:00
Paul Sokolovsky d5e9ab6e61 extmod/machine_pulse: Make time_pulse_us() not throw exceptions.
machine.time_pulse_us() is intended to provide very fine timing, including
while working with signal bursts, where each transition is tracked in row.
Throwing and handling an exception may take too much time and "signal loss".
So instead, in case of a timeout, just return negative value. Cases of
timeout while waiting for initial signal stabilization, and during actual
timing, are recognized.

The documentation is updated accordingly, and rewritten somewhat to clarify
the function behavior.
2017-02-05 14:20:17 +03:00
Damien George 84fb292cd5 tests/basics/string_format_modulo: Add more tests for dict formatting. 2017-02-03 12:17:43 +11:00
Paul Sokolovsky 87882e1708 tests: Split tests for 2- and 3-arg pow(). 2017-02-02 23:34:52 +03:00
Nicko van Someren df0117c8ae py: Added optimised support for 3-argument calls to builtin.pow()
Updated modbuiltin.c to add conditional support for 3-arg calls to
pow() using MICROPY_PY_BUILTINS_POW3 config parameter. Added support in
objint_mpz.c for for optimised implementation.
2017-02-02 22:23:10 +03:00
Damien George 8a39e18f5f tests/float: Add tests for zero to a negative power. 2017-02-03 00:04:13 +11:00
Damien George 05c70fdfba tests/basics/set_binop: Add tests for inplace set operations. 2017-02-02 23:36:53 +11:00
Paul Sokolovsky b32880bd51 tests/heapalloc_bytesio: Test for BytesIO with preallocates space. 2017-02-02 00:38:38 +03:00
Damien George 28185bb81b tests/thread: Fix stack size test so tests run reliably on baremetal. 2017-02-01 17:21:35 +11:00
Damien George bebb3a6160 tests/thread: Make thread_exc2 runable on baremetal. 2017-01-31 13:59:20 +11:00
Paul Sokolovsky 33b8e65bc0 tests/basics/zip: Make skippable. 2017-01-31 00:33:01 +03:00
Paul Sokolovsky aee723ed4c tests/run-tests: Skip frozenset tests if set literal syntax is not available. 2017-01-31 00:25:09 +03:00
Damien George a0c729681f tests/extmod/vfs_fat_ramdisk: Make it work on pyboard. 2017-01-27 23:22:15 +11:00
Damien George b9bfaa349a tests/extmod/vfs_fat: Update tests to work with new VFS sub-system.
The vfs_fat_fsusermount test is no longer relevant so has been removed.
2017-01-27 17:21:45 +11:00
Damien George 94d87fbb30 test/extmod: Update vfs_fat tests for new OO FatFs library.
The new version of FatFs requires a minimum of 50 blocks on the device.
Also, some tests no longer make sense with an OO vfs.
2017-01-27 13:19:10 +11:00
Paul Sokolovsky 9ffc3ae0e7 tests/heapalloc_str: Test for alloc-free string operations.
Starts with concatenation with an empty string.
2017-01-27 00:49:39 +03:00
Damien George 221f88d1f3 tests/extmod: Add test for ure debug printing when compiling a regex. 2017-01-26 23:45:51 +11:00
Damien George bf51200bc1 tests/extmod/framebuf1: Fix test for framebuf invalid constructor. 2017-01-25 23:23:50 +11:00
Oleg Korsak 406fb3cb60 tests/extmod/framebuf4: Add tests for GS4_HMSB framebuf format. 2017-01-25 23:20:19 +11:00
Oleg Korsak fd99690f18 extmod/modframebuf: Add GS4_HMSB format. 2017-01-25 23:19:28 +11:00
stijn 533129f835 tests: Make sure special tests can be skipped as well.
Fixes #2806.
2017-01-24 00:30:55 +11:00
Damien George 20fc620327 tests/basics/builtin_help: Add test for help('modules'). 2017-01-22 12:14:56 +11:00
Damien George 1864f90e9a tests: Add test for builtin help function. 2017-01-22 11:56:16 +11:00
Paul Sokolovsky bd3dd9296b tests/heapalloc_int_from_bytes: Test that int.from_bytes() can work w/o alloc.
For a small number of bytes, it's expected to return a small int without
allocation.
2017-01-21 20:15:56 +03:00
Paul Sokolovsky 3b09dca046 tests: Add test for int.from_bytes() for arbitrary-precision integer.
This test works only for MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ
and needs a way of skipping in other cases.
2017-01-21 20:15:31 +03:00
Damien George 1639200e57 tests/basics: Add test for assignment of attribute to bound method. 2017-01-20 13:17:22 +11:00
Damien George 7314ebae8a tests/misc/non_compliant: Add test for inability to assign func attrs. 2017-01-19 23:38:53 +11:00
Damien George fb5838041b tests/micropython/opt_level: Add test for opt_level 3. 2017-01-19 23:38:11 +11:00
Damien George 4c4f586e2c tests/extmod/framebuf1: Add test for no-op fill_rect. 2017-01-19 23:37:44 +11:00
Damien George 213a718953 tests/float: Add test for assigning to attribute of complex number. 2017-01-19 23:37:21 +11:00
Paul Sokolovsky af90461931 py/binary: mp_binary_get_size: Raise error on unsupported typecodes.
Previouly, we had errors checked in callers, which led to duplicate code
or missing checks in some places.
2017-01-17 22:53:06 +03:00
Rami Ali 5e80c53c11 tests/extmod: Improve test coverage of ure module. 2017-01-17 17:42:37 +11:00
Rami Ali 5314219f18 tests/basics: Improve runtime.c test coverage. 2017-01-17 16:21:17 +11:00
Rami Ali cba723fc8c tests/io: Improve test coverage of io.BufferedWriter. 2017-01-17 13:27:02 +11:00
Damien George 96baaa68a4 tests: Update tests, and add new ones, for recent generator tweaks. 2017-01-17 00:17:44 +11:00
Rami Ali 751e379533 tests: Improve frozen import test coverage. 2017-01-16 16:59:03 +11:00
Damien George 63e291de70 py/builtinimport: Raise ValueError for bad relative import, per CPython. 2017-01-16 16:21:04 +11:00
Rami Ali 50e14ca619 tests/import: Improve builtinimport.c test coverage. 2017-01-16 15:59:33 +11:00
Rami Ali 8d01bd3a1c tests: Improve stream.c test coverage. 2017-01-16 15:57:10 +11:00
Damien George 65cadbeb9d tests: Update test suite to be compatible with CPython 3.6.
CPython 3.6 has a few changes that, when run on uPy's test suite, give a
different output to CPython 3.5.  uPy currently officially supports the
3.4 language definition, but it's useful to be able to run the test suite
with 3.4/3.5/3.6 versions of CPython.  This patch makes such changes to
support 3.6.
2017-01-09 00:19:01 +11:00
Damien George a722ed532f tests/unix/extra_coverage: Add tests for importing frozen packages. 2017-01-08 22:45:55 +11:00
Paul Sokolovsky ef1bbada96 tests/array*: Allow to skip test if "array" is unavailable. 2017-01-07 01:13:40 +03:00
Paul Sokolovsky e5a6a26330 tests/types1: Split out set type test to set_types.
set isn't the most basic type and can be disabled by a port.
2017-01-06 11:01:55 +03:00
Damien George 8d1c236a1f tests/unix/extra_coverage: Add basic tests to import frozen str and mpy. 2017-01-05 14:58:08 +11:00
Rami Ali d7e168428b tests/unix: Improve formatfloat.c test coverage using C. 2017-01-05 12:31:05 +11:00
Rami Ali 64dc925c4a tests/float: Improve formatfloat.c test coverage using Python. 2017-01-05 12:31:05 +11:00
Rami Ali ec72db8a39 tests: Improve warning.c test coverage. 2017-01-05 12:23:40 +11:00
Paul Sokolovsky 26f00ff154 tests/run-tests: Allow to skip set tests.
If sets are not enabled, set literals lead to SyntaxError during parsing,
so it requires feature_check. Set tests are skipped based on set_*.py
pattern.
2017-01-05 00:16:29 +03:00
Damien George 54ea10a76a tests/pyb/uart: Update test to match recent change to UART timeout_char. 2017-01-04 17:53:41 +11:00
Rami Ali 75aa7befec tests/unix: Improve runtime_utils.c test coverage. 2016-12-29 18:24:03 +11:00
Rami Ali b7024f0f64 tests/cmdline: Improve repl.c autocomplete test coverage. 2016-12-29 17:14:04 +11:00
Rami Ali f397e1fdf0 tests/thread: Improve modthread.c test coverage. 2016-12-29 13:27:50 +11:00
Rami Ali c15ebf7c8c tests/extmod: Improve ubinascii.c test coverage. 2016-12-29 13:22:19 +11:00
Rami Ali eae819c0ed tests/micropython: Add test for micropython.stack_use() function. 2016-12-28 17:46:52 +11:00
Rami Ali 65574f817a tests/basics: Add tests to improve coverage of binary.c. 2016-12-28 16:11:54 +11:00
Damien George 43384ad7e7 tests/basics: Add tests for parsing of ints with base 36. 2016-12-28 12:08:46 +11:00
Paul Sokolovsky 05aebb9206 tests/heapalloc_inst_call: Test for no alloc for simple object calls. 2016-12-25 00:50:27 +03:00
Paul Sokolovsky 492c612f9d tests/utimeq_stable: Test for partial stability of utimeq queuing. 2016-12-24 00:25:15 +03:00
Paul Sokolovsky ffe807f349 extmod/moduheapq: Revert change for adhoc relative-time queue support.
Now that specialized utimeq module has been implenented, revert previous
adhoc changes to uheapq.

This reverts commit 0cbc07227c.
2016-12-22 06:37:49 +03:00
Damien George cdec7ba30e tests: Add a coverage test for printing the parse-tree. 2016-12-22 11:26:06 +11:00
Damien George adccafb42a tests/basics/lexer: Add a test for newline-escaping within a string. 2016-12-22 10:32:06 +11:00
Paul Sokolovsky 5d9025a76e tests/extmod: Add test for utimeq module. 2016-12-22 00:31:38 +03:00
Rami Ali 1731868ae7 tests: Add tests to improve coverage of objarray.c. 2016-12-21 18:21:41 +11:00
Rami Ali 531c206e8b tests: Add tests to improve coverage of runtime.c. 2016-12-21 15:44:41 +11:00
Damien George 67f3edc10a tests/import: Add a test which uses ... in from-import statement. 2016-12-21 11:25:53 +11:00
Rami Ali 5d06a74303 tests/basics: Improve test coverage for generators. 2016-12-20 16:19:56 +11:00
Damien George 1e7a801e2d tests/run-tests: For REPL tests make sure the REPL is exited at the end. 2016-12-20 15:13:49 +11:00
Damien George 7bbce4e213 tests/basics/set_pop: Improve coverage of set functions. 2016-12-20 14:25:06 +11:00
Damien George b470f59892 tests/basics: Add test for builtin locals(). 2016-12-20 14:08:57 +11:00
Damien George d291007fea tests/basics/builtin_dir: Add test for dir() of a type. 2016-12-20 14:08:27 +11:00
Damien George 49bf7617d0 tests/float/builtin_float_round: Test round() with second arg. 2016-12-20 14:01:10 +11:00
Rami Ali 5e1ccddc82 tests/basics: Improve mpz test coverage. 2016-12-20 10:15:48 +11:00
Paul Sokolovsky 91359c8690 tests/struct*: Make skippable. 2016-12-19 19:41:12 +03:00
Damien George 7081ea4119 tests/micropython: Get heapalloc_traceback test running on baremetal.
When printing exceptions from files sent to a target by pyboard.py the
filename in the exception is <stdin>, which differs to when running the
script on the PC.  So we strip out the filename to make the outputs the
same on all targets (see also misc/print_exception.py test).
2016-12-15 11:11:57 +11:00
Rami Ali 9112b0b62b tests/extmod: Improve modframebuf test coverage. 2016-12-13 16:29:21 +11:00
Rami Ali d22762017e tests/extmod: Improve moductypes test coverage. 2016-12-12 17:09:14 +11:00
Paul Sokolovsky aee13ef3f2 tests: Update for required byteorder arg for int.from_bytes()/to_bytes(). 2016-12-09 22:53:30 +03:00
Damien George 898d4c1217 extmod/modframebuf: Make framebuf implement the buffer protocol.
So that one can easily access the underlying data of the frame buffer, eg
to write the data out to a display.
2016-12-08 15:17:47 +11:00
Damien George 042d5f24d6 tests/extmod/framebuf1: Add basics tests for hline, vline, rect, line. 2016-12-05 11:55:43 +11:00
Paul Sokolovsky e44b236ce2 tests/extmod/btree1: Exercise btree.flush(). 2016-12-05 01:55:05 +03:00
Damien George 6194336d81 tests/extmod/vfs_fat_fileio: Add test for constructor of FileIO type. 2016-12-02 15:37:58 +11:00
Damien George b7df3e541a extmod/vfs_fat: Implement POSIX behaviour of rename, allow to overwrite.
If the destination of os.rename() exists then it will be overwritten if it
is a file.  This is the POSIX behaviour, which is also the CPython
behaviour, and so we follow suit.

See issue #2598 for discussion.
2016-12-02 15:06:09 +11:00
Damien George 81e171b7bb extmod/modframebuf: Add back legacy FrameBuffer1 "class".
For backwards compatibility.  It simple creates a frame buffer with the
MVLSB format.
2016-12-01 16:43:25 +11:00
Radomir Dopieralski 225e22b287 extmod/modframebuf: Make FrameBuffer handle 16bit depth.
Rename FrameBuffer1 into FrameBuffer and make it handle different bit
depths via a method table that has getpixel and setpixel.  Currently
supported formats are MVLSB (monochrome, vertical, LSB) and RGB565.

Also add blit() and fill_rect() methods.
2016-12-01 16:43:25 +11:00
Damien George dbc09d03f6 tests/basics: Enable tests for list slice getting with 3rd arg.
Also add a test to check case when 3rd arg is 0.
2016-11-26 16:39:25 +11:00
Damien George 4c3c515bd1 tests/basics: Change dict_fromkeys test so it doesn't use generators.
And then it can run with the native emitter.
2016-11-26 16:38:38 +11:00
Damien George a4f96c8c2a tests/basics: Add tests for if-expressions. 2016-11-26 16:15:31 +11:00
Damien George a31a3a9fd5 tests/basics: Add test for dict.fromkeys where arg is a generator.
Improves coverage because it tests the case where the arg does not have a
__len__ slot.
2016-11-26 15:38:48 +11:00
Rami Ali 2eff9c29a1 tests/basics: Improve user class coverage. 2016-11-22 15:49:02 +11:00
Rami Ali 1b41cacac7 tests/extmod: Improve ujson coverage. 2016-11-22 15:48:42 +11:00
Damien George 1f43d49f9e tests/micropython: Move alloc-less traceback test to separate test file.
The native emitter doesn't provide proper traceback info so this test
should not be run in that case.
2016-11-21 17:39:23 +11:00
Damien George d70f87aaa2 tests/micropython: Add test for creating traceback without allocation. 2016-11-21 17:10:17 +11:00
Damien George 30bca45e1a tests/basics: Add test for logical constant folding. 2016-11-15 16:48:49 +11:00
Paul Sokolovsky 8212773adb tests: Use read() instead of readall(). 2016-11-14 00:27:35 +03:00
Paul Sokolovsky 0cbc07227c extmod/moduheapq: Adhoc changes to support ordering by utime.ticks_ms().
As required for further elaboration of uasyncio, like supporting baremetal
systems with wraparound timesources. This is not intended to be public
interface, and likely will be further refactored in the future.
2016-11-12 02:33:17 +03:00
Damien George c4e58eaa98 stmhal/i2c: Add option to I2C to enable/disable use of DMA transfers.
New keyword option in constructor and init() method is "dma=<bool>".
DMA is now disabled by default for I2C transfers because it currently does
not handle I2C bus errors very well (eg if slave device doesn't ACK or
NACK correctly during a transfer).
2016-11-11 17:36:19 +11:00
Damien George 679c0c4c83 tests/micropython: Add test for import from within viper function. 2016-11-10 22:54:55 +11:00
Paul Sokolovsky fa3a108ed7 tests/vfs_fat_oldproto: Skip for ports not supporting "oldproto".
Otherwise this broke esp8266 testsuite.
2016-11-06 01:47:44 +03:00
Alex March 94aeba0427 tests/extmod/framebuf1: Test framebuffer pixel clear, and text function. 2016-11-03 00:10:17 +11:00
Paul Sokolovsky be6a765c69 tests/extmod/ticks_diff: Test for new semantics of ticks_diff(). 2016-10-30 21:33:12 +03:00
Fabio Utzig 8908e505ce py/sequence: Fix reverse slicing of lists. 2016-10-30 15:54:19 -02:00
Paul Sokolovsky 1ba4db5685 tests/btree1: Fix out of memory error running on esp8266. 2016-10-29 19:53:31 +03:00
Alex March cc0cc67815 tests/extmod/uhashlib_sha256: Rename sha256.py test. 2016-10-28 19:51:54 +03:00
Alex March b83ac44e82 tests/extmod/uhashlib_sha1: Coverage for SHA1 algorithm. 2016-10-28 19:51:46 +03:00
Alex March 964fb2450e tests/basics/gc1: Garbage collector threshold() coverage. 2016-10-27 22:15:42 +03:00
Alex March fbca4f94b3 tests/extmod/vfs_fat_oldproto: Test old block device protocol. 2016-10-27 12:22:43 +11:00
Alex March 38a9359339 tests/extmod/vfs_fat_fsusermount: Improve fsusermount test coverage. 2016-10-27 12:22:42 +11:00
Damien George 25c6fc731b tests/basics: Add test for builtin "delattr". 2016-10-24 13:50:39 +11:00
Damien George bc5b896f24 tests/basics/builtin_slice: Add test for "slice" builtin name. 2016-10-24 13:35:39 +11:00
Damien George 5694201930 extmod/vfs_fat_file: Make file.close() a no-op if file already closed.
As per CPython semantics.  In particular, file.__del__() should not raise
an exception if the file is already closed.
2016-10-24 12:59:20 +11:00
Alex March cb20d999bc tests/extmod/vfs_fat: Improve VFS test coverage.
Covered case:
- Stat cases
- Invalid read/write/flush/close
- Invalid mkdir/rmdir/remove/getcwd
- File seek/tell, modes a/x/+, t/b
- Writing to a full disk
- Full path rename, slash trim
- Rename cases
- Bytestring listdir
- File object printing
2016-10-24 12:49:19 +11:00
Damien George 1e3a7c4ac5 tests/run-tests: Enable extmod/machine1.py on pyboard.
It now works.
2016-10-17 13:18:27 +11:00
Damien George 6caca3259f tests: Add test to print full KeyError exc from failed dict lookup. 2016-10-17 12:01:18 +11:00
Damien George e9404e5f5f tests: Improve coverage of array, range, dict, slice, exc, unicode. 2016-10-17 11:43:47 +11:00
Damien George 453c2e8f55 tests/cmdline: Improve coverage test for printing bytecode. 2016-10-17 11:23:37 +11:00
Damien George 34d0b3f85c tests/micropython: Add tests for heap_lock, and emergency exceptions. 2016-10-14 00:32:34 +11:00
Alex March e42186d356 tests/extmod/vfs_fat: Replace asserts with prints and expected outputs. 2016-10-13 14:56:47 +03:00
Damien George 11ab807d76 tests/extmod: Add test for ujson.load(). 2016-10-13 11:46:49 +11:00
Alex March f274561e16 tests/extmod/vfs_fat: Test coverage for remove() and rmdir(). 2016-10-11 16:03:52 +11:00
Damien George 5e22afce41 tests: Improve test coverage of py/compile.c. 2016-10-11 12:30:32 +11:00
Damien George 7f0e563de3 tests/micropython: Add test for micropython.opt_level() function. 2016-10-11 11:01:22 +11:00
Paul Sokolovsky 3dabaae47d tests/io/bytesio_ext: Add test for readinto(). 2016-10-09 12:01:02 +03:00
Paul Sokolovsky 49e140488d tests/io/write_ext: Add description comment. 2016-10-09 11:55:28 +03:00
Damien George 82af4d6749 tests: Improve coverage of struct with test for non-compliant behaviour. 2016-10-07 12:57:25 +11:00
Alex March 9fdba0e09c tests/extmod/uzlib: Test adaptive huffman tree for tinflate coverage. 2016-10-07 01:02:11 +11:00
stijn 7f19b1c3eb tests: Fix expected output of verbose cmdline test
The output might contain more than one line ending in 5b so properly skip
everything until the next known point.
This fixes test failures in appveyor debug builds.
2016-10-05 12:58:50 +02:00
Alex March addd1d3db1 tests/extmod/btree1: Checks for put, seq, string print and unsupported binary op. 2016-10-05 00:17:22 +11:00
Damien George cd20027f56 tests/run-tests: Disable cmdline/cmd_showbc test on Windows.
Disabled until a proper fix is found.
2016-10-04 14:42:51 +11:00
Damien George 9f72a14920 tests/basics: Add test for printing OSError when errno is unknown. 2016-09-30 16:45:10 +10:00
Damien George 17b4509564 tests/basics: Add test constructing a set from a non-trivial expression. 2016-09-30 15:00:15 +10:00
Damien George 3c582bc7cb tests/import: Add test for compiling "import a.b as c". 2016-09-30 14:48:22 +10:00
Damien George 6cf2a3966e tests/basics: Add further tests for nonlocal scoping and closures. 2016-09-30 14:20:55 +10:00
Damien George b32c01b748 py/compile: Fix async-for/async-with to work with simpler exc on stack.
There is now just the exception instance on the stack when an exception is
raised, not the full (type, exc, traceback).
2016-09-28 11:52:13 +10:00
Damien George 443cc0114d tests/basics: Add test for set.difference_update with arg being itself. 2016-09-28 11:10:27 +10:00
Damien George 2c7716fed0 py/objset: Ensure that use of frozenset.update raises an exception. 2016-09-28 11:06:18 +10:00
Damien George 290daa15d9 tests/float: Add test for parsing a float from an empty string. 2016-09-27 15:44:56 +10:00
Alex March 670376c5cb tests/extmod/vfs_fat_ramdisk: Add test for VFS.statvfs(). 2016-09-27 13:48:58 +10:00
Damien George 791b65f4b2 py/modmicropython: Add micropython.const, alias for identity function.
Having a micropython.const identity function, and writing "from micropython
import const" at the start of scripts that use the const feature, allows to
write scripts which are compatible with CPython, and with uPy builds that
don't include const optimisation.

This patch adds such a function and updates the tests to do the import.
2016-09-27 13:34:21 +10:00
Damien George f65e4f0b8f tests/cmdline/cmd_showbc: Fix test now that 1 value is stored on stack.
This corresponds to the change in the way exception values are stored on
the Python value stack.
2016-09-27 13:22:06 +10:00
Damien George 38b54b65d4 tests/micropython: Add tests for const names being replaced in parser. 2016-09-27 13:03:53 +10:00
Damien George 3f0c1c2452 tests/basics: Add test case for overflowing Py stack in try-finally. 2016-09-27 12:46:50 +10:00
Paul Sokolovsky d46de80162 tests/uzlib_decompio_gz: Test for DecompIO with gzip bitstream. 2016-09-24 15:43:23 +03:00
Damien George 3f5fe6269e tests/run-tests: Add --via-mpy option to run test from precompiled code.
With mpy-cross built, tests can now be run by first compiling them to .mpy
files, and then executing the .mpy file.  Usage: ./run-tests --via-mpy
2016-09-20 12:19:35 +10:00
Damien George bb954d80a4 tests: Get cmdline verbose tests running again.
The showbc function now no longer uses the system printf so works
correctly.
2016-09-20 11:33:19 +10:00
Paul Sokolovsky 60592fd23c tests/array1: Add tests for "l", "L" array types to improve coverage. 2016-09-19 17:20:41 +03:00
Paul Sokolovsky b85bcd671c tests/struct1: Test "l" specifier to improve coverage. 2016-09-19 17:01:02 +03:00
Damien George b9672bcbe8 tests/extmod: Add test for machine.time_pulse_us(). 2016-09-16 23:31:02 +10:00
Damien George 2b7c4a1878 tests/basics: Add errno1 test, to check basics of uerrno module. 2016-09-16 15:33:51 +10:00
Damien George 67a4813601 tests/extmod/urandom: Add urandom tests for error cases. 2016-09-16 12:49:15 +10:00
Damien George b236b1974b tests/pyb: Update exp file for previously updated extint test. 2016-09-09 19:37:45 +10:00
Damien George 2f02960607 tests/pyb: Add test for ExtInt when doing swint while disabled. 2016-09-09 19:36:09 +10:00
Damien George 763e04bba5 tests/run-tests: Disable thread/stress_recurse.py test on Travis.
It has reliability issues (cause unknown at this time).
2016-09-08 13:06:29 +10:00
Damien George cac8dc3414 tests/extmod/framebuf1: Add tests for scrolling in the x-direction. 2016-09-05 12:08:25 +10:00
Paul Sokolovsky 61e2dfd97d tests/extmod/uzlib_decompio: Add zlib bitstream testcases. 2016-09-04 14:45:27 +03:00
Damien George 2d8740a4d1 tests/extmod: Add a test for framebuf module, tested by coverage build. 2016-09-04 16:40:40 +10:00
Paul Sokolovsky fafd587514 tests/extmod: Add test for uzlib.DecompIO. 2016-09-03 00:20:30 +03:00
Damien George 58f3861358 tests/unix/extra_coverage: Add test for str/bytes with invalid hash. 2016-09-02 15:07:42 +10:00
Delio Brignoli f98bb2ddcb py/mpprint: Fail an assertion with unsupported format specifiers.
Arguments of an unknown type cannot be skipped and continuing to parse a
format string after encountering an unknown format specifier leads to
undefined behaviour.  This patch helps to find use of unsupported formats.
2016-09-01 18:09:44 +10:00
Damien George 8f8f699eb7 tests/run-tests: Disable thread_gc1.py test on Travis.
It has reliability issues (cause unknown at this time).
2016-08-27 23:41:16 +10:00
Radomir Dopieralski fea7fe45ea tests/extmod/vfs_fat_ramdisk: Add tests for VFS.umount()
Try to un-mount a file system and re-mount it again.
2016-08-26 23:24:32 +03:00
Damien George 3b5affa0d1 tests/cmdline: Add test for -O option to check optimisation value. 2016-08-26 22:29:38 +10:00
Damien George 78bc31e294 tests/run-tests: Disable thread/stress_heap.py when running on Travis.
It has reliability issues and sometimes fails on Travis (reason currently
unknown).
2016-08-25 14:06:40 +10:00
Paul Sokolovsky c428367543 extmod/modubinascii: Make crc32() support configurable.
Disable by default, enable in unix port.
2016-08-24 18:28:43 +03:00
Pavol Rusnak 39799f7564
extmod/modubinascii: implement binascii.crc32 2016-08-24 10:42:46 +02:00
Damien George 567e7fcd12 tests/run-tests: Disable thread/thread_lock4.py on Travis.
It has reliability issues that need to be worked out.
2016-08-17 13:48:09 +10:00
Paul Sokolovsky a6fc90f92a tests/uzlib_decompress: Actually test raw DEFLATE stream. 2016-08-17 06:10:16 +03:00
Damien George bb19e7b94b tests/basics/special_methods: Enable tests for extra special methods.
These additional special methods are enabled on most ports so we can test
them in this test.
2016-08-17 12:38:19 +10:00
rguillon ed6a1ada24 tests/basics: Add a test file for overriding special methods. 2016-08-17 12:11:32 +10:00
Damien George 095e43a9a5 py/sequence: Allow to use bignums as indices in slice objects.
See issue #2264.
2016-08-15 23:26:34 +10:00
Damien George f6a8e84a25 tests/basics: Add test for break from within try within a for-loop. 2016-08-15 21:28:41 +10:00
Damien George b359cf2911 tests/misc/non_compliant: Add tests to improve coverage testing. 2016-08-15 10:46:46 +10:00
Damien George d5f42c9daf tests/basics: Add more list tests to improve coverage testing. 2016-08-15 10:46:35 +10:00
Damien George 3c82d1d34b tests/basics: Add more tuple tests to improve coverage testing. 2016-08-15 10:46:02 +10:00
Paul Sokolovsky 0be4a7712d tests: Rename zlibd_decompress.py -> uzlib_decompress.py.
To use the actual current name.
2016-08-12 22:50:45 +03:00
Paul Sokolovsky 8897dcb2a1 tests/basics: bytes/str.partition/rpartition are now optional.
Skip tests if not available.
2016-08-07 22:14:34 +03:00
Paul Sokolovsky 3eb532e974 extmod/modbtree: Implement __contains__ operation. 2016-08-02 00:24:59 +03:00
Paul Sokolovsky bc3912980a tests/machine1: Revamp to work with unix port (which has "umachine"). 2016-07-31 04:30:48 +03:00
Paul Sokolovsky eb0e3bab1e tests/machine_mem.py: Too non-portable, rework as an example for unix port. 2016-07-31 04:22:09 +03:00
Paul Sokolovsky 617bda27e9 tests/extmod/btree1: Tests against in-memory DB (using io.BytesIO). 2016-07-31 02:29:05 +03:00
Paul Sokolovsky abd5a57ea1 tests/io/bytesio_ext: Test for .seek()/.flush() on BytesIO. 2016-07-29 23:00:25 +03:00
Paul Sokolovsky 6ead9f6f3d tests/run-tests: Make "regex'ed .exp" facility available to device tests.
Required to pass bytes_compare3.py (opptional warnings) on devices.
2016-07-26 23:08:33 +03:00
Paul Sokolovsky d1771bbae0 tests/unicode_subscr.py: Detailed test for subscripting unicode strings. 2016-07-25 19:28:19 +03:00
Paul Sokolovsky 6af90b2972 py/objstrunicode: str_index_to_ptr: Should handle bytes too.
There's single str_index_to_ptr() function, called for both bytes and
unicode objects, so should handle each properly.
2016-07-25 14:45:08 +03:00
Paul Sokolovsky 5a38694f55 tests/extmod/btree1: Close database at the end of test. 2016-07-24 00:30:32 +03:00
Paul Sokolovsky b652ee705b tests/bytes_compare: Rework test for bytes <-> str comparison.
This may produce a warning, depending on MicroPython configuration.
2016-07-22 12:02:04 +03:00
Paul Sokolovsky c3f519adfe tests/extmod/machine_pinbase: Skip if machine.PinBase is not available. 2016-07-17 16:30:24 +03:00
Paul Sokolovsky 0b52228739 tests: Add test for extended arguments to stream .write() method. 2016-07-14 11:48:15 +03:00
Damien George 2b5a1067c0 tests/run-tests: If running thread tests on unix, don't run mutate ones.
They will fail because the GIL is disabled on the unix build.
2016-07-09 16:52:57 +01:00
Paul Sokolovsky 92a9078a6f tests/meminfo: Update for addition of "max free sz" output. 2016-07-01 00:39:26 +03:00
Damien George 8b9ddf4031 tests/thread: Allow some tests to run on ports with not much heap. 2016-06-28 11:28:52 +01:00
Damien George 63d05228a3 tests/thread: Allow thread_sleep1 to run without floating point. 2016-06-28 11:28:52 +01:00
Damien George 15e68277c1 tests/thread: Make sure that thread tests don't rely on floating point. 2016-06-28 11:28:52 +01:00
Damien George 5b7789d519 tests/thread: Make stack-size test run correctly and reliable on uPy. 2016-06-28 11:28:52 +01:00
Damien George b7274e91bc tests/thread: Add test for concurrent mutating of user instance. 2016-06-28 11:28:50 +01:00
Damien George 2e4cdae4fd tests/thread: Add test for concurrent interning of strings.
Qstr code accesses global state and needs to be made thread safe.
2016-06-28 11:28:50 +01:00
Damien George 094a0dd11a tests/thread: Add tests that mutate shared objects.
Tests concurrent mutating access to: list, dict, set, bytearray.
2016-06-28 11:28:50 +01:00
Damien George c73cf9d931 tests/thread: Rename thread_stress_XXX.py to stress_XXX.py. 2016-06-28 11:28:50 +01:00
Damien George dcc7c5bd89 tests/thread: Add tests for running GC within a thread, and heap stress. 2016-06-28 11:28:49 +01:00
Damien George 3545ef8bb4 tests/thread: Remove need to sleep to wait for completion in some tests.
Use a lock and a counter instead, and busy wait for all threads to
complete.  This makes test run faster and they no longer rely on the time
module.
2016-06-28 11:09:31 +01:00
Damien George 2d5ea38b49 tests: Add 3 more tests for _thread module. 2016-06-28 11:09:31 +01:00
Damien George ed36632c6c tests: Add tests for _thread module.
Includes functionality and stress tests.
2016-06-28 11:09:31 +01:00
Paul Sokolovsky 0fb7a7a7ce tests/btree1: Add testcase for iterating btree object directly. 2016-06-24 23:43:20 +03:00
Paul Sokolovsky d5835261af tests/extmod: Add "btree" module test. 2016-06-21 10:00:02 +03:00
Paul Sokolovsky 119b3dabf7 tests: Add a testcase for machine.PinBase class. 2016-06-19 19:45:29 +03:00
Mark Anthony Palomer deaf0712aa tests: Add testcase for OrderedDict equality.
There's a need for .exp file because CPython renders OrderedDict's as:

OrderedDict([('b', 2)])

while MicroPython as:

OrderedDict({'b': 2})
2016-06-12 17:37:19 +03:00
Paul Sokolovsky e918fc5e37 tests/bench: Add testcase to compare bytes(N) vs b"\0" * N.
Based on python-dev discussion regarding PEP467.
2016-06-08 14:28:18 +03:00
Damien George b1533c4366 py/parse: Treat constants that start with underscore as private.
Assignments of the form "_id = const(value)" are treated as private
(following a similar CPython convention) and code is no longer emitted
for the assignment to a global variable.

See issue #2111.
2016-06-06 17:28:32 +01:00
Paul Sokolovsky a1a261d8e8 tests/recursive_iternext: Clang/Linux is even more stack-frugal than MacOS. 2016-06-04 21:10:43 +03:00
Damien George 97ce5d1d77 tests/pyb/rtc: Make RTC test on pyboard more reliable by calling init(). 2016-06-03 15:13:39 +01:00
Damien George 7d60a97914 tests/misc/recursive_iternext: Provide more fine-grained selection of N.
To work on a variety of ports the selection of N is very specific.
2016-06-03 15:09:45 +01:00
Damien George ddadbaed06 tests/misc/recursive_iternext.py: Increase depth N from 1000 to 2000.
This makes the test reliably overflow the recursion limit (which is the
correct behaviour) on Mac OS X.
2016-06-03 09:33:57 +01:00
Paul Sokolovsky f0eea1fdf9 tests/extmod/vfs_fat_ramdisk: Add testcases for chdir(), getcwd(). 2016-05-29 18:54:14 +03:00
Damien George 715ee9d925 py/modstruct: Allow to have "0s" in struct format. 2016-05-28 23:27:38 +01:00
Antonin ENFRUN ca41dc2750 py/objnamedtuple: Allow passing field names as a tuple.
So the documentation's example works.  Besides, a tuple can be more
memory efficient.
2016-05-23 21:08:07 +01:00
Paul Sokolovsky 53bac8e869 tests: Add testcase for str.center(). 2016-05-22 00:18:53 +03:00
Paul Sokolovsky 719f8c044a tests/struct1: Add testcase for an unknown type char. 2016-05-14 15:54:09 +03:00
Damien George 1e2f829293 tests/basics/string_splitlines: Reinstate feature test for splitlines. 2016-05-13 13:11:22 +01:00
Damien George cc80c4dd59 py/objstr: Make dedicated splitlines function, supporting diff newlines.
It now supports \n, \r and \r\n as newline separators.

Adds 56 bytes to stmhal and 80 bytes to unix x86-64.

Fixes issue #1689.
2016-05-13 12:21:32 +01:00
Damien George 5ab98d5c41 stmhal: Convert to use internal errno symbols; enable uerrno module. 2016-05-10 23:30:39 +01:00
Damien George 65402ab1ec py/mpz: Do Python style division/modulo within bignum divmod routine.
This patch consolidates the Python logic for division/modulo to one place
within the bignum code.
2016-05-08 22:21:21 +01:00
Damien George dc3faea040 py/mpz: Fix bug with overflowing C-shift in division routine.
When DIG_SIZE=32, a uint32_t is used to store limbs, and no normalisation
is needed because the MSB is already set, then there will be left and
right shifts (in C) by 32 of a 32-bit variable, leading to undefined
behaviour.  This patch fixes this bug.
2016-05-08 21:38:43 +01:00
Henrik Sölver c4587e2426 stmhal/can: Allow to get existing CAN obj if constructed without args.
Initialisation of CAN objects should now behave as other peripheral
objects.

Fixes issue #2001.
2016-05-08 12:47:33 +01:00
Damien George 9e47c145c7 tests: Disable memoryview tests that overflow int conversion.
They fail on builds with 32-bit word size.
2016-05-07 22:36:49 +01:00
Damien George 470c429ee1 py/runtime: Properly handle passing user mappings to ** keyword args. 2016-05-07 22:02:46 +01:00
Damien George 12dd8df375 py/objstr: Binary type of str/bytes for buffer protocol is 'B'.
The type is an unsigned 8-bit value, since bytes objects are exactly
that.  And it's also sensible for unicode strings to return unsigned
values when accessed in a byte-wise manner (CPython does not allow this).
2016-05-07 21:18:17 +01:00
Paul Sokolovsky 5ec11f565b tests/run-tests: Factor out list supported external boards.
To get consistent error messages, etc.
2016-05-07 18:45:16 +03:00
Paul Sokolovsky 566d8f1d7e tests: Make "io" modules fixes for CPython compatibility.
Previously, "import _io" worked on both CPython and MicroPython (essentially
by a chance on CPython, as there's not guarantee that its contents will stay
the same across versions), but as the module was renamed to uio, need to use
more robust import sequence for compatibility.
2016-05-02 14:38:07 +03:00
Paul Sokolovsky 8c35f3979c tests: Update for _io/_collections module having been renamed. 2016-05-02 14:15:11 +03:00
Paul Sokolovsky df06e34175 tests/run-bench-tests: Process tests in alphabetical order. 2016-05-01 10:35:24 +03:00
Paul Sokolovsky 3c2e40b008 tests/run-tests: Add gen_yield_from_stopped to skipped for --emit=native.
Just as the rest of generator tests, which aren't yet supoorted for
native.
2016-04-28 10:24:27 +03:00
Paul Sokolovsky 0ea2108f1c tests: Add testcase for yielding from a stopped generator. 2016-04-28 02:08:51 +03:00
Damien George 07615d9f7e tests/extmod: Move split-on-empty-match tests to a separate test file.
And provide an expected-output file because these tests have a different
behaviour under CPython.
2016-04-26 10:19:04 +01:00
Damien George fea40ad468 py: Fix bug passing a string as a keyword arg in a dict.
Addresses issue #1998.
2016-04-21 16:51:36 +01:00
Damien George 2c883c5ab7 tests: Fix dict1.py so it doesn't rely on the order of dict elems. 2016-04-15 16:28:33 +01:00
Damien George c2a519bab9 tests: Skip async tests for native emitter. 2016-04-13 15:56:42 +01:00
Damien George 7f7e247545 tests: Add .exp files for async tests, so they can run with Python 3.4. 2016-04-13 15:56:15 +01:00
Damien George c33df193bf tests: Add 6 tests for async await/for/with. 2016-04-13 15:27:06 +01:00
Damien George 04d5e644fc py/objarray: Fix array.append so it doesn't extend if append fails.
Addresses issue #1965.
2016-04-07 09:03:33 +01:00
Damien George 2c915e1ae6 py: Implement basic with support in native emitter. 2016-04-07 08:53:24 +01:00
Damien George e1e7657277 py/formatfloat: Fix further cases of buffer overflow in formatting.
Includes extensive test cases to catch hopefully all cases where
buffer might overflow.
2016-03-29 22:07:15 +01:00
Paul Sokolovsky 88f60de914 tests: Add test for io.BufferedWriter. 2016-03-25 15:01:19 +02:00
Damien George da161fd9f0 extmod/uctypes: Finish support for FLOAT32 and FLOAT64 types. 2016-03-19 21:59:42 +00:00
Damien George 99146ea444 tests/io: Remove "testfile" at end of open_plus test. 2016-03-17 20:09:33 +00:00
Damien George 664f03f466 tests: Add a test for argument passing to inline-asm functions. 2016-03-16 08:24:07 +00:00
Damien George 157056ecdf tests: Add new subdir "stress/" specifically for stress tests. 2016-03-15 13:20:18 +00:00
Damien George ab69ed7dac tests: Split large tests into smaller files, to run with a small heap.
All tests in basics/ directory can now run and pass using 64-bit unix
port with only a 16k heap (./run-tests --heapsize 16k).  Tests in this
directory should remain small so they can be used for ports with a
small heap.
2016-03-15 13:07:41 +00:00
Damien George 9996adc37d tests/run-tests: Add cmd line option "--heapsize".
This allows you to specify the heapsize that unix will use when running
the test suite, eg: ./run-tests --heapsize 16k
2016-03-15 13:04:43 +00:00
Damien George cea6cf8a5e py/formatfloat: Fix buffer overflow when formatting tiny numbers. 2016-03-15 12:21:56 +00:00
Damien George 77f85db41e py/objarray: Fix array slice assignment when array is reallocated.
Addresses issue #1898.
2016-03-14 23:12:54 +00:00
Damien George f0e2d13fd2 tests/run-tests: Simplify handling of newline in output from tests.
Now, all output has newlines converted to \n, regardless of port or
platform.
2016-03-08 10:20:38 +00:00
Damien George d964873e56 tests/run-tests: Fix logic when selecting test-dirs for a given target. 2016-03-07 12:00:16 +00:00
Paul Sokolovsky b86c20676e tests/recursive_iternext.py: Make low-heap friendly. 2016-03-07 15:30:02 +07:00
Paul Sokolovsky 419bb26ddc tests/print_exception: Use exception which prints the same regardless of config.
NameError may either include offending name or not. Unfortunately, this
change makes test float-dependent. And using integer division leads to
different error message than CPython.
2016-03-07 14:10:06 +07:00
Paul Sokolovsky d973c1bc12 test/string_format_fp30: Variant of string_format for 30-bit stuffed float. 2016-03-06 06:10:40 +02:00
Paul Sokolovsky 50e0a7b9d4 test/float2int_fp30: Variant of float2int for 30-bit stuffed float. 2016-03-06 06:08:38 +02:00
Damien George fbb3c190f9 tests: Remove commented out tests so test script is not too big. 2016-03-06 06:00:28 +02:00
Damien George 14848ffa12 tests: Reduce large object allocations so tests can run with small heap. 2016-03-06 05:59:46 +02:00
Paul Sokolovsky 2382d30318 tests/run-tests: Skips for esp8266. 2016-03-03 15:38:43 +02:00
Paul Sokolovsky 2740dd85f2 tests/vfs_fat_ramdisk: Add testcase for .rename(). 2016-02-29 01:24:18 +02:00
Paul Sokolovsky 9fb36af9af tests/vfs_fat_ramdisk: Allow to run in native mode (don't use "with"). 2016-02-29 01:03:32 +02:00
Paul Sokolovsky eaa96a7610 tests/vfs_fat_ramdisk: Add testcase for .mkdir(). 2016-02-29 00:06:44 +02:00
Paul Sokolovsky 57425b648f tests/vfs_fat_ramdisk: Add testcase for .remove(). 2016-02-28 20:30:59 +02:00
Paul Sokolovsky 9c081b740b tests/vfs_fat_ramdisk: Add .listdir() testcase. 2016-02-28 17:19:12 +02:00
danicampora add930c4b5 cc3200: Rename 'server' class to 'Server' for consistency. 2016-02-22 22:54:34 +01:00
danicampora cc7a4d7db2 tests/wipy: Correct machine test expected result. 2016-02-22 00:42:05 +01:00
danicampora 5148860332 tests: Skip uctypes and urandom tests not supported byt the WiPy. 2016-02-21 22:30:35 +01:00
danicampora fe9620a2bd test/wipy: Add Timer class tests. 2016-02-21 21:53:20 +01:00
Alex March 69d9e7d27d py/repl: Check for an identifier char after the keyword.
- As described in the #1850.
- Add cmdline tests.
2016-02-17 08:56:15 +00:00
Paul Sokolovsky dfc35afba1 tests/vfs_fat_ramdisk: Skip test if can't allocate ramdisk. 2016-02-15 17:27:57 +02:00
Paul Sokolovsky 9fdac9144d tests/vfs_fat_ramdisk: Allow to override sector size. 2016-02-14 20:52:38 +02:00
Paul Sokolovsky 9d0525182d tests/vfs_fat_ramdisk: Switch to ioctl-based blockdev API. 2016-02-14 20:45:08 +02:00
Paul Sokolovsky 0ee1d0f407 tests/vfs_fat_ramdisk: Add test for VfsFat. 2016-02-14 19:15:22 +02:00
Paul Sokolovsky e5cff5b223 tests/bytearray1: Add testcases for "in" operator. 2016-02-14 18:57:18 +02:00
Paul Sokolovsky d4315a6caf float/string_format: Split large test in 2. 2016-02-13 17:18:55 +02:00
Paul Sokolovsky 2850e7cd97 tests/run-tests: Add esp8266 target. 2016-02-13 17:03:12 +02:00
Paul Sokolovsky dc587a3623 test/float2int: Make test output clearer. 2016-02-13 17:03:02 +02:00
Damien George f7e5e677df tests/pyb: Add simple test for stm module on pyboard. 2016-02-10 17:06:07 +00:00
Damien George 3e02b1d19a py/viper: Allow casting of Python integers to viper pointers.
This allows you to pass a number (being an address) to a viper function
that expects a pointer, and also allows casting of integers to pointers
within viper functions.

This was actually the original behaviour, but it regressed due to native
type identifiers being promoted to 4 bits in width.
2016-02-09 13:29:20 +00:00
Paul Sokolovsky 5bf6eba845 tests/open_plus: Add tests for "r+", "w+" open modes. 2016-02-06 21:59:54 +02:00
Doug Currie 2e2e15cec2 py/mpz: Complete implementation of mpz_{and,or,xor} for negative args.
For these 3 bitwise operations there are now fast functions for
positive-only arguments, and general functions for arbitrary sign
arguments (the fast functions are the existing implementation).

By default the fast functions are not used (to save space) and instead
the general functions are used for all operations.

Enable MICROPY_OPT_MPZ_BITWISE to use the fast functions for positive
arguments.
2016-02-03 22:13:39 +00:00
pohmelie e3a29de1dc py/objstr: For str.format, add nested/computed fields support.
Eg: '{:{}}'.format(123, '>20')

@pohmelie was the original author of this patch, but @dpgeorge made
significant changes to reduce code size and improve efficiency.
2016-02-02 16:25:24 +00:00
Damien George 93bb7dffd2 py/vm: Fix popping of exception block in UNWIND_JUMP opcode.
Fixes issue #1812.
2016-02-01 16:07:21 +00:00
Damien George 9e677114e4 py/mpprint: Fix sign extension when printf'ing %u, %x and %X. 2016-02-01 15:08:42 +00:00
Damien George ef5f2669dc tests: For pyboard, add test for I2C error handling and recovery. 2016-01-30 00:06:04 +00:00
Damien George 3cfb15cf4d tests: Update pyboard LED test. 2016-01-29 23:12:59 +00:00
Damien George 8f54c08691 py/inlineasm: Add ability to specify return type of asm_thumb funcs.
Supported return types are: object, bool, int, uint.

For example:

@micropython.asm_thumb
def foo(r0, r1) -> uint:
    add(r0, r0, r1)
2016-01-27 14:27:10 +00:00
Damien George ac11e89fa3 tests: For urandom test, use sys.exit() instead of sys.exit(1). 2016-01-26 21:57:02 +00:00
Damien George 0ae97f531d tests: Add some tests for urandom module. 2016-01-26 15:27:00 +00:00
Dave Hylands a17755ee8b py: Add ustruct.pack_into and unpack_from 2016-01-19 12:25:28 +00:00
chrysn f8ba2eca80 builtin property: accept keyword arguments
this allows python code to use property(lambda:..., doc=...) idiom.

named versions for the fget, fset and fdel arguments are left out in the
interest of saving space; they are rarely used and easy to enable when
actually needed.

a test case is included.
2016-01-14 21:15:18 +02:00
stijn dea585f8ae tests: Remove builtin_dict test
This is essentially a duplicate of obj_dict.py
2016-01-14 21:10:59 +02:00
Dave Hylands 66d0c1052a extmod: Fix uctypes size calculation for bitfields 2016-01-10 23:31:26 +02:00
Damien George 3b936a5f4c tests: Fix math_fun_special test so it passes with single prec float. 2016-01-08 17:58:02 +00:00
Damien George b1fa907d56 tests: Allow float tests to run when MATH_SPECIAL_FUNCTIONS is disabled. 2016-01-08 14:27:21 +00:00
Damien George ea8be373a9 py/inlinethumb: Remove 30-bit restriction on movwt instruction.
movwt can now move a full 32-bit constant into a register.
2016-01-07 16:34:11 +00:00
Damien George 22b2265053 py/parse: Improve constant folding to operate on small and big ints.
Constant folding in the parser can now operate on big ints, whatever
their representation.  This is now possible because the parser can create
parse nodes holding arbitrary objects.  For the case of small ints the
folding is still efficient in RAM because the folded small int is stored
inplace in the parse node.

Adds 48 bytes to code size on Thumb2 architecture.  Helps reduce heap
usage because more constants can be computed at compile time, leading to
a smaller parse tree, and most importantly means that the constants don't
have to be computed at runtime (perhaps more than once).  Parser will now
be a little slower when folding due to calls to runtime to do the
arithmetic.
2016-01-07 14:40:35 +00:00
Damien George d4df8f4925 py/objstr: In str.format, handle case of no format spec for string arg.
Handles, eg, "{:>20}".format("foo"), where there is no explicit spec for
the type of the argument.
2016-01-04 13:13:39 +00:00
Paul Sokolovsky ee7b8f32e3 tests/object_dict.py: Add test for obj.__dict__ . 2016-01-03 20:51:36 +02:00
stijn 3c014a67ea py: Implement __dict__ for instances.
Note that even though wrapped in MICROPY_CPYTHON_COMPAT, it is not
fully compatible because the modifications to the dictionary do not
propagate to the actual instance members.
2016-01-03 20:51:26 +02:00
Dave Hylands 7281d95aee py: Make dir report instance members 2016-01-03 20:37:18 +02:00
Antonin ENFRUN b50030b1d0 tests/uctypes: Test item assignment for scalar arrays. 2016-01-03 20:32:51 +02:00
Damien George e5ce5e2a43 tests: Skip class_bind_self.py for native emitter. 2015-12-26 13:06:50 +00:00
Damien George 78913211a9 py: Be more restrictive binding self when looking up instance attrs.
When looking up and extracting an attribute of an instance, some
attributes must bind self as the first argument to make a working method
call.  Previously to this patch, any attribute that was callable had self
bound as the first argument.  But Python specs require the check to be
more restrictive, and only functions, closures and generators should have
self bound as the first argument

Addresses issue #1675.
2015-12-26 12:41:31 +00:00
Damien George 7ce8860b6b tests: Skip try-finally test for native emitter. 2015-12-24 12:49:31 +00:00
Damien George 8047340d75 py: Handle case of return within the finally block of try-finally.
Addresses issue #1636.
2015-12-24 12:47:39 +00:00
Damien George 117158fcd5 tests: Add tests for stream IO errors. 2015-12-23 22:37:02 +00:00
Paul Sokolovsky 664bc44f30 tests: Add tests for %-formatting of bytes.
This requires CPython3.5, to not require switching to it, just use .exp
file.
2015-12-20 16:54:34 +02:00
Michael Buesch 17298af61e py/modmath: Add domain error checking to sqrt, log, log2, log10.
These functions will raise 'ValueError: math domain error' on invalid
input.
2015-12-12 15:12:54 +00:00
Damien George 29e9db0c58 py: Fix compiler to handle lambdas used as default arguments.
Addresses issue #1709.
2015-12-12 13:42:51 +00:00
Paul Sokolovsky a6eff059b9 unix: Rename "_os" module to "uos" for consistency with baremetal ports. 2015-12-12 00:04:35 +02:00
Damien George de2a2e296b tests: Add test for "not" of a user defined class. 2015-12-10 22:21:57 +00:00
Henrik Sölver e242b1785f py/emitinlinethumb: Add support for MRS instruction.
Only IPSR and BASEPRI special registers supported at the moment, but easy
to extend in the future.
2015-12-10 17:32:54 +00:00
Dave Hylands 5a4a2b1db3 extmod: Add test which demonstrates LITTLE_ENDIAN packing failure 2015-12-09 21:43:28 +02:00
Damien George 3ff259a262 py: Fix calling of parent classmethod from instance of subclass.
Addresses issue #1697.
2015-12-09 17:30:01 +00:00
Damien George 0891cf7d2d tests: Disable for_range.py test for native emitter (it requires yield). 2015-12-08 21:39:21 +00:00
Damien George 33ac0fd09f py: Don't try to optimise for+range when args are not simple expressions.
Addresses issue #1693.
2015-12-08 21:05:14 +00:00
Paul Sokolovsky 55995869e5 tests/builtin_minmax: Make compatible with @native codegen. 2015-12-07 19:32:48 +02:00
Paul Sokolovsky 36c6d2fa7d tests/builtin_minmax: Add testcase for lazy iterable (generator). 2015-12-07 18:59:18 +02:00
pohmelie e23d5a64cf tests: Add min/max "default" agrument test 2015-12-07 18:56:25 +02:00
Paul Sokolovsky cbc489dff5 tests: Actuall add feature check for complex type being available. 2015-12-06 15:13:26 +02:00
Paul Sokolovsky eed2f36ae2 tests/run-tests: Allow to skip complex tests if it's not compiled in. 2015-12-06 14:57:31 +02:00
Paul Sokolovsky 54a1d9ecb7 tests/extra_coverage: Update for sys.modules addition. 2015-12-05 00:13:29 +02:00
Damien George 7a99639cff py: Fix function calls that have positional and a star-arg-with-iterator.
Addresses issue #1678.
2015-12-03 17:59:49 +00:00
Damien George 0d9b450701 stmhal: Make uart.write() function correctly for timeout=0.
In non-blocking mode (timeout=0), uart.write() can now transmit all of its
data without raising an exception.  uart.read() also works correctly in
this mode.

As part of this patch, timout_char now has a minimum value which is long
enough to transfer 1 character.

Addresses issue #1533.
2015-11-30 17:29:52 +00:00
Ryan Shaw f99491cbf7 stmhal: uart.any() function now returns number of bytes available. 2015-11-30 13:07:20 +00:00
Paul Sokolovsky ff8c4188f4 tests/run-tests: Improve robustness of REPL tests.
Unconditionally wait for MicroPython banner. On overloaded systems, when
using emulators, etc. initial executable startup may take more than 20ms.
2015-11-24 19:52:30 +02:00
Damien George 9a56912ad1 py/compile: Do proper checking of * and ** in function definition.
This patch checks that there is only one *, and that ** is last in the
arg list.
2015-11-23 16:50:42 +00:00
Damien George 0e3f29cc99 py: Check that second argument to hasattr is actually a string.
Fixes issue #1623.
2015-11-23 15:57:00 +00:00
Paul Sokolovsky 4120f32292 tests/int_big_*: Add more tests for result normalization.
Tested by comparability to small int/casting to bool.
2015-11-22 22:11:01 +02:00
Paul Sokolovsky b56c635d64 tests/int_big_xor: Test that xor result is normalized.
And thus can be successfully used in comparisons, etc.
2015-11-22 22:02:15 +02:00
Paul Sokolovsky b64e0575fd tests/float/string_format: Add testcase for incorrect rounding for %f. 2015-11-22 18:08:49 +02:00
Damien George 2c83894257 py: Implement default and star args for lambdas. 2015-11-17 14:00:14 +00:00
danicampora e4404fbef0 cc3200: Unmount all user file systems after a soft reset. 2015-11-16 23:43:47 +01:00
Paul Sokolovsky 772f0b4159 tests/jni: Add test for working with container of List interface. 2015-11-13 01:33:09 +02:00
Henrik Sölver 35e7d9c0f1 stmhal/can: Fix a bug in filter handling.
Reported here: http://forum.micropython.org/viewtopic.php?f=2&t=845
2015-11-02 23:09:49 +00:00
Paul Sokolovsky aee704ebe1 extmod/modure: Make sure that errors in regexps are caught early. 2015-11-01 00:38:22 +03:00
Paul Sokolovsky 0bd3f3291d tests/base/struct1.py: Add test for repetition counters. 2015-10-31 18:55:31 +03:00
stijn 24b03561bd tests: Make sure test output has \r\n line-ends when running on Windows
This is the case already when using just subprocess.check_output, but in
the special cases (cmdline, meminfo, ...) the carriage return gets lost
during output processing so restore it in the end.
This fixes the micropython/meminfo.py test on Windows.
2015-10-31 14:11:19 +03:00
adminpete d6201fc4b7 py: In inline asm, vldr and vstr offsets now in bytes not words.
As per ARM convention.
2015-10-31 10:50:45 +00:00
danicampora 1950295735 cc3200: Set pin direction first, then value. Fixes #1542. 2015-10-26 23:26:43 +01:00
Paul Sokolovsky 9a334d41e3 tests/jni: Test for basic object operations. 2015-10-24 01:20:34 +03:00
danicampora 075ca64521 cc3200: Fix UART tests after correcting uart.read() behaviour. 2015-10-21 15:30:57 +02:00
danicampora 1f2daf4304 cc3200: Correct ticks_cpu and ticks_us functions in time module. 2015-10-21 15:30:57 +02:00
Damien George e693e52442 tests: Disable some tests for pyboard that do not run correctly. 2015-10-20 23:55:50 +01:00
Paul Sokolovsky acea9352a9 tests/extmod: Add tests for sleep_ms/us(), ticks_ms/us/diff().
Simple smoke tests, mostly for coverage. Added to extmod based on the fact
that they're extensions to standard modules.
2015-10-20 01:54:20 +03:00
danicampora 9c72c71c05 cc3200: WLAN class can retrieve the existing instance. 2015-10-19 21:17:15 +02:00
danicampora f4c50f1cfc tests/wipy: Make WLAN test more stable. 2015-10-19 21:17:15 +02:00
danicampora ae70e98ed4 cc3200: Fix time.ticks_* functions. 2015-10-19 21:17:15 +02:00
danicampora 36ae417c9f docs: Add wipy and network.server documentation. 2015-10-19 21:17:15 +02:00
danicampora 2e0cd20a1d cc3200: Refactor network module to make the server a propper object. 2015-10-19 21:17:15 +02:00
danicampora d8137178bb cc3200: Create wipy module, remove HeartBeat class.
The heartbeat is now controllable via a single function within the
wipy module.
2015-10-19 21:17:15 +02:00
Damien George 096d1e4512 py: Add lsl/lsr/asr opcode support to inline Thumb2 assembler. 2015-10-19 14:26:19 +01:00
danicampora e19dfe1c32 cc3200: In scan results rename 'auth' field to 'sec'.
As defined by the new API, since 'auth' is actually a  tuple
composed by the security type and the key.
2015-10-17 23:21:44 +02:00
Damien George 4bf3f2d3c0 py: Fix with+for+return bug by popping for-iter when unwinding exc stack.
Addresses issue #1182.
2015-10-15 17:48:28 +01:00
Damien George 4300c7dba2 py: Remove dependency on printf/fwrite in mp_plat_print.
See issue #1500.
2015-10-15 00:05:55 +01:00
Paul Sokolovsky 2430dfac31 tests/jni: Start adding modjni tests.
These are currently not intended to run with the rest of testsuite, as
they require dependencies and special environment setup anyway (drafted
in tests/jni/README).
2015-10-14 00:56:01 +03:00
Damien George 2ec835f572 tests: Add more tests for viper 16/32-bit load/store, and ellipsis. 2015-10-13 18:24:36 +01:00
Damien George b8f9ac5411 py: Implement ptr32 load and store in viper emitter. 2015-10-13 00:50:17 +01:00
Damien George 3aa7dd23c9 unix: Add exit and paste-mode hints to shell startup banner.
Thanks to @nyov for the initial patch.
2015-10-12 00:19:00 +01:00
Damien George 0334058fa4 Rename "Micro Python" to "MicroPython" in REPL, help, readme's and misc. 2015-10-12 00:06:25 +01:00
Peter Hinch 0e87bc7be6 tests: In pyb RTC tests, check wakeup register values. 2015-10-09 23:06:05 +01:00
Damien George 4fb5ff86ee tests: Add test for evaluation order of dictionary key/value pairs.
In Python 3.4 the value is evaluated before the key.  In Python 3.5 it's
key then value.
2015-10-08 13:15:07 +01:00
Damien George 9f5f156b9d py/emitnative: Raise ViperTypeError for unsupported unary ops. 2015-10-08 13:08:59 +01:00
Damien George 7e12a601b8 py/compile: Fix edge case when constant-folding negation of integer.
Also adds tests specifically for testing constant folding.
2015-10-08 13:02:00 +01:00
Paul Sokolovsky 062bd81814 tests/basics/builtin_range: PEP8 fixes. 2015-10-05 20:02:52 +03:00
Damien George 34f26ea862 tests: Allow tests to pass against CPython 3.5.
All breaking changes going from 3.4 to 3.5 are contained in
basics/python34.py.
2015-10-02 13:01:47 +01:00
Damien George e5635f4ab3 py: Catch all cases of integer (big and small) division by zero. 2015-10-01 22:48:48 +01:00
Damien George 2065373f67 py/mpz: Fix bignum anding of large negative with smaller positive int. 2015-10-01 22:35:06 +01:00
Damien George a81539db25 tests: Add further tests for mpz code. 2015-10-01 18:49:37 +01:00
Damien George 4c02e54298 py/mpz: Raise NotImplError instead of failing assertion. 2015-10-01 17:57:36 +01:00
Tom Soulanille 2a8a564fbd tests: Test slicing a range that does not start at zero. 2015-09-28 14:01:20 +00:00
Daniel Campora d88d3b0b3a tests/wipy: Skip the rtc_irq test. 2015-09-27 21:36:38 +02:00
Daniel Campora d5de1bf853 tests: Skip uheapq1 test if target is WiPy. 2015-09-27 18:47:35 +02:00
Daniel Campora 6143f63560 tests/wipy: Fix error in wlan test. 2015-09-27 18:00:36 +02:00
Daniel Campora 37a2015cc5 tests/wipy: Add machine module tests. 2015-09-27 17:35:58 +02:00
Daniel Campora 958e273336 tests: Skip extmod machine tests when target is WiPy. 2015-09-27 17:35:45 +02:00
Daniel Campora c92e6a45eb cc3200: Rename pyb module to machine. 2015-09-27 16:50:27 +02:00
Daniel Campora 0a7e4fa5ce tests/wipy: Improve robustness of rtc_irq test. 2015-09-27 14:20:38 +02:00
Daniel Campora 8192310dad tests/wipy: Improve robustness of time test. 2015-09-27 12:32:02 +02:00