Commit Graph

303 Commits

Author SHA1 Message Date
Paul Sokolovsky ad1bac63f7 tests/string-format: Add test for formatting ints with float format.
Fail currently.
2014-04-02 20:41:34 +03:00
Damien George 929a675a3d Change test scripts to use python3; bytecode tests use python3.4.
I upgraded to Python 3.4.0, so needed to make these changes.  Hopefully
the tests still run with Python 3.3.x (the scripts use python3 so are
agnostic as to the subversion).

Bytecode tests are tightly coupled to the Python version, and now some
fail against Python 3.4.
2014-04-02 15:31:39 +01:00
Damien George 10e21b9770 Add more tests. 2014-04-02 14:23:04 +01:00
Damien George 93b7faa29a py: Factor out static/class method unwrapping code; add tests. 2014-04-02 14:13:26 +01:00
Damien George e4c834fc1e Add a test. 2014-04-02 13:32:37 +01:00
Damien George 4881566874 py: Add support for sep and end keywords in print. 2014-04-02 10:34:44 +01:00
Damien George 084ef373fb py: Fix math.{ceil,floor,trunc} to return int. 2014-04-01 21:21:50 +01:00
Dave Hylands 7adc2e0431 Turn off full tests in string-format.py
Add some basic coverage tests
2014-04-01 08:10:02 -07:00
Paul Sokolovsky 51413c8cb6 tests: Add test for implicit float to int conversion (not allowed!) 2014-04-01 13:50:16 +03:00
Dave Hylands baf6f14deb Enhance str.format support
This adds support for almost everything (the comma isn't currently
supported).

The "unspecified" type with floats also doesn't behave exactly like
python.

Tested under unix with float and double
Spot tested on stmhal
2014-04-01 01:17:33 -07:00
Damien George e44d26ae0c py: Implement __getattr__.
It's not completely satisfactory, because a failed call to __getattr__
should not raise an exception.

__setattr__ could be implemented, but it would slow down all stores to a
user created object.  Need to implement some caching system.
2014-03-31 22:57:56 +01:00
Paul Sokolovsky 4db727afea objstr: Very basic implementation of % string formatting operator. 2014-03-31 21:20:52 +03:00
Damien George 18a6eb9e13 Merge branch 'master' of github.com:micropython/micropython 2014-03-31 18:03:52 +01:00
Damien George 3ff2d03891 py: Fix bug in optimised for .. range.
Don't store final, failing value to the loop variable.  This fix also
makes for .. range a bit more efficient, as it uses less store/load
pairs for the loop variable.
2014-03-31 18:02:22 +01:00
Paul Sokolovsky 183faa3b13 tests: Add testcase for multiple inheritance. 2014-03-31 19:46:35 +03:00
Paul Sokolovsky 6ded55a61f py: Properly implement divide-by-zero handling.
"1/0" is sacred idiom, the shortest way to break program execution
(sys.exit() is too long).
2014-03-31 02:23:57 +03:00
Damien George 0aa4379543 Merge pull request #399 from pfalcon/gen-defargs
objgenerator: Handle default args to generator functions.
2014-03-30 21:51:49 +01:00
Paul Sokolovsky f7eaf605c0 py: Fix "TypeError: 'iterator' object is not iterable", doh. 2014-03-30 23:37:24 +03:00
Paul Sokolovsky f39d3b93da py: Implement support for generalized generator protocol.
Iterators and ducktype objects can now be arguments of yield from.
2014-03-30 23:30:16 +03:00
Damien George 230fec77d7 py: Implement positional and keyword args via * and **.
Extends previous implementation with * for function calls to * and **
for both function and method calls.
2014-03-30 21:21:24 +01:00
Paul Sokolovsky 7fafb28f6d objgenerator: Handle default args to generator functions.
Addresses #397.
2014-03-30 20:25:19 +03:00
Paul Sokolovsky 55ca075cab vm: Implement CALL_FUNCTION_VAR opcode (foo(*(1, 2, 3))). 2014-03-30 17:47:16 +03:00
Damien George 010043caaf Add "tracing" to try-reraise2.py test. It now fails. 2014-03-30 00:39:15 +00:00
Paul Sokolovsky 0c904df8e6 vm: Save current active exception on opening new try block.
Required to reraise correct exceptions in except block, regardless if more
try blocks with active exceptions happen in the same except block.

P.S. This "automagic reraise" appears to be quite wasteful feature of Python
- we need to save pending exception just in case it *might* be reraised.
Instead, programmer could explcitly capture exception to a variable using
"except ... as var", and reraise that. So, consider disabling argless raise
support as an optimization.
2014-03-30 01:01:35 +02:00
Paul Sokolovsky d109676ec0 py: Reraising exception possible only in except block. 2014-03-29 23:18:59 +02:00
Damien George 21a07dc50f Merge pull request #389 from pfalcon/with-statement
With statement implementation
2014-03-29 14:00:03 +00:00
Damien George da51a399cf Merge pull request #383 from pfalcon/yield-from
Implement "yield from"
2014-03-29 12:18:14 +00:00
Damien George 75f71584a6 tests: Remove unimplemented exceptions from testing. 2014-03-29 11:43:00 +00:00
Paul Sokolovsky e7286ef2c7 tests: Add "with" statement testcases. 2014-03-29 04:39:31 +02:00
Paul Sokolovsky 3c2b2acd8c tests: Add testcases for yield from. 2014-03-28 02:50:56 +02:00
Damien George d6f9434091 Merge pull request #381 from pfalcon/closure-defargs
py: Support closures with default args.
2014-03-26 23:09:14 +00:00
Paul Sokolovsky e9137b94f2 py: Implement getattr() builtin. 2014-03-27 00:11:36 +02:00
Paul Sokolovsky 2447a5b582 py: Support closures with default args. 2014-03-26 23:17:44 +02:00
Damien George 66eaf84b8c py: Replace mp_const_stop_iteration object with MP_OBJ_NULL. 2014-03-26 19:27:58 +00:00
Damien George 688e220d26 Merge pull request #379 from pfalcon/reraise
vm: Implement raise statement w/o args (reraising last exception).
2014-03-26 18:59:15 +00:00
Damien George 752ba554cc Merge branch 'gen-close-ret-val' of github.com:pfalcon/micropython into pfalcon-gen-close-ret-val 2014-03-26 18:46:06 +00:00
Paul Sokolovsky c403076ef8 vm: Implement raise statement w/o args (reraising last exception). 2014-03-26 17:32:02 +02:00
Paul Sokolovsky 962b1cd1b1 objgenerator: Implement return with value and .close() method.
Return with value gets converted to StopIteration(value). Implementation
keeps optimizing against creating of possibly unneeded exception objects,
so there're considerable refactoring to implement these features.
2014-03-26 15:40:58 +02:00
Damien George 681d0a9ca7 Merge pull request #370 from xbe/str-rfind
py/objstr.c: Implement str.rfind() and add tests for it, refactor find_subbytes().
2014-03-25 15:51:15 +00:00
Damien George ffb5cfc8d8 py: Removed some unnecessary exception objects.
They still exist in commented-out form in objexcept.c if they are ever
needed.
2014-03-25 14:29:40 +00:00
Paul Sokolovsky 9512e9e817 objexcept: Add "args" exception attribute, as well as StopIteration.value. 2014-03-25 01:42:01 +02:00
Paul Sokolovsky 7f8b31345b rt_load_method(): Add missing qstr_str() when getting type name. 2014-03-25 01:39:10 +02:00
xbe 17a5a83fb4 Implement str.rfind() and add tests for it. 2014-03-24 01:00:00 -07:00
Paul Sokolovsky f909034400 py: Implement support for "except Exception as var" clause.
For this, needed to implement DELETE_NAME bytecode (because var bound
in except clause is automatically deleted at its end).
http://docs.python.org/3/reference/compound_stmts.html#except :
"When an exception has been assigned using as target, it is cleared at
the end of the except clause."
2014-03-23 22:00:04 +02:00
Paul Sokolovsky fd232c3ef7 run-tests: Dump output of failing tests to files again.
This was a long-standing regression from converting script from sh to python.
2014-03-23 01:58:07 +02:00
Damien George a6d53188b7 Merge pull request #359 from rjdowdall/master
Fixed some math functions and added more exceptions.
2014-03-22 20:26:17 +00:00
Rachel Dowdall 56402796d8 Fixed floor division on mp ints and small ints. Added a floordivide test case. 2014-03-22 20:19:24 +00:00
Rachel Dowdall cde8631f15 Fixed modulo operator on ints and mp ints to agree with python. Added intdivmod.c and tests/basics/modulo.py. 2014-03-22 17:29:27 +00:00
Paul Sokolovsky 48caa09a9d objgenerator: Implement .throw() method to throw exceptions into generator. 2014-03-22 17:55:42 +02:00
Paul Sokolovsky 61fd20f168 objgenerator: Implement throwing exceptions out of generator. 2014-03-22 17:55:42 +02:00
Paul Sokolovsky c0abc28aa1 objgenerator: Keep exception stack within generator object, like value stack.
This is required to properly handle exceptions across yields.
2014-03-22 17:55:42 +02:00
Rachel Dowdall 721c55dced Added exception hierarchy except for OSError and UnicodeError (requires arguments). Comment out the errors that aren't needed if memory becomes an issue. 2014-03-22 15:28:16 +00:00
Rachel Dowdall 249b9c761d Fixed broken math functions that return bool and added some more. 2014-03-22 14:39:33 +00:00
Paul Sokolovsky 1ecea7c753 py: Make 'bytes' be a proper type, support standard constructor args. 2014-03-22 00:07:04 +02:00
Paul Sokolovsky 42901554db objint_longlong: Add regression test for improper inplace op implementation. 2014-03-22 00:04:04 +02:00
Damien George e3e7c2bafb Merge pull request #351 from xbe/str-partition
Implement str.partition and add tests for it.
2014-03-21 20:19:30 +00:00
xbe 4504ea8007 Implement str.rpartition and add tests for it. 2014-03-21 02:58:09 -07:00
xbe 613a8e3edf Implement str.partition and add tests for it. 2014-03-21 02:57:18 -07:00
Damien George 1609f85582 Rename test so that it doesn't clash with Python math module. 2014-03-20 23:41:04 +00:00
Rachel Dowdall 5a14a1d690 Added various simple functions to math module. 2014-03-20 21:26:51 +00:00
Damien George 2d7ff07175 py: Add mpz modulo operation. 2014-03-20 16:28:41 +00:00
Paul Sokolovsky 51bbf6a006 Implement support for __str__ and __repr__ special methods in classes. 2014-03-16 15:18:22 +02:00
Damien George 536dde254b py: In string.count, handle case of zero-length needle. 2014-03-13 22:07:55 +00:00
xbe c5d70ba48b Fix issues in str.count implementation.
See pull request #343.
2014-03-13 00:33:07 -07:00
xbe 9e1e8cd642 Implement str.count and add tests for it.
Also modify mp_get_index to accept:
1. Indices that are or evaluate to a boolean.
2. Slice indices.
Add tests for these two cases.
2014-03-12 22:57:16 -07:00
Damien George b068b21742 Add more tests for multi-precision integers. 2014-03-12 15:39:51 +00:00
Damien George 25f5a30e73 py: Fix overriding of default arguments.
Addresses issue #327.
2014-03-03 23:25:08 +00:00
Paul Sokolovsky e74f52b76c namedtuple: Inherit unary/binary ops from tuple base class. 2014-03-03 11:42:53 +08:00
Paul Sokolovsky d08fd68664 Add basic collections.namedtuple implementation. 2014-03-03 11:42:53 +08:00
Damien George 06201ff3d6 py: Implement bit-shift and not operations for mpz.
Implement not, shl and shr in mpz library.  Add function to create mpzs
on the stack, used for memory efficiency when rhs is a small int.
Factor out code to parse base-prefix of number into a dedicated function.
2014-03-01 19:50:50 +00:00
Paul Sokolovsky 135002a086 Add basic super() test. 2014-02-22 20:25:05 +02:00
Paul Sokolovsky 56e5ef203b parse: Refactor parse node encoding to support full range of small ints.
Based on suggestion by @dpgeorge at
https://github.com/micropython/micropython/pull/313
2014-02-22 16:39:45 +02:00
Paul Sokolovsky fb7f94392d import: Implement "from pkg.mod import sym" syntax properly.
http://docs.python.org/3.3/library/functions.html#__import__ :
"When the name variable is of the form package.module, normally, the
top-level package (the name up till the first dot) is returned, not
the module named by name. However, when a non-empty fromlist argument
is given, the module named by name is returned."
2014-02-20 00:37:12 +02:00
Paul Sokolovsky ac2e28c654 Support passing positional args as keywords to bytecode functions.
For this, record argument names along with each bytecode function. The code
still includes extensive debug logging support so far.
2014-02-16 18:36:33 +02:00
Paul Sokolovsky 1b694c082e Rename fun-kwargs.py -> fun-kwvarargs.py to free up slot for simple kw test. 2014-02-16 15:55:06 +02:00
Paul Sokolovsky 91ba7a54c5 builtinimport: Get the basic (and only basic) package imports work. 2014-02-16 02:55:46 +02:00
Damien George e5d371b545 py: Pass keyword arguments to byte code. 2014-02-16 00:17:42 +00:00
Damien George 2e482cdb7b py: Implement *vargs support.
Addresses issue #295.
2014-02-16 00:01:29 +00:00
Damien George c8f78bc280 py: VM never throws an exception, instead returns a status and value.
Addresses issue #290, and hopefully sets up things to allow generators
throwing exceptions, etc.
2014-02-15 22:55:00 +00:00
Paul Sokolovsky 8ac72b9d00 Add testcase for failing namespace switch throwing exception from a module.
Issue #290. This currently fails, to draw attention to the issue.
2014-02-15 12:44:29 +02:00
Paul Sokolovsky e7299b5296 Add testcase for "from module import *". 2014-02-14 00:30:36 +02:00
Paul Sokolovsky b2e8c52298 Add testcase for "from module import sym". 2014-02-14 00:30:36 +02:00
Paul Sokolovsky 2aa217b974 Implement full arg handling for exec(). 2014-02-13 00:36:54 +02:00
Paul Sokolovsky 8d90a382cf basics/enumerate.py: Don't turn enumerate test into heap test.
With range(10000), doesn't fit into 128K heap.
2014-02-11 15:34:32 +02:00
Damien George e8d2c3cf6c Merge pull request #267 from pfalcon/func-ret-ann
Clean up handling of function return type annotation.
2014-02-10 21:59:11 +00:00
Paul Sokolovsky ac0134d427 Factor out mp_seq_count_obj() and implement tuple.count(). 2014-02-10 07:13:32 +02:00
Paul Sokolovsky 624eff6a8a Implement tuple.index(). 2014-02-10 07:13:32 +02:00
Paul Sokolovsky 2f0b026a44 Clean up handling of function return type annotation. 2014-02-10 02:04:26 +02:00
Paul Sokolovsky f7c2410e65 Implement tuple multiplication. 2014-02-08 23:19:48 +02:00
Paul Sokolovsky ee4aaf7cdd Implement tuple addition. 2014-02-08 23:17:51 +02:00
Paul Sokolovsky e827e98a6f Implement tuple comparison. 2014-02-08 22:56:36 +02:00
Paul Sokolovsky 1e19b24ea0 io.File, socket types: Add fileno() method.
Implementation is duplicated, but tolerate this for now, because there's
no clear idea how to de-dup it.
2014-02-08 21:20:32 +02:00
Paul Sokolovsky 9fce77c993 Add more finally + break/continue testcases. 2014-02-06 03:27:39 +02:00
Paul Sokolovsky 3c95ba7e4e Add additional testcase for finally/return. 2014-02-06 03:20:56 +02:00
Damien George 35e2a4e6bb py: Add built-in super. 2014-02-05 00:51:47 +00:00
Paul Sokolovsky 00c0b8a989 Fix unstable case in builtin_id.py test. 2014-02-04 00:50:22 +02:00
Damien George 93d004f4b0 Merge branch 'xbe-master' 2014-02-02 13:38:41 +00:00
Damien George 330cf6d04a Change id to return signed integer. 2014-02-02 13:38:21 +00:00
Paul Sokolovsky 87e85b7dc7 Implement str/bytes rich comparisons. 2014-02-02 08:58:16 +02:00
xbe 0ebf8534ab Implement and add tests for the id() builtin function. 2014-02-01 19:00:41 -08:00