Commit Graph

765 Commits

Author SHA1 Message Date
Damien George
51b9a0d0c4 py/objstr: Make string formatting 8-bit clean. 2015-08-29 23:13:51 +01:00
Damien George
1d350b8ac6 tests: Add a few tests for bool, bytearray, float to improve coverage. 2015-08-29 23:13:28 +01:00
Paul Sokolovsky
a488c266c3 tests: Add byteorder query script. 2015-08-30 01:04:04 +03:00
Paul Sokolovsky
58d9b10d70 tests: Split byteorder-dependent tests to *_endian.py's. 2015-08-30 00:38:00 +03:00
Paul Sokolovsky
0a8b5d160b run-tests: Allow to skip byteorder-dependent tests.
If byteorder of MicroPython under test and host CPython differ.
2015-08-30 00:37:53 +03:00
Paul Sokolovsky
5cb524673e tests/ffi_float: Split tgammaf() testcase to a separate test.
Some libc's may implement tgammaf as a header macro using tgamma(), so
don't assume it'll be in the library.
2015-08-29 17:24:29 +03:00
Paul Sokolovsky
a160b70ced tests: Add test on set/frozenset equality. 2015-08-28 22:42:01 +03:00
Paul Sokolovsky
8b3b2d04a8 objset: frozensets are hashable. 2015-08-28 22:31:52 +03:00
Damien George
936e25b164 tests: For unix ffi float test, add libm.so.6 to library search list.
Latest Arch Linux doesn't have libm.so as a proper shared object and so
we need to load libm.so.6.
2015-08-25 18:14:53 +01:00
Damien George
d007cb8903 tests: Add more tests to improve coverage, mostly testing exceptions. 2015-08-21 12:02:09 +01:00
Damien George
d292a81e95 tests: Make io test cleanup after itself by removing 'testfile'. 2015-08-21 08:45:52 +01:00
Damien George
65dc960e3b unix-cpy: Remove unix-cpy. It's no longer needed.
unix-cpy was originally written to get semantic equivalent with CPython
without writing functional tests.  When writing the initial
implementation of uPy it was a long way between lexer and functional
tests, so the half-way test was to make sure that the bytecode was
correct.  The idea was that if the uPy bytecode matched CPython 1-1 then
uPy would be proper Python if the bytecodes acted correctly.  And having
matching bytecode meant that it was less likely to miss some deep
subtlety in the Python semantics that would require an architectural
change later on.

But that is all history and it no longer makes sense to retain the
ability to output CPython bytecode, because:

1. It outputs CPython 3.3 compatible bytecode.  CPython's bytecode
changes from version to version, and seems to have changed quite a bit
in 3.5.  There's no point in changing the bytecode output to match
CPython anymore.

2. uPy and CPy do different optimisations to the bytecode which makes it
harder to match.

3. The bytecode tests are not run.  They were never part of Travis and
are not run locally anymore.

4. The EMIT_CPYTHON option needs a lot of extra source code which adds
heaps of noise, especially in compile.c.

5. Now that there is an extensive test suite (which tests functionality)
there is no need to match the bytecode.  Some very subtle behaviour is
tested with the test suite and passing these tests is a much better
way to stay Python-language compliant, rather than trying to match
CPy bytecode.
2015-08-17 12:51:26 +01:00
blmorris
bdd78c31b6 py: Add stream_tell method, and use for unix and stmhal file tell. 2015-08-13 22:56:32 +01:00
Tom Soulanille
20f40c3229 tests: Remove over-specification of startup banner 2015-08-08 12:37:36 +01:00
stijn
dbfba6a20e tests: Fix exceptions when running cmdline tests on windows
- subprocess.check_output can only handle strings on windows, not bytes,
  so convert the arguments as such
- the pty module is for posix systems only so skip the tests needing it
  in case it is not available
2015-08-08 12:35:27 +01:00
stijn
7ede3ec4b1 tests: Always use forward slashes for paths
This is more consistent and fixes run_micropython on windows as it uses
forward slahses to compare paths
2015-08-08 12:35:27 +01:00
Tom Soulanille
89852d38ef run-tests: Test REPL emacs keys, but only if present.
Uses cmdline/repl_emacs_check.py to check for presence of emacs keys in
repl before doing full feature test.
2015-08-06 00:03:44 +01:00
Damien George
526dd54252 tests: Add test for pyboard SPI in slave mode, recv with no master.
See PR #1414.
2015-08-05 23:47:57 +01:00
Damien George
9a2913ed1c py/objlist: Make list += accept all arguments and add test. 2015-08-02 20:53:54 +01:00
Tom Soulanille
3dd0b69e46 run-tests: Use PTY when running REPL tests. 2015-07-26 15:23:11 +01:00
Daniel Campora
cd14188bc8 tools: Add telnet support to pyboard.py.
The adapter class "TelnetToSerial" is used to access the Telnet
connection using the same API as with the serial connection. The
function pyboard.run-test() has been removed to made the module
generic and because this small test is no longer needed.
2015-07-26 14:02:34 +01:00
Damien George
3900fed849 tests: Skip parser test if "compile" builtin is not available. 2015-07-24 22:37:26 +01:00
Damien George
96f0dd3cbc py/parse: Fix handling of empty input so it raises an exception. 2015-07-24 15:05:56 +00:00
Damien George
d241c2a592 py/lexer: Raise SyntaxError when str hex escape sequence is malformed.
Addresses issue #1390.
2015-07-23 23:20:37 +01:00
Damien George
e45c1dbd6f py: Allow viper functions to take up to 4 arguments.
Addresses issue #1380.
2015-07-23 14:11:29 +01:00
Delio Brignoli
32aba40830 py: Implement memoryview slice assignment.
Adds ability to do "memcpy" with memoryview objects, such as:
m1[0:3] = m2[2:5].
2015-07-20 15:53:22 +01:00
Sebastian Plamauer
1e8ca3a3cf modbuiltins: Implement round() to precision. 2015-07-19 21:49:44 +03:00
Paul Sokolovsky
354d17523f modmachine: Implement physical memory access using /dev/mem (Linux, etc).
This requires root access. And on recent Linux kernels, with
CONFIG_STRICT_DEVMEM option enabled, only address ranges listed in
/proc/iomem can be accessed. The above compiled-time option can be
however overriden with boot-time option "iomem=relaxed".

This also removed separate read/write paths - there unlikely would
be a case when they're different.
2015-07-08 11:37:23 +03:00
Damien George
68e8b595de tests: Catch ValueError instead of any exception to properly test error. 2015-07-06 11:35:08 +00:00
Galen Hazelwood
616986a5f3 extmod: Add a2b_base64 and b2a_base64 functions to ubinascii. 2015-07-04 12:26:52 +03:00
Paul Sokolovsky
9896314f5b tests: Add test for relative import without package context. 2015-06-27 00:40:22 +03:00
Damien George
59fba2d6ea py: Remove mp_load_const_bytes and instead load precreated bytes object.
Previous to this patch each time a bytes object was referenced a new
instance (with the same data) was created.  With this patch a single
bytes object is created in the compiler and is loaded directly at execute
time as a true constant (similar to loading bignum and float objects).
This saves on allocating RAM and means that bytes objects can now be
used when the memory manager is locked (eg in interrupts).

The MP_BC_LOAD_CONST_BYTES bytecode was removed as part of this.

Generated bytecode is slightly larger due to storing a pointer to the
bytes object instead of the qstr identifier.

Code size is reduced by about 60 bytes on Thumb2 architectures.
2015-06-25 14:42:13 +00:00
Damien George
e44c1d3ace tests: Split out json float tests to separate files. 2015-06-25 10:50:00 +01:00
Daniel Campora
186b355b28 tests: Add support for the WiPy in run-tests script.
The --pyboard param has been replaced by --target which defaults to
'unix'. Possible values at this moment are 'unix', 'pyboard' and
'wipy'. Now is also possible to select the baud rate of the serial
device when calling the script.
2015-06-25 10:45:25 +01:00
Daniel Campora
4af5424242 tests: Adapt misc/features.py tests for ports without floating point. 2015-06-24 17:53:29 +01:00
Daniel Campora
d709622bd2 tests: Adapt basics/memoryerror.py for ports with lower heap sizes. 2015-06-24 15:25:59 +02:00
Paul Sokolovsky
a06c38b486 tests: Add testcase for open(..., "a"). 2015-06-21 00:05:09 +03:00
Damien George
06593fb0f2 py: Use a wrapper to explicitly check self argument of builtin methods.
Previous to this patch a call such as list.append(1, 2) would lead to a
seg fault.  This is because list.append is a builtin method and the first
argument to such methods is always assumed to have the correct type.

Now, when a builtin method is extracted like this it is wrapped in a
checker object which checks the the type of the first argument before
calling the builtin function.

This feature is contrelled by MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG and
is enabled by default.

See issue #1216.
2015-06-20 16:39:39 +01:00
Damien George
f6518a7bd5 tests: Check that machine module exists and print SKIP if it doesn't. 2015-06-15 23:35:15 +01:00
Damien George
e9ce00d874 py: Implement divmod for mpz bignum. 2015-06-13 23:38:28 +01:00
Damien George
c5029bcbf3 py: Add MP_BINARY_OP_DIVMOD to simplify and consolidate divmod builtin. 2015-06-13 23:36:30 +01:00
Damien George
6f49520042 py: Implement second arg for math.log (optional value for base). 2015-06-13 22:35:25 +01:00
Damien George
7ed58cb663 py: Support unicode (utf-8 encoded) identifiers in Python source.
Enabled simply by making the identifier lexing code 8-bit clean.
2015-06-09 10:58:07 +00:00
Damien George
6e56bb623c py: Fallback to stack alloca for Python-stack if heap alloc fails.
If heap allocation for the Python-stack of a function fails then we may
as well allocate the Python-stack on the C stack.  This will allow to
run more code without using the heap.
2015-06-08 22:07:27 +01:00
Paul Sokolovsky
1679696612 moductypes: Swap address and descriptor args in constructor.
Now address comes first, and args related to struct type are groupped next.
Besides clear groupping, should help catch errors eagerly (e.g. forgetting
to pass address will error out).

Also, improve args number checking/reporting overall.
2015-06-06 22:57:54 +03:00
Damien George
031278f661 unix: Allow to cat a script into stdin from the command line.
See issue #1306.
2015-06-04 23:42:45 +01:00
Damien George
567b349c2b py: Implement native multiply operation in viper emitter. 2015-06-04 14:00:29 +00:00
Damien George
4d9cad180d py: Implement implicit cast to obj for viper load/store index/value.
This allows to do "ar[i]" and "ar[i] = val" in viper when ar is a Python
object and i and/or val are native viper types (eg ints).

Patch also includes tests for this feature.
2015-06-04 11:52:16 +01:00
Damien George
80f638fe19 tests: Add test for recursive iternext stack overflow. 2015-06-03 22:41:06 +01:00
Damien George
a16715ac62 tests: Add special tests to test mp_printf function to improve coverage. 2015-05-28 14:25:07 +00:00