Commit Graph

966 Commits

Author SHA1 Message Date
Damien George a16715ac62 tests: Add special tests to test mp_printf function to improve coverage. 2015-05-28 14:25:07 +00:00
Damien George 9ede4dcfbb tests: Add some tests for printing floats to improve coverage. 2015-05-28 14:24:47 +00:00
Damien George 79474c6b16 py: Remove unnecessary extra handling of padding of nan/inf.
C's printf will pad nan/inf differently to CPython.  Our implementation
originally conformed to C, now it conforms to CPython's way.

Tests for this are also added in this patch.
2015-05-28 14:22:12 +00:00
Damien George 6d1ff7e966 tests: Add tests to create valid and invalid UART, I2C, SPI, CAN busses. 2015-05-28 11:06:12 +01:00
Damien George 9ae3fc6523 unix: Add option to use uPy readline, and enable by default.
This gets uPy readline working with unix port, with tab completion and
history.  GNU readline is still supported, configure using
MICROPY_USE_READLINE variable.
2015-05-27 15:59:43 +01:00
Dave Hylands a3a14b9db7 lib: Fix some issues in timeutils
In particular, dates prior to Mar 1, 2000 are screwed up.

The easiest way to see this is to do:

>>> import time
>>> time.localtime(0)
(2000, 1, 1, 0, 0, 0, 5, 1)
>>> time.localtime(1)
(2000, 1, 2, 233, 197, 197, 6, 2)

With this patch, we instead get:
>>> import time
>>> time.localtime(1)
(2000, 1, 1, 0, 0, 1, 5, 1)

Doh - In C % is NOT a modulo operator, it's a remainder operator.
2015-05-21 23:31:50 +03:00
Dave Hylands 3ad94d6072 extmod: Add ubinascii.unhexlify
This also pulls out hex_digit from py/lexer.c and makes unichar_hex_digit
2015-05-20 09:29:22 +01:00
stijn 861670ba2a py: Implement mp_format_float for doubles and use where appropriate
This allows using (almost) the same code for printing floats everywhere,
removes the dependency on sprintf and uses just snprintf and
applies an msvc-specific fix for snprintf in a single place so
nan/inf are now printed correctly.
2015-05-17 21:47:11 +01:00
stijn 709955b601 py: Fix printing of complex number when imaginary part is nan 2015-05-13 23:10:15 +01:00
Damien George f601390ef8 unix: Add some extra coverage tests for vstr and attrtuple. 2015-05-12 23:34:10 +01:00
Damien George 7bab32ef89 tests: Add further tests for class defining __hash__. 2015-05-12 23:08:18 +01:00
Damien George c2a4e4effc py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function.
Hashing is now done using mp_unary_op function with MP_UNARY_OP_HASH as
the operator argument.  Hashing for int, str and bytes still go via
fast-path in mp_unary_op since they are the most common objects which
need to be hashed.

This lead to quite a bit of code cleanup, and should be more efficient
if anything.  It saves 176 bytes code space on Thumb2, and 360 bytes on
x86.

The only loss is that the error message "unhashable type" is now the
more generic "unsupported type for __hash__".
2015-05-12 22:46:02 +01:00
Paul Sokolovsky 6738c1dded vm: Properly handle StopIteration raised in user instance iterator.
I.e. in bytecode Python functions.
2015-05-11 23:57:42 +01:00
blmorris 5df81de7af sthmal/rtc.c: Add calibration() method to get/set RTC fine-tuning value. 2015-05-11 23:48:39 +01:00
Paul Sokolovsky 4ed7b7f751 py: iternext() may not return MP_OBJ_NULL, only MP_OBJ_STOP_ITERATION.
Testing for incorrect value led to premature termination of generator
containing yield from for such iterator (e.g. "yield from [1, 2]").
2015-05-10 00:41:49 +03:00
Damien George d792d9e49e unix: Make extra-coverage function callable from Python scripts.
This allows the output of the extra-coverage tests to be checked using
the normal run-tests script.
2015-05-08 09:18:38 +01:00
Damien George 0589c19d52 tests: Add test for machine module (mem* functions). 2015-05-08 00:18:28 +01:00
Damien George 57ebe1b27d unix-cpy: Fix adjustment of stack size when leaving exception handler.
Also remove __debug__ from one of the bytecode tests.
2015-05-06 16:46:21 +01:00
Damien George 9a42eb541e py: Fix naming of function arguments when function is a closure.
Addresses issue #1226.
2015-05-06 13:55:33 +01:00
Damien George 367d4d1098 tests: Fix cmd_showbc now that LOAD_CONST_ELLIPSIS bytecode is gone. 2015-05-05 23:58:52 +01:00
Paul Sokolovsky 37c6555b44 obj: Handle user instance hash based on Python adhoc rules.
User instances are hashable by default (using __hash__ inherited from
"object"). But if __eq__ is defined and __hash__ not defined in particular
class, instance is not hashable.
2015-05-05 22:48:19 +03:00
Paul Sokolovsky 3d3ef36e97 modstruct: Rename module to "ustruct", to allow full Python-level impl. 2015-05-04 16:53:52 +03:00
Damien George 47b9809d23 py: Check that arg to object.__new__ is a user-defined type.
Addresses issue #1203.
2015-05-04 11:08:40 +01:00
Damien George 6bbbb1ab41 unix/modffi: Support passing float/double args. 2015-04-28 19:40:34 +01:00
Paul Sokolovsky ae2c81ff38 vm: On exiting except block, clear sys.exc_info() value.
This doesn't handle case fo enclosed except blocks, but once again,
sys.exc_info() support is a workaround for software which uses it
instead of properly catching exceptions via variable in except clause.
2015-04-26 01:40:37 +03:00
Damien George 271d18eb08 py: Support conversion of bignum to bytes.
This gets int.to_bytes working for bignum, and also struct.pack with 'q'
and 'Q' args on 32-bit machines.

Addresses issue #1155.
2015-04-25 23:16:39 +01:00
Paul Sokolovsky 8b85d14b92 modsys: Add basic sys.exc_info() implementation.
The implementation is very basic and non-compliant and provided solely for
CPython compatibility. The function itself is bad Python2 heritage, its
usage is discouraged.
2015-04-25 03:49:23 +03:00
Damien George 8c1d23a0e2 py: Modify bytecode "with" behaviour so it doesn't use any heap.
Before this patch a "with" block needed to create a bound method object
on the heap for the __exit__ call.  Now it doesn't because we use
load_method instead of load_attr, and save the method+self on the stack.
2015-04-24 01:52:28 +01:00
Damien George 40d43ea88d tests: Add more tests for viper, including tests for ViperTypeError's. 2015-04-22 23:18:28 +01:00
Damien George 1f9e2188a6 tests: Add tests for attrtuple, and for more corner cases. 2015-04-22 16:52:03 +01:00
Damien George 956d765786 py: Fix printing of "inf" and "nan" floating point values. 2015-04-22 16:51:29 +01:00
= 5008972fef py/inlinethumb: Support for core floating point instructions.
Adds support for the following Thumb2 VFP instructions, via the option
MICROPY_EMIT_INLINE_THUMB_FLOAT:

vcmp
vsqrt
vneg
vcvt_f32_to_s32
vcvt_s32_to_f32
vmrs
vmov
vldr
vstr
vadd
vsub
vmul
vdiv
2015-04-19 15:47:05 +01:00
Damien George d8cbbcaa9d py: Fix builtin ord so that it can handle bytes values >= 0x80.
Addresses issue #1188.
2015-04-19 12:26:46 +01:00
Henrik e3cd154317 stmhal: Add support for sending and receiving CAN RTR messages. 2015-04-18 14:53:00 +01:00
Damien George 7d5e34287c stmhal: Allow sending CAN messages with timeout=0.
Thanks to Henrik Sölver for this patch.
2015-04-16 23:52:43 +01:00
Damien George 90aa7595b4 tests: Convert line endings in fun_name.py from CRLF to LF. 2015-04-16 22:09:17 +01:00
Damien George 044c473de2 py: Add %q format support to mp_[v]printf, and use it. 2015-04-16 14:30:16 +00:00
Paul Sokolovsky 56beb01724 objarray: Support assignment of bytes to bytearray slice. 2015-04-16 00:51:12 +03:00
Paul Sokolovsky 8b7faa31e1 objstr: split(None): Fix whitespace properly. 2015-04-12 00:17:57 +03:00
Damien George 7a6dbaa89b stmhal: Make LED object print LED(x) for consistency with constructor. 2015-04-11 21:50:53 +01:00
Damien George 9988618e0e py: Implement full func arg passing for native emitter.
This patch gets full function argument passing working with native
emitter.  Includes named args, keyword args, default args, var args
and var keyword args.  Fully Python compliant.

It reuses the bytecode mp_setup_code_state function to do all the hard
work.  This function is slightly adjusted to accommodate native calls,
and the native emitter is forced a bit to emit similar prelude and
code-info as bytecode.
2015-04-07 22:43:28 +01:00
Damien George c9aa1883ed py: Simplify bytecode prelude when encoding closed over variables. 2015-04-07 00:08:17 +01:00
Damien George 78772ada0d py: Implement calling functions with *args in native emitter. 2015-04-06 22:48:21 +01:00
Damien George e5c4362a98 tests: Add some more tests to improve code coverage of corner cases. 2015-04-05 00:03:43 +01:00
Damien George 97abe22963 tests: Add tests to exercise lexer; and some more complex number tests. 2015-04-04 23:16:22 +01:00
Damien George 9dd3640464 tests: Add missing tests for builtins, and many other things. 2015-04-04 22:05:30 +01:00
Paul Sokolovsky 620058cc57 tests: Add test for str.splitlines(). 2015-04-04 00:09:54 +03:00
Damien George 82f37bf0d1 tests: Add specific test for closures in native emitter. 2015-04-03 16:14:25 +01:00
Damien George 4cd9ced8dc py: Implement closures in native code generator.
Currently supports only x64 and Thumb2 archs.
2015-04-03 15:05:53 +01:00
Paul Sokolovsky ad038ca101 tests/class_descriptor.py: Fix line-endings (were CRLF). 2015-03-28 01:07:00 +02:00
stijn 28fa84b445 py: Add optional support for descriptors' __get__ and __set__ methods.
Disabled by default.  Enabled on unix and windows ports.
2015-03-26 23:55:14 +00:00
Damien George 23d7fd526d tests: Skip some new tests when testing native emitter. 2015-03-25 23:33:48 +00:00
Damien George 214179b430 tests: Add tests for SyntaxError, TypeError, and other missing things.
This is intended to improve coverage of the test suite.
2015-03-25 23:10:09 +00:00
Damien George db80b65402 tests: Make pyb/timer test check callback timing properly. 2015-03-20 23:50:33 +00:00
stijn 3cc17c69ff py: Allow retrieving a function's __name__.
Disabled by default.  Enabled on unix and stmhal ports.
2015-03-20 23:13:32 +00:00
Damien George d478fc75b3 tests: Adjust expected output, since Travis can't do git describe. 2015-03-20 21:31:50 +00:00
Paul Sokolovsky d48035b06b tests: Add basic test for OrderedDict.
Mostly to have coverage of newly added code in map.c.
2015-03-20 17:26:10 +00:00
Damien George 1004535237 tests: Make cmdline tests more stable by using regex for matching. 2015-03-20 17:25:25 +00:00
Damien George f256cfef4f tests: Add some more tests for complex numbers and ure module. 2015-03-14 22:56:02 +00:00
Damien George 6837d46c1d py: Fix builtin abs so it works for bools and bignum. 2015-03-14 22:07:30 +00:00
Damien George 26a9975fba tests: Add some more tests for bytes, bignum, string and ujson. 2015-03-14 21:20:58 +00:00
Damien George 0683c1ceef tests: Don't try to verify amount of memory used in cmd_showbc test. 2015-03-14 17:38:41 +00:00
Damien George 703c009681 tests: Add cmdline test to test showbc code. 2015-03-14 14:06:20 +00:00
Damien George ac4f6b804f stmhal: Fix adc.read_timed so buffer store respects element size.
Addresses issue #1154.
2015-03-13 22:11:50 +00:00
Damien George 143c34109c tests: Add ability to test uPy cmdline executable.
This allows to test options passed to cmdline executable, as well as the
behaviour of the REPL.
2015-03-13 10:58:34 +00:00
Damien George af43565322 tests: Add tests for things that are not already tested.
The aim here is to improve coverage of the code.
2015-03-12 22:48:45 +00:00
Damien George c832bde05f tests: Add zlib test for decompressing uncompressed data. 2015-03-12 00:17:04 +00:00
Peter D. Gray b2a237d337 py: Add support for start/stop/step attributes of builtin range object. 2015-03-11 20:02:06 +00:00
Damien George 55278dcc76 tests: Add test for modure when regex has errors. 2015-03-10 17:47:43 +00:00
Damien George 6cb6947b99 extmod/ure: Correctly return None when a group has no match.
See issue #1122.
2015-03-04 13:51:32 +00:00
Damien George 72ddcfd9ff tests: Skip basics/boundmeth1.py for native emitter. 2015-03-03 18:06:45 +00:00
Damien George 086a7616dd tests: Add tests for boundmeth; and bignum cmp, unary, float, error. 2015-03-03 16:45:39 +00:00
stijn 25f1264699 tests: Skip special math fun tests when math module exists but not funs. 2015-03-03 14:36:59 +00:00
Damien George f2a889564b tests: Add basics test for gc module. 2015-03-02 18:30:17 +00:00
Damien George fe3da09fa0 tests: Use range as iterable instead of list comprehension.
So that navite emitter passes (comprehensions use yield which is not yet
supported by native emitter).
2015-03-02 17:55:55 +00:00
Damien George 24ffb8e876 tests: Add tests for builtins: all, any, sum, abs. 2015-03-02 17:21:10 +00:00
Damien George 96e37d3bb8 tests: Add tests for inline assembler beq_n and beq_w ops. 2015-03-02 14:31:00 +00:00
Damien George 2af921fb51 tests: Add tests for op special meths, ubinascii, complex. 2015-03-02 12:47:44 +00:00
Damien George 47538cc880 tests: Add test for micropython const feature when it has a SyntaxError. 2015-03-01 12:06:24 +00:00
Paul Sokolovsky 992284be39 tests: Add test for array slice assignment. 2015-02-27 22:17:24 +02:00
Damien George b67253e96f tests: Update pyb/uart.py test since baudrate of 1200 is too low. 2015-02-27 00:40:08 +00:00
Damien George 4852e09c79 py: Fix adding of traceback so that it appends to existing info.
This makes exception traceback info self contained (ie doesn't rely on
list object, which was a bit of a hack), reduces code size, and reduces
RAM footprint of exception by eliminating the list object.

Addresses part of issue #1126.
2015-02-27 00:36:39 +00:00
Damien George 626ee90ce1 tests: Add more tests for pyb.Timer class. 2015-02-23 13:18:33 +00:00
Damien George 5c047b97f2 tests: Add test for math special functions. 2015-02-22 14:49:46 +00:00
Damien George 4e3906d6b5 tests: Add tests for ure groups and named char classes.
Issue #1122 should now be fixed.
2015-02-21 10:39:41 +00:00
Paul Sokolovsky 2e24034c3f run-tests-exp.sh: Typo fix in comment. 2015-02-21 03:22:33 +02:00
Damien George eff10f66a6 py: Implement bl/bx instructions for inline Thumb assembler. 2015-02-16 18:17:07 +00:00
Paul Sokolovsky ee831cafa9 tests: Add another testcase for relative imports. 2015-02-16 12:11:41 +02:00
Henrik Sölver f80f1a7077 stmhal: Add support for CAN rx callbacks. 2015-02-15 03:10:53 +00:00
Damien George ed8b4da0db tests: Remove obsolete test; don't use fp in micropython/ tests. 2015-02-15 01:57:39 +00:00
Damien George f6532bb9e0 py: Simplify and remove redundant code for __iter__ method lookup. 2015-02-15 01:10:13 +00:00
Damien George d1c3788375 py: Fix loading of immediate pointer in Thumb assembler.
Addresses issue #1117.
2015-02-15 00:45:28 +00:00
stijn c1832fd206 py: Add setattr builtin. 2015-02-14 23:35:00 +00:00
Damien George baafb290ad stmhal: Add uart.sendbreak() method, to send a break condition. 2015-02-13 19:04:24 +00:00
Damien George 192d536fe4 py: Implement clz and rbit for inline Thumb assembler. 2015-02-13 11:06:23 +00:00
Damien George 32f0b7942c py: Implement sdiv/udiv for inline Thumb assembler. 2015-02-13 10:43:05 +00:00
Damien George 0d967b8ae4 py: Implement push/pop for inline Thumb assembler. 2015-02-13 02:30:35 +00:00
Damien George 48244044a2 py: Allow subclass of native object to delegate to the native buffer_p.
Addresses issue #1109.
2015-02-09 15:08:00 +00:00
Paul Sokolovsky 194117a066 objstr: Fix bytes creation from array of long ints. 2015-02-09 12:11:49 +08:00
Damien George 7d414a1b52 py: Parse big-int/float/imag constants directly in parser.
Previous to this patch, a big-int, float or imag constant was interned
(made into a qstr) and then parsed at runtime to create an object each
time it was needed.  This is wasteful in RAM and not efficient.  Now,
these constants are parsed straight away in the parser and turned into
objects.  This allows constants with large numbers of digits (so
addresses issue #1103) and takes us a step closer to #722.
2015-02-08 01:57:40 +00:00
Damien George 5f64dc55d8 extmod: Make ujson.loads raise exception if given empty string.
Addresses issue #1097.
2015-02-02 21:52:19 +00:00
Damien George e8b877be60 tests: Disable float/cmath_fun.py for native emitter. 2015-02-02 20:01:51 +00:00
Damien George 744e767458 py: Make list.sort keep stack usage within O(log(N)) bound.
Also fix list.sort so it works with user-defined types, and parse the
keyword arguments properly.

Addresses issue #338.
2015-02-02 15:14:22 +00:00
Damien George ae3150cb5c tests: Add test for cmath module. 2015-02-02 12:52:38 +00:00
Damien George 32bade19d9 py: Convert CR to LF and CR LF to LF in lexer.
Only noticeable difference is how newlines are encoded in triple-quoted
strings.  The behaviour now matches CPython3.
2015-01-30 00:27:46 +00:00
Damien George 92ab95f215 tests: Add some tests to improve coverage. 2015-01-29 14:56:09 +00:00
Damien George 26c0b155fa tests: Make float/int_power.py pass on pyboard/single prec float. 2015-01-29 13:56:58 +00:00
Damien George 12c66be2b8 tests: Add some tests to improve coverage.
Used gcov to find some parts of vm.c, runtime.c, obj.c that were not
covered by any tests.  Still need to use gcov more thoroughly.
2015-01-29 00:44:11 +00:00
Paul Sokolovsky 57aebe1714 tests: Add testcase for bytes() on values in range 128-255. 2015-01-28 22:29:51 +02:00
Paul Sokolovsky 2324f3ef29 moduzlib: Implement raw DEFLATE decoding support. 2015-01-28 02:21:49 +02:00
David Steinberg 0b3014ce3a py: Add support for floats in mp_binary_{get,set}_val()
- This then provides support for floats in the struct package
2015-01-27 22:49:01 +02:00
Damien George a9dc9b8f6d py: Fix comparison of minus-zero long int. 2015-01-27 17:47:38 +00:00
David Steinberg 4c1a7e0d6a tests: Update float2int tests for new range classifications
- Tests vary based on build configuration (32/64-bit and internal int type).
- Added tests for exceptions raised on overflow of int type.
2015-01-24 21:05:16 +00:00
Paul Sokolovsky 66b060f3e6 tests: Fix typo in file_long_read3.py. 2015-01-23 19:00:02 +02:00
Paul Sokolovsky 444331c07f modujson: .loads(): Handle more whitespace characters. 2015-01-23 18:41:29 +02:00
Paul Sokolovsky 1f04336b23 tests: Add extra test for reading multiple of internal chunk size. 2015-01-23 18:18:11 +02:00
Paul Sokolovsky 220d21e1bf tests: Add testcase for reading amounts bigger than buffer/chunk size. 2015-01-23 16:42:02 +02:00
Damien George 6d1f5070ce lib/libm: Add frexp and modf functions; use in stmhal; add tests.
Addresses issue #1081.
2015-01-22 13:48:29 +00:00
Damien George b6e6b5277f py: Implement proper re-raising in native codegen's finally handler.
This allows an exception to propagate correctly through a finally
handler.
2015-01-21 17:00:01 +00:00
Damien George 962a5d50c9 py: Implement __reversed__ slot.
Addresses issue #1073.
2015-01-21 00:19:42 +00:00
stijn bf19541f46 py: Prevent segfault for operations on closed StringIO.
Addresses issue #1067.
2015-01-20 23:50:43 +00:00
Damien George 1e1779eacf py: Reluctantly add an extra pass to bytecode compiler.
Bytecode also needs a pass to compute the stack size.  This is because
the state size of the bytecode function is encoded as a variable uint,
so we must know the value of this uint before we encode it (otherwise
the size of the generated code changes from one pass to the next).

Having an entire pass for this seems wasteful (in time).  Alternative is
to allocate fixed space for the state size (would need 3-4 bytes to be
general, when 1 byte is usually sufficient) which uses a bit of extra
RAM per bytecode function, and makes the code less elegant in places
where this uint is encoded/decoded.

So, for now, opt for an extra pass.
2015-01-14 00:20:28 +00:00
Damien George 4c81ba8015 py: Never intern data of large string/bytes object; add relevant tests.
Previously to this patch all constant string/bytes objects were
interned by the compiler, and this lead to crashes when the qstr was too
long (noticeable now that qstr length storage defaults to 1 byte).

With this patch, long string/bytes objects are never interned, and are
referenced directly as constant objects within generated code using
load_const_obj.
2015-01-13 16:21:23 +00:00
Damien George c38dc3ccc7 py: Implement fallback for equality check for all types.
Return "not equal" for objects that don't implement equality check.
This is as per Python specs.
2015-01-11 15:13:18 +00:00
Paul Sokolovsky 7bfe4b21b9 tests: Make ffi_callback.py be able to run on uclibc and macosx.
Similar to ffi_float.py.
2015-01-10 00:35:48 +02:00
Damien George c33ecb83ba tests: Add test for when instance member overrides class member. 2015-01-08 17:48:44 +00:00
Damien George 19b3fea6a8 tests: Separate out test cases that rely on float support to float/ dir. 2015-01-08 15:41:37 +00:00
Damien George ad2307c92c py: Temporary fix for conversion of float to int when fits in small int.
Addresses issue #1044 (see also #1040).  Could do with a better fix.
2015-01-07 12:10:47 +00:00
Paul Sokolovsky 343ca1e63a objarray: Make sure that longint works as bytearray size. 2015-01-04 17:19:16 +02:00
Paul Sokolovsky c114496641 objstr: Implement kwargs support for str.format(). 2015-01-04 00:26:31 +02:00
Damien George 6fd4b36bc5 py: Raise exception if trying to convert inf/nan to int. 2015-01-02 23:04:09 +00:00
David Steinberg 6e0b6d02db py: Fix float to int conversion for large exponents. 2015-01-02 22:31:41 +00:00
stijn 021dc44009 py: Allow keyword arguments for namedtuple 2015-01-01 14:53:23 +02:00
stijn 12340147b0 py: Use sequence of strings for named tuple initialization
- remove single string initialization style
- take list of strings instead
- store list in the type for fast lookup
2015-01-01 14:53:23 +02:00
Damien George e0ac194f4f py: Fix rshift and not of zero/one edge cases in mpz.
Addresses issue #1027.
2014-12-31 19:35:01 +00:00
Damien George 816a46a4ab tests: Disable float/float2int.py on pyboard (needs double prec). 2014-12-31 18:46:18 +00:00
Paul Sokolovsky 2c75665445 objstr: Fix %d-formatting of floats. 2014-12-31 02:21:19 +02:00
Paul Sokolovsky 12033df511 py: Partially fix float to int conversion.
This fixes conversion when float type has more mantissa bits than small int,
and float value has small exponent. This is for example the case of 32-bit
platform using doubles, and converting value of time.time(). Conversion of
floats with larg exponnet is still not handled correctly.
2014-12-30 00:22:50 +02:00
Damien George c55a4d82cf py: Make bytes objs work with more str methods; add tests. 2014-12-24 20:28:30 +00:00
Paul Sokolovsky 7fdb8d78a4 tests: Add run-tests-exp.py, simple MicroPython-based test runner.
This script is rewrite of run-tests-exp.sh, and tries to achieve self-hosted
testsuite running in environments where neither CPython nor unix shell is
available. As run-tests-exp.sh, it requires complete set of .exp files
pre-generated with ./run-test --write-exp.
2014-12-24 16:34:05 +00:00
Paul Sokolovsky 978f4ca2e1 run-tests: Allow to run testuite against Windows build on Linux (using Wine).
Just adjust line-endings of micropython.exe output, the rest should be
handled by Wine (automagically on properly configured distro).

To run:

MICROPY_MICROPYTHON=../windows/micropython.exe ./run-tests
2014-12-20 16:53:46 +02:00
stijn f5efefd5a0 windows: Correctly interpret skipped tests, enable uhashlib and ubinascii 2014-12-20 16:52:22 +02:00
Damien George f04329e93b lib/libm: Add acosh, asinh, atanh, tan; get working with stmhal.
acoshf, asinhf, atanhf were added from musl.  mathsincos.c was
split up into its original, separate files (from newlibe-nano-2).
tan was added.

All of the important missing float functions are now implemented,
and pyboard now passes tests/float/math_fun.py (finally!).
2014-12-18 14:44:02 +00:00
Damien George 6936f4626c tests: Get misc/print_exception and pyb/spi working on pyboard. 2014-12-18 13:37:56 +00:00
Paul Sokolovsky c8b0229bc7 tests: sha256: skip test if uhashlib module is not available. 2014-12-18 00:32:15 +02:00
Paul Sokolovsky 7a4765dbeb tests: Add testcase for ffi callbacks. 2014-12-15 02:18:54 +02:00
Paul Sokolovsky c0bc3bd736 asmarm: Fix bug with encoding small negative ints using MVN instruction. 2014-12-14 03:24:17 +02:00
Paul Sokolovsky 138562ccd9 run-tests: Skip native/viper tests based on prefix.
Otherwise, new tests are forgotten to be added to explicit lists. Issue
found running on Debian/ARM.
2014-12-13 00:51:24 +02:00
Damien George e181c0dc07 py: Fix optimised for-loop compiler so it follows proper semantics.
You can now assign to the range end variable and the for-loop still
works correctly.  This fully addresses issue #565.

Also fixed a bug with the stack not being fully popped when breaking out
of an optimised for-loop (and it's actually impossible to write a test
for this case!).
2014-12-12 17:19:56 +00:00
Paul Sokolovsky 1ca28bd570 run-tests: Reset MICROPYPATH, to make sure tests use only builtin modules. 2014-12-12 00:58:07 +02:00
Paul Sokolovsky dbc7854355 run-tests: PEP8 fix. 2014-12-12 00:58:07 +02:00
Paul Sokolovsky f42b3c7599 tests: Activate recursive_data.py test, now that io.StringIO is available. 2014-12-12 00:58:07 +02:00
Damien George 5fba93a26b tests: Add test for semantics of for-loop that optimisation can break. 2014-12-11 17:40:41 +00:00
Damien George f905145c6d tests: Disable print_exception test when using native emitter. 2014-12-11 17:34:55 +00:00
Damien George 184182d14c tests: Fix print_exception test and re-enable it on Travis CI.
Issue was with uPy: on local machine with micropython-lib installed, io
module is available.  Not the case on Travis CI, where only _io module
is available in uPy.
2014-12-11 17:10:25 +00:00
Paul Sokolovsky 66a6caa307 run-tests: Skip print_exception.py on TravisCI, as it irreproducibly fails.
TODO: Figure out what's wrong on Travis.
2014-12-11 15:03:29 +02:00
Damien George 4140e19c8a tests: Fix print_exception.py to work on Travis CI. 2014-12-10 21:45:51 +00:00
Paul Sokolovsky e8487ea1be tests: Add test for print_exception() function. 2014-12-10 20:48:53 +00:00
Damien George 78d702c300 py: Allow builtins to be overridden.
This patch adds a configuration option (MICROPY_CAN_OVERRIDE_BUILTINS)
which, when enabled, allows to override all names within the builtins
module.  A builtins override dict is created the first time the user
assigns to a name in the builtins model, and then that dict is searched
first on subsequent lookups.  Note that this implementation doesn't
allow deleting of names.

This patch also does some refactoring of builtins code, creating the
modbuiltins.c file.

Addresses issue #959.
2014-12-09 16:19:48 +00:00
Damien George be6d8be91e py: Rename mp_obj_int_get to mp_obj_int_get_truncated; fix struct.pack.
mp_obj_int_get_truncated is used as a "fast path" int accessor that
doesn't check for overflow and returns the int truncated to the machine
word size, ie mp_int_t.

Use mp_obj_int_get_truncated to fix struct.pack when packing maximum word
sized values.

Addresses issues #779 and #998.
2014-12-05 23:13:52 +00:00
Damien George 32ef3a3517 py: Allow bytes/bytearray/array to be init'd by buffer protocol objects.
Behaviour of array initialisation is subtly different for bytes,
bytearray and array.array when argument has buffer protocol.  This patch
gets us CPython conformant (except we allow initialisation of
array.array by buffer with length not a multiple of typecode).
2014-12-04 15:46:14 +00:00
Damien George b2e731177e py: Implement +, += and .extend for bytearray and array objs.
Addresses issue #994.
2014-11-30 00:00:55 +00:00
Damien George 7288403b9b tests: Split out float test from builtin_round.py. 2014-11-29 14:47:54 +00:00
Henrik Sölver acb92c186c Adding CAN filter management 2014-11-26 18:52:33 +00:00
Paul Sokolovsky 4a1c80c293 tests: Add test for hashlib.sha256 . 2014-11-22 14:54:02 +02:00
Damien George c9f8f653ad py: Add support for float/double arrays in array module.
Addresses issue #981.
2014-11-21 18:16:25 +00:00
blmorris 9d1ca65b59 Set PYTHONIOENCODING='utf-8' so that unicode tests can pass on CPython on
systems where another encoding is set in the locale
2014-11-19 10:44:31 -05:00
Damien George 5694cc5490 py: Make stream seek correctly check for ioctl fn; add seek for textio. 2014-11-16 23:56:37 +00:00
Paul Sokolovsky c7d5500142 tests: Add test for file.seek(). 2014-11-17 00:16:14 +02:00
Damien George 224fee0e10 stmhal: Fix HAL error raising; make test for it.
Addresses issue #968.
2014-11-15 20:39:44 +00:00
Damien George 4df85e49d4 tests: Add test for hash of user defined class. 2014-11-15 18:30:01 +00:00
Damien George a65c03c6c0 py: Allow +, in, and compare ops between bytes and bytearray/array.
Eg b"123" + bytearray(2) now works.  This patch actually decreases code
size while adding functionality: 32-bit unix down by 128 bytes, stmhal
down by 84 bytes.
2014-11-05 16:30:34 +00:00
Damien George 0344fa1ddf py: Fix builtin callable so it checks user-defined instances correctly.
Addresses issue #953.
2014-11-03 16:09:39 +00:00
Paul Sokolovsky 039887a0ac py: Fix bug with right-shifting small ints by large amounts.
Undefined behavior in C, needs explicit check.
2014-11-02 02:41:30 +02:00
Damien George c7da7838ba tests: Add heapalloc.py.exp, since CPython can't generate it. 2014-10-31 22:09:40 +00:00
Damien George 109c1de015 py: Make gc.enable/disable just control auto-GC; alloc is still allowed.
gc.enable/disable are now the same as CPython: they just control whether
automatic garbage collection is enabled or not.  If disabled, you can
still allocate heap memory, and initiate a manual collection.
2014-10-31 21:30:46 +00:00
Damien George 1559a97810 py: Add builtin round function.
Addresses issue #934.
2014-10-31 11:28:50 +00:00
Damien George efc49c5591 stmhal: Improve CAN print function. 2014-10-30 23:16:05 +00:00
Henrik Sölver 6a15ac80dc tests: Added and adapted CAN tests for extended messages 2014-10-30 23:16:01 +00:00
Paul Sokolovsky e62a0fe367 objstr: Allow to convert any buffer proto object to str.
Original motivation is to support converting bytearrays, but easier to just
support buffer protocol at all.
2014-10-31 00:03:53 +02:00
Paul Sokolovsky 66d08eb4fe moductypes: Add test for accessing UINT8 array. 2014-10-30 03:50:37 +02:00
Paul Sokolovsky 2559e13957 moductypes: Make sure we can apply .sizeof() to all aggregate types.
Before, sizeof() could be applied to a structure field only if that field
was itself a structure. Now it can be applied to PTR and ARRAY fields too.
It's not possible to apply it to scalar fields though, because as soon as
scalar field (int or float) is dereferenced, its value is converted into
Python int/float value, and all original type info is lost. Moreover, we
allow sizeof of type definitions too, and there int is used to represent
(scalar) types. So, we have ambiguity what int may be - either dereferenced
scalar structure field, or encoded scalar type. So, rather throw an error
if user tries to apply sizeof() to int.
2014-10-30 03:50:23 +02:00
Damien George b2f19b8d34 tests: Get builtin_compile to skin properly on pyboard. 2014-10-26 15:38:28 +00:00
Damien George 480a7ce58f stmhal: Change SPI phase spec to 0,1 to match standard conventions.
Was 1 or 2, now 0 or 1 (respectively).  0 means sample MISO on first
edge, 1 means sample on second edge.

Addresses issue #936.
2014-10-26 13:54:31 +00:00
Damien George de3c806965 py: Fix memoryview referencing so it retains ptr to original buffer.
This way, if original parent object is GC'd, the memoryview still points
to the underlying buffer data so that buffer is not GC'd.
2014-10-26 13:20:50 +00:00
Damien George 627852019b tests: Add test for compile builtin. 2014-10-25 22:07:25 +01:00
Paul Sokolovsky e2f8d98525 stream: Add optional 2nd "length" arg to .readinto() - extension to CPython.
While extension to file.readinto() definition of CPython, the additional arg
is similar to what in CPython available in socket.recv_into().
2014-10-23 21:43:59 +03:00
Damien George dd4f4530ab py: Add builtin memoryview object (mostly using array code). 2014-10-23 13:34:35 +01:00
Damien George f5d69794a8 extmod: Add uheapq module. 2014-10-22 23:20:15 +01:00
Damien George e72be1b999 py: Fix smallint modulo with negative arguments.
Addresses issue #927.
2014-10-22 23:05:50 +01:00
Damien George e7a478204a py: Remove unused and unneeded SystemError exception.
It's purpose is for internal errors that are not catastrophic (ie not as
bad as RuntimeError).  Since we don't use it, we don't need it.
2014-10-22 19:42:55 +01:00
Damien George 481d714bd5 stmhal: Overhaul UART class to use read/write, and improve it.
UART object now uses a stream-like interface: read, readall, readline,
readinto, readchar, write, writechar.

Timeouts are configured when the UART object is initialised, using
timeout and timeout_char keyword args.

The object includes optional read buffering, using interrupts.  You can set
the buffer size dynamically using read_buf_len keyword arg.  A size of 0
disables buffering.
2014-10-21 22:15:20 +01:00
stijn a3efe04dce Use mode/encoding kwargs in io and unicode tests
mode argument is used to assert it works
encoding argument is used to make sure CPython uses the correct encoding
as it does not automatically use utf-8
2014-10-21 22:10:38 +03:00
Damien George 21ca2d76a2 py: Partially fix viper multi-comparison; add test for it. 2014-10-19 19:00:51 +01:00
Paul Sokolovsky 1a55b6a787 unix, stmhal: Implement file.readinto() method.
Also, usocket.readinto(). Known issue is that .readinto() should be available
only for binary files, but micropython uses single method table for both
binary and text files.
2014-10-18 22:44:07 +03:00
Paul Sokolovsky 297d8469b8 modure: Update to re1.5 v0.6.1, fixed and extended character class support. 2014-10-17 22:25:18 +03:00
Damien George 391db8669b py: Add more compiler optimisations for constant if/while conditions. 2014-10-17 17:57:33 +00:00
Damien George 9870fdd4b0 tests: Add test for nested while with exc and break. 2014-10-17 17:28:25 +00:00
Paul Sokolovsky 067ae1269d objclosure: Fix printing of generator closures.
The code previously assumed that only functions can be closed over.
2014-10-16 00:14:01 +03:00
Paul Sokolovsky 95908b0f50 modure: Update to re1.5 v0.6, support for char sets/classes ([a-c]). 2014-10-15 04:44:07 +03:00
Damien George 29f5682621 Merge pull request #904 from pfalcon/moduzlib
Module "uzlib" - based on similarly named library
2014-10-12 23:25:24 +01:00
Paul Sokolovsky 34162872b1 moduzlib: Integrate into the system. 2014-10-13 00:07:44 +03:00
Damien George 91cfd414c0 py: Implement native load for viper.
Viper can now do: ptr8(buf)[0], which loads a byte from a buffer using
machine instructions.
2014-10-12 16:59:29 +01:00
Damien George 1ef2348df0 py: Implement and,or,xor native ops for viper. 2014-10-12 14:21:06 +01:00
Paul Sokolovsky f7bcce0552 modure: Basic tests. 2014-10-11 14:36:33 +03:00
Paul Sokolovsky 5dc8f9b28a tests: Skip ffi_float.py if module ffi is not available. 2014-10-06 22:37:40 +03:00
Paul Sokolovsky 9aeec0e3a3 tests: Add missing "import sys". 2014-10-06 22:30:46 +03:00
Damien George f53c343363 tests: Force skip of LE test on non-LE arch; improve run-tests-exp.sh. 2014-10-06 17:35:46 +00:00
Damien George 9c6f7378f7 tests: Make run-tests-exp.sh skip tests that fail due to invalid decorator.
Should address issue #856.
2014-10-06 17:06:49 +00:00
Damien George 5a04e2cca8 tests: Add check for micropython.native and then skip relevant tests.
If micropython.native decorator doesn't compile, then we skill all
native/viper tests.

This patch also re-enables the ujson_loads test on NT.

Addresses issue #861, and partially addresses issue #856.
2014-10-05 22:27:12 +01:00
Damien George a91ac2011f py: Make compiler return a proper exception on SyntaxError. 2014-10-05 19:01:34 +01:00
Damien George c3ab90da46 tests: Make printing of floats hopefully more portable. 2014-10-05 17:50:02 +01:00
stijn dc1ea1156a Exclude some tests which always fail on windows 2014-10-05 09:32:26 +02:00
Damien George e535a61983 tests: Add simple CAN test. 2014-10-02 17:32:02 +01:00
blmorris 3b064370f8 Enable device keyword option when running pyboard.py --tests and run-tests --pyboard 2014-10-01 23:31:52 +01:00
Damien George 8b03d944e2 py: Remove IOError since it's deprecated; use OSError instead.
In CPython IOError (and EnvironmentError) is deprecated and aliased to
OSError.  All modules that used to raise IOError now raise OSError (or a
derived exception).

In Micro Python we never used IOError (except 1 place, incorrectly) and
so don't need to keep it.

See http://legacy.python.org/dev/peps/pep-3151/ for background.
2014-09-30 13:59:30 +00:00
Damien George dfef4249eb py: Fix viper store on x86; add tests for viper ptr16. 2014-09-29 21:41:41 +00:00
Damien George e9dac3b4d0 py: Add casting to viper; add native mem stores to viper.
Viper can now do the following:

def store(p:ptr8, c:int):
    p[0] = c

This does a store of c to the memory pointed to by p using a machine
instructions inline in the code.
2014-09-29 22:10:41 +01:00
Damien George 44c96b2314 tests: Add tests for viper binary operations. 2014-09-29 19:42:06 +01:00
Damien George 6f81348fa2 py: Allow viper to use ints as direct conditionals in jumps.
Allows things like: if 1: ...
2014-09-29 19:42:06 +01:00
Damien George cde0ca21bf py: Simplify JSON str printing (while still conforming to JSON spec).
The JSON specs are relatively flexible and allow us to use one function
to print strings, be they ascii, bytes or utf-8 encoded.
2014-09-25 17:35:56 +01:00
blmorris 4f449120e1 Change allows tests/unix/ffi_float.py to pass on OSX 2014-09-25 16:31:30 +01:00
Damien George 2234c3f23d tests: Add test for exception matching of a tuple of exceptions. 2014-09-25 15:49:26 +01:00
Damien George d6230f62c7 py: Make native emitter handle multi-compare and not/is not/not in ops. 2014-09-23 14:15:45 +00:00
Damien George 96e20c600f tests: Fix uctypes tests to run on 64bit arch; enable more native tests. 2014-09-23 14:15:45 +00:00
Damien George 2c180f7ccc extmod, ujson: Add test and comment for loads. 2014-09-21 23:43:03 +01:00
Damien George 612045f53f py: Add native json printing using existing print framework.
Also add start of ujson module with dumps implemented.  Enabled in unix
and stmhal ports.  Test passes on both.
2014-09-17 22:56:34 +01:00
Damien George 83695596ed py: Fix build error when float disabled; add test for divmod. 2014-09-13 19:58:18 +01:00
Damien George 8594ce2280 py: Implement divmod, % and proper // for floating point.
Tested and working on unix and pyboard.
2014-09-13 18:43:09 +01:00
Damien George c7a79284bb tests: Enable misc tests on pyboard; output 4 sig figs in rge_sm. 2014-09-06 18:38:55 +01:00
Damien George 17598d49e1 unix: Don't use -Wno-error=cpp or #warning; fix strict alias warning.
For the sake of older versions of gcc (and other compilers), don't use
the #warning CPP directive, nor the -Wno-error=cpp option.

Also, fix a strict alias warning in modffi.c for older compilers, and
add a test for ffi module.

Addresses issue #847.
2014-09-06 17:46:52 +01:00
Damien George 9a21d2e070 py: Make mpz able to use 16 bits per digit; and 32 on 64-bit arch.
Previously, mpz was restricted to using at most 15 bits in each digit,
where a digit was a uint16_t.

With this patch, mpz can use all 16 bits in the uint16_t (improvement
to mpn_div was required).  This gives small inprovements in speed and
RAM usage.  It also yields savings in ROM code size because all of the
digit masking operations become no-ops.

Also, mpz can now use a uint32_t as the digit type, and hence use 32
bits per digit.  This will give decent improvements in mpz speed on
64-bit machines.

Test for big integer division added.
2014-09-06 17:15:34 +01:00
Damien George 02d95d7ce9 py: Fix 2 bugs in native emitter: jump_or_pop and stack settling.
Addresses issue #838.
2014-08-29 20:05:32 +01:00
Damien George 15d2fe8da4 tests: Add option to run-tests to enable native emitter. 2014-08-29 19:47:10 +01:00
Dave Hylands b7f7c655ed Make int(b'123') work properly. 2014-08-26 19:15:04 -07:00
Damien George 779794a680 py: Add dispatch for user defined ==, >, <=, >=.
Addresses issue #827.
2014-08-26 09:31:26 +01:00
Damien George fa1a9bc9fd tests: Add test for pyb.disable_irq and pyb.enable_irq. 2014-08-25 18:44:10 +01:00
Damien George 7310fd469a py: Consolidate min/max functions into one, and add key= argument.
Addresses issue #811.
2014-08-24 19:14:09 +01:00
Damien George 8ba832456e stmhal, modtime: Small changes, reduced code size by around 80 bytes.
Also added test for modtime.
2014-08-24 17:40:24 +01:00
Damien George 3c658a4e75 py: Fix bug where GC collected native/viper/asm function data.
Because (for Thumb) a function pointer has the LSB set, pointers to
dynamic functions in RAM (eg native, viper or asm functions) were not
being traced by the GC.  This patch is a comprehensive fix for this.

Addresses issue #820.
2014-08-24 16:28:17 +01:00
Damien George 86de21b810 py: Viper can call functions with native types, and raise exceptions. 2014-08-16 22:06:11 +01:00
Damien George d779b9642f tests: Wait for just over 1 sec when testing RTC.
Waiting for 1000ms between seconds of RTC is sometimes too quick.
Waiting for 1001ms is enough for the RTC to pass 1 second.
2014-08-16 13:39:14 +01:00
Damien George e6c0dff967 py: Viper can now store to global. 2014-08-15 23:47:59 +01:00
Damien George a5190a7dac py: Fix typing of viper locals; allow default types in annotation. 2014-08-15 22:39:08 +01:00
Damien George 2ac4af6946 py: Allow viper to have type annotations.
Viper functions can now be annotated with the type of their arguments
and return value.  Eg:

@micropython.viper
def f(x:int) -> int:
    return x + 1
2014-08-15 16:45:41 +01:00
Damien George 9b7a8ee8f1 py: Fix mult by negative number of tuple, list, str, bytes.
Multiplication of a tuple, list, str or bytes now yields an empty
sequence (instead of crashing).  Addresses issue #799

Also added ability to mult bytes on LHS by integer.
2014-08-13 13:22:24 +01:00
Damien George 1ddd844815 extmod: Finish rename of zlib to zlibd; enable zlibd on stmhal. 2014-08-12 23:23:53 +01:00
Paul Sokolovsky 5073d3da07 tests: Add test for zlibd module. 2014-08-13 00:26:26 +03:00
Damien George bb91f1195a py: Improve range: add len, subscr, proper print.
Can now index ranges with integers and slices, and reverse ranges
(although reversing is not very efficient).

Not sure how useful this stuff is, but gets us closer to having all of
Python's builtins.
2014-08-12 19:41:18 +01:00
Damien George 4c03b3a899 py: Implement builtin reversed() function.
reversed function now implemented, and works for tuple, list, str, bytes
and user objects with __len__ and __getitem__.

Renamed mp_builtin_len to mp_obj_len to make it publically available (eg
for reversed).
2014-08-12 18:33:40 +01:00
Paul Sokolovsky 9749b2fb0d objstr: Make sure that bytes are indexed as bytes, not as unicode.
Fixes #795.
2014-08-11 22:38:00 +03:00
Paul Sokolovsky 5f930337bc objarray: Implement equality testing between arrays and other buffers. 2014-08-10 16:22:57 +03:00
Damien George b92e7533d3 tests, pyb: Update pin test. 2014-08-08 22:38:58 +01:00
Paul Sokolovsky d0f5e61ab5 py: Implement __file__ attribute for modules. 2014-07-28 21:21:59 +03:00
Paul Sokolovsky 512465bc66 tests: Add testcase for read by length past EOF.
Currently broken for unicode input streams.
2014-07-22 00:11:37 +03:00
Damien George 1694bc733d py: Add stream reading of n unicode chars; unicode support by default.
With unicode enabled, this patch allows reading a fixed number of
characters from text-mode streams; eg file.read(5) will read 5 unicode
chars, which can made of more than 5 bytes.

For an ASCII stream (ie no chars > 127) it only needs to do 1 read.  If
there are lots of non-ASCII chars in a stream, then it needs multiple
reads of the underlying object.

Adds a new test for this case.  Enables unicode support by default on
unix and stmhal ports.
2014-07-19 18:34:04 +01:00
Paul Sokolovsky a1760a56ff test: Add run-tests-exp.sh, script to run testsuite with only sh dependency.
This script uses expected test results as generated by run-tests --write-exp,
and requires only standard unix shell funtionality (no bash). It is useful
to run testsuite on embedded systems, where there's no CPython and Bash.
2014-07-13 18:49:56 +03:00
Paul Sokolovsky 2cf381081a run-tests: Add option to write CPython's test results to .exp files.
Mostly to run testsuite on targets which doesn't have CPython.
2014-07-12 16:34:51 +03:00
Paul Sokolovsky 2097c8b1e1 moductypes: Add symbolic constants to specify bitfield position/length. 2014-07-11 00:06:36 +03:00
Paul Sokolovsky 8215847b4d moductypes: Foreign data interface module, roughly based on ctype ideas.
But much smaller and memory-efficient. Uses Python builtin data structures
(dict, tuple, int) to describe structure layout.
2014-07-09 19:28:24 +03:00
Damien George 539681fffd tests: Rename test scripts, changing - to _ for consistency.
From now on, all new tests must use underscore.

Addresses issue #727.
2014-07-05 06:14:29 +01:00
Damien George 0182385ab0 py: Automatically ake __new__ a staticmethod.
Addresses issue #622.
2014-07-05 05:55:00 +01:00
Damien George 41736f8201 tests: Write output in byte mode, not text mode.
This enables testing unicode and non-unicode implementations.
2014-06-28 10:29:12 +01:00
Damien George b3a50f0f3e Merge branch 'master' into unicode
Conflicts:
	py/mpconfig.h
2014-06-28 10:27:15 +01:00
Paul Sokolovsky 8993fb6cf0 py: Add protection against printing too nested or recursive data structures.
With a test which cannot be automatically validated so far.
2014-06-28 02:25:04 +03:00
Paul Sokolovsky ed07d035d5 tests: Add basic test for unicode file i/o. 2014-06-27 00:04:20 +03:00
Paul Sokolovsky 63143c94ce tests: Test for explicit start/end args to str methods for unicode. 2014-06-27 00:04:20 +03:00
Paul Sokolovsky b1949e4c09 tests: Add tests for unicode find()/rfind()/index(). 2014-06-27 00:04:19 +03:00
Paul Sokolovsky 17994d1bd3 tests: Add test for unicode string iteration. 2014-06-27 00:04:19 +03:00
Chris Angelico 1e3781bc35 tests: Add unicode test. 2014-06-27 00:04:17 +03:00
Paul Sokolovsky 16ac4962ae tests: Add test for catching infinite function recursion.
Put into misc/ to not complicate life for builds with check disabled.
2014-06-27 00:03:56 +03:00
Paul Sokolovsky 7a2f166949 modstruct: Fix alignment handling issues.
Also, factor out mp_binary_get_int() function.
2014-06-25 23:34:44 +03:00
Paul Sokolovsky f605172d2b tests/float/: Skip tests if "math" module is not available. 2014-06-20 18:00:23 +03:00
Paul Sokolovsky 74c710187c bench: Three ways to process a byte buffer. 2014-06-19 22:27:13 +03:00
Paul Sokolovsky 59ced651b5 bench: Add test for map() vs inplace operations in array-likes.
map() is 5 times slower. That's mostly because of inefficiency of creating
containers from iterables of unknown length (like map()).
2014-06-19 22:19:24 +03:00
Paul Sokolovsky 17db096505 bench: Add tests for constructing various containers from iterator.
Both "bound" (like, length known) and "unbound" (length unknown) are tested.
All of list, tuple, bytes, bytesarray offer approximately the same
performance, with "unbound" case being 30 times slower.
2014-06-19 21:44:33 +03:00
Paul Sokolovsky e53d2197e4 bench: Add test for function call overhead.
For a trivial operation, calling a function is 5 times slower than doing
operation inline.
2014-06-19 20:49:03 +03:00
Paul Sokolovsky 2ec38a17d4 objstr: Be 8-bit clean even for repr().
This will allow roughly the same behavior as Python3 for non-ASCII strings,
for example, print("<phrase in non-Latin script>".split()) will print list
of words, not weird hex dump (like Python2 behaves). (Of course, that it
will print list of words, if there're "words" in that phrase at all, separated
by ASCII-compatible whitespace; that surely won't apply to every human
language in existence).
2014-06-14 01:21:13 +03:00
Paul Sokolovsky fbdf2f1d63 py: Rename builtin "io" to "_io".
Functionality we provide in builtin io module is fairly minimal. Some
code, including CPython stdlib, depends on more functionality. So, there's
a choice to either implement it in C, or move it _io, and let implement other
functionality in Python. 2nd choice is pursued. This setup matches CPython
too (_io is builtin, io is Python-level).
2014-06-12 01:22:25 +03:00
Paul Sokolovsky f4bf065dac tests: Add testcases for "complicated" args to generator functions. 2014-06-11 20:43:47 +03:00
Damien George 58cbb4d661 py: Implement __contains__ special method. 2014-06-10 23:07:56 +01:00
Paul Sokolovsky 195de3247b objtype: Fix passing of class param to inherited classmethods.
This is getting more and more tangled, but that's old news.
2014-06-08 22:28:44 +03:00
Damien George 4297fed1c3 tests: Run 'micropython' tests on pyboard. 2014-06-08 13:46:03 +01:00
Damien George 9e951498b2 tests: Add more tests for default keyword-only args. 2014-06-08 12:58:32 +01:00
Damien George c06427c019 tests: Fix default arg test. 2014-06-08 00:12:32 +01:00
Paul Sokolovsky b4efac14cd py: Make sure getattr() works with non-interned strings (by interning them). 2014-06-08 01:15:06 +03:00
Damien George f0778a7ccb py: Implement default keyword only args.
Should finish addressing issue #524.
2014-06-07 22:01:00 +01:00
Paul Sokolovsky b56a53dfd6 Merge pull request #667 from Rosuav/testfixes
A couple of small fixes to run-tests
2014-06-06 22:23:23 +03:00
Dave Hylands b69f9fa31f Fix str.modulo when precision is specified. 2014-06-05 23:09:02 -07:00
Chris Angelico 047db2299c Turn the Travis CI test skipping mechanism into something more generic 2014-06-06 07:51:01 +10:00
Chris Angelico 88b11b50e5 Figure out the test_name before using it (significant only to Travis skips) 2014-06-06 07:51:01 +10:00
Damien George d4c2bddd0c py: Raise TypeError when trying to format non-int with %x,%o,%X.
This behaviour follows Python 3.5 standard (in 3.4 it's a
DeprecationWarning which we'd rather make a TypeError).
2014-06-05 19:44:54 +01:00
Chris Angelico daf973ae00 Change comments (mainly URLs) to no longer specifically say Python 3.3 2014-06-06 03:51:03 +10:00
Damien George c074cd38c3 Merge pull request #663 from Rosuav/floatpercentx
Remove tests that fail under CPython 3.5
2014-06-05 18:39:08 +01:00
Paul Sokolovsky 75ce9256b2 objstr: Implement "%(key)s" % {} formatting for strings and dicts.
Also, make sure that args to "*" format specifiers are bounds-checked
properly and don't lead for segfaults in case of mismatch.
2014-06-05 20:06:15 +03:00
Chris Angelico 7a6e09635a Remove tests that fail under CPython 3.5
See http://bugs.python.org/issue19995 for rationale. As micropython currently
aims for Python 3.3 compatibility I have not changed behaviour, but this
change allows the test suite to be run against a newer Python without having
spurious failures.
2014-06-05 22:34:11 +10:00
Damien George bcb6ca4d5e py: Implement full behaviour of dict.update(), and dict().
Add keyword args to dict.update(), and ability to take a dictionary as
argument.

dict() class constructor can now use dict.update() directly.

This patch loses fast path for dict(other_dict), but is that really
needed?  Any anyway, this idiom will now re-hash the dictionary, so is
arguably more memory efficient.

Addresses issue #647.
2014-06-03 12:53:44 +01:00
Damien George 4d659f566f tests: Add feature test for when heap allocation is disabled. 2014-05-31 18:33:16 +01:00
Damien George a053e37b2c tests: Change --test_dirs to --test-dirs. 2014-05-31 18:11:01 +01:00
Damien George e7412ab37b Merge pull request #632 from stinos/tests-dir-argument
tests: Add argument to allow specifying which directories to test
2014-05-31 18:11:03 +01:00