Damien George
04c55f5828
tests: Rewrite some tests so they can run without needing eval/exec.
...
For builds without the compiler enabled (and hence without eval/exec) it is
useful to still be able to run as many tests as possible.
2018-02-14 16:50:20 +11:00
Damien George
6031957473
tests: Automatically skip tests that require eval, exec or frozenset.
2018-02-14 16:46:44 +11:00
Damien George
1f53ff61ff
tests/basics: Rename remaining tests that are for built-in functions.
...
For consistency with all of the other tests that are named builtin_XXX.py.
2018-02-07 15:55:52 +11:00
Damien George
b45c8c17f0
py/objtype: Check and prevent delete/store on a fixed locals map.
...
Note that the check for elem!=NULL is removed for the
MP_MAP_LOOKUP_ADD_IF_NOT_FOUND case because mp_map_lookup will always
return non-NULL for such a case.
2018-02-07 15:44:29 +11:00
Damien George
a1d85d6199
tests/basics/memoryerror: Add test for out-of-memory using realloc.
2017-12-20 16:58:27 +11:00
Damien George
35a759dc1d
tests: Add some more tests to improve coverage of py/parse.c.
2017-12-19 16:13:00 +11:00
Damien George
2bfa531798
tests/basics/builtin_pow3: Add tests for edge cases of pow3.
2017-12-19 15:44:10 +11:00
Damien George
8e6113a188
tests/basics/generator_pend_throw: Add test for just-started generator.
2017-12-19 15:02:34 +11:00
Damien George
7208cad97a
tests/basics: Add more set tests to improve coverage of py/objset.c.
2017-12-19 13:59:54 +11:00
Paul Sokolovsky
6364401666
py/objgenerator: Allow to pend an exception for next execution.
...
This implements .pend_throw(exc) method, which sets up an exception to be
triggered on the next call to generator's .__next__() or .send() method.
This is unlike .throw(), which immediately starts to execute the generator
to process the exception. This effectively adds Future-like capabilities
to generator protocol (exception will be raised in the future).
The need for such a method arised to implement uasyncio wait_for() function
efficiently (its behavior is clearly "Future" like, and normally would
require to introduce an expensive Future wrapper around all native
couroutines, like upstream asyncio does).
py/objgenerator: pend_throw: Return previous pended value.
This effectively allows to store an additional value (not necessary an
exception) in a coroutine while it's not being executed. uasyncio has
exactly this usecase: to mark a coro waiting in I/O queue (and thus
not executed in the normal scheduling queue), for the purpose of
implementing wait_for() function (cancellation of such waiting coro
by a timeout).
2017-12-15 20:20:36 +02:00
Damien George
36f79523ab
tests: Add tests to improve coverage of py/objtype.c.
2017-12-14 12:25:30 +11:00
Paul Sokolovsky
da34b6ef45
tests: Fix few test for proper "skipped" detection with qemu-arm's tinytest.
...
"Builtin" tinytest-based testsuite as employed by qemu-arm (and now
generalized by me to be reusable for other targets) performs simplified
detection of skipped tests, it treats as such tests which raised SystemExit
(instead of checking got "SKIP" output). Consequently, each "SKIP" must
be accompanied by SystemExit (and conversely, SystemExit should not be
used if test is not skipped, which so far seems to be true).
2017-12-12 23:45:48 +02:00
Damien George
fd0b0db873
tests/basics: Add test for overriding a native base-class's init method.
2017-12-12 16:47:38 +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
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
stijn
79ed58f87b
py/objnamedtuple: Add _asdict function if OrderedDict is supported
2017-11-12 14:16:54 +02: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
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
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
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
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
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
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
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
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
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
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
Krzysztof Blazewicz
7feb7301b2
tests/basics: Add tests for arithmetic operators precedence.
2017-07-05 15:51:03 +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
44922934f5
tests/basics: Add tests for for-else statement.
2017-06-22 14:02:14 +10: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
Paul Sokolovsky
a2803b74f4
tests/basics: Convert "sys.exit()" to "raise SystemExit".
2017-06-10 20:03:01 +03: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
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
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
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
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
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
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
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
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
Paul Sokolovsky
c9705cff68
tests/basics/fun_error: Split out skippable test.
2017-03-10 02:22:56 +01:00
Paul Sokolovsky
ce63a95a85
tests/dict_fromkeys: Split out skippable part.
2017-03-09 08:31:35 +01:00
Paul Sokolovsky
983144404b
tests/basic: Make various tests skippable.
2017-03-09 00:07:19 +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
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
Damien George
3d91c12d33
tests/basics: Add further tests for OrderedDict.
2017-03-03 11:23:54 +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
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
Damien George
d87c6b6768
tests/basics/string_join: Add more tests for string concatenation.
2017-02-17 12:30:27 +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
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
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
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
05c70fdfba
tests/basics/set_binop: Add tests for inplace set operations.
2017-02-02 23:36:53 +11:00
Paul Sokolovsky
33b8e65bc0
tests/basics/zip: Make skippable.
2017-01-31 00:33:01 +03: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
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
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
5314219f18
tests/basics: Improve runtime.c test coverage.
2017-01-17 16:21:17 +11:00
Damien George
96baaa68a4
tests: Update tests, and add new ones, for recent generator tweaks.
2017-01-17 00:17:44 +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
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
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
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
Damien George
adccafb42a
tests/basics/lexer: Add a test for newline-escaping within a string.
2016-12-22 10:32:06 +11: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
Rami Ali
5d06a74303
tests/basics: Improve test coverage for generators.
2016-12-20 16:19:56 +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
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
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
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
Damien George
30bca45e1a
tests/basics: Add test for logical constant folding.
2016-11-15 16:48:49 +11:00
Fabio Utzig
8908e505ce
py/sequence: Fix reverse slicing of lists.
2016-10-30 15:54:19 -02:00
Alex March
964fb2450e
tests/basics/gc1: Garbage collector threshold() coverage.
2016-10-27 22:15:42 +03: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
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
5e22afce41
tests: Improve test coverage of py/compile.c.
2016-10-11 12:30:32 +11:00
Damien George
82af4d6749
tests: Improve coverage of struct with test for non-compliant behaviour.
2016-10-07 12:57:25 +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
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
3f0c1c2452
tests/basics: Add test case for overflowing Py stack in try-finally.
2016-09-27 12:46:50 +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
2b7c4a1878
tests/basics: Add errno1 test, to check basics of uerrno module.
2016-09-16 15:33:51 +10: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
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
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
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
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
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
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
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
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
8c35f3979c
tests: Update for _io/_collections module having been renamed.
2016-05-02 14:15:11 +03:00
Paul Sokolovsky
0ea2108f1c
tests: Add testcase for yielding from a stopped generator.
2016-04-28 02:08:51 +03: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
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
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
77f85db41e
py/objarray: Fix array slice assignment when array is reallocated.
...
Addresses issue #1898 .
2016-03-14 23:12:54 +00: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
e5cff5b223
tests/bytearray1: Add testcases for "in" operator.
2016-02-14 18:57:18 +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
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
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
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
8047340d75
py: Handle case of return within the finally block of try-finally.
...
Addresses issue #1636 .
2015-12-24 12:47:39 +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
Damien George
29e9db0c58
py: Fix compiler to handle lambdas used as default arguments.
...
Addresses issue #1709 .
2015-12-12 13:42:51 +00:00
Damien George
de2a2e296b
tests: Add test for "not" of a user defined class.
2015-12-10 22:21:57 +00: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
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
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
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
Damien George
2c83894257
py: Implement default and star args for lambdas.
2015-11-17 14:00:14 +00:00
Paul Sokolovsky
0bd3f3291d
tests/base/struct1.py: Add test for repetition counters.
2015-10-31 18:55:31 +03: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