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
Damien George
5b5562c1d1
py: Fix stack underflow with optimised for loop.
2014-05-31 17:59:11 +01:00
Damien George
049a01d148
tests: Add another test for break-from-for-loop.
2014-05-31 16:56:15 +01:00
Kim Bauters
a3f4b83018
add methods isspace(), isalpha(), isdigit(), isupper() and islower() to str
2014-05-31 07:30:57 +01:00
Paul Sokolovsky
ccd0e0afcd
tests: Add test for break in for.
...
For #635 / 25c84643b6
.
2014-05-31 00:43:41 +03:00
Paul Sokolovsky
8827682b35
objstr: *strip(): If nothing is stripped, don't create dup string.
2014-05-30 03:15:17 +03:00
Paul Sokolovsky
bcdffe53c6
objstr: *strip(): Fix handling of one-char subject strings.
2014-05-30 03:15:17 +03:00
Damien George
f55cf10101
py: Implement bignum '&' with negatives on lhs and rhs.
...
Needs proper coverage testing. Doesn't implement -ve & -ve.
Addresses issue #611 .
2014-05-29 15:01:49 +01:00
stijn
8ac3b578e5
tests: Add argument to allow specifying which directories to test
2014-05-28 14:33:30 +02:00
Paul Sokolovsky
d07bf029b7
tests: Add small testcase for 3-arg slices.
2014-05-26 02:02:47 +03:00
Paul Sokolovsky
5fd5af98d0
objlist: Implement support for arbitrary (3-arg) slices.
2014-05-25 22:12:56 +03:00
Paul Sokolovsky
2705f4c782
objlist: Implement growing slice assignment.
...
This means that complete slice operations are supported for lists (but not
for bytearray's and array.array's).
2014-05-25 02:36:12 +03:00
Paul Sokolovsky
d098c6bf85
objstr: Implement .endswith().
2014-05-24 22:46:51 +03:00
Paul Sokolovsky
806ea1f6ca
py: Initial attempts to actually allow implementing __new__ in Python.
...
Caveat is that __new__ should recurse to base class __new__, and ultimately,
object.__new__ is what handles instance allocation.
2014-05-22 00:32:00 +03:00
Paul Sokolovsky
a8408a8abe
objtype: super: Fall back to "object" lookup as last resort.
...
Also, define object.__init__() (semantically empty, purely CPython compat
measure). Addresses #520 .
2014-05-21 22:27:03 +03:00
Damien George
0fd01683c6
Merge pull request #607 from Anton-2/osx-clang
...
Allow compilation of unix port under clang on OS X
2014-05-21 19:51:05 +01:00
Paul Sokolovsky
66ab571cca
tests: Update subclass-native2.py for __new__/__init__ refactor.
...
Now case of subclassing tuple works, and list is broken, see comments.
2014-05-19 21:56:07 +03:00
Paul Sokolovsky
c18ef2a9dd
objstr: startswith(): Accept optional "start" arg.
2014-05-15 21:33:18 +03:00
Paul Sokolovsky
70328e419a
py: Implement more complete bytes comparison handling.
2014-05-15 20:58:40 +03:00
Paul Sokolovsky
ad3baec12f
sequence: Fix yet another case of improper sequence comparison.
...
This time, in mp_seq_cmp_bytes(). How many more cases are still lurking?
2014-05-15 19:09:06 +03:00
Paul Sokolovsky
2a27365854
objstr.c: Partial implementation of .rsplit().
...
sep=None is TODO.
2014-05-14 02:42:20 +03:00
Paul Sokolovsky
7074f25768
tests/int-long.py: Try to expose issue with recent "&" optimization.
2014-05-13 08:24:54 +03:00
Damien George
561e425903
py: Fix bug in mpz_and function.
...
Addresses issue #610 .
2014-05-12 23:27:29 +01:00
Paul Sokolovsky
df94b717b4
modstruct: Implement count specifier for strings (e.g. "100s").
...
Infra for counts of other types is there, need last mile to be implemented.
2014-05-12 23:45:50 +03:00
Antonin ENFRUN
1b901c320b
tests: create result file for test/basics/memoryerror.py .
...
On Mac OS "python3 test/basics/memoryerror.py" never runs out of memory, the process is frozen by the os before.
2014-05-12 00:13:10 +02:00
Paul Sokolovsky
5ebd5f0f19
objstr: Slice indexing: support bytes properly.
2014-05-11 21:22:59 +03:00
Paul Sokolovsky
bfb8819c0c
objstr: Make .split() support bytes.
2014-05-11 21:17:28 +03:00
Paul Sokolovsky
5e5d69b35e
objstr: Make .join() support bytes.
2014-05-11 21:13:01 +03:00
Paul Sokolovsky
ff30666c69
py: Add basic implementation of hasattr() function.
2014-05-11 20:51:30 +03:00
Damien George
1d34e32431
py: frozenset() creates an empty frozenset.
2014-05-11 18:28:48 +01:00
Damien George
c3dcb590b8
Merge pull request #603 from stinos/windows-tests-newline
...
tests: Fix handling of newlines from expected output files on windows
2014-05-11 15:03:57 +01:00
Paul Sokolovsky
eea0118654
py: Give up and make mp_obj_str_get_data() deal with bytes too.
...
This is not fully correct re: error handling, because we should check that
that types are used consistently (only str's or only bytes), but magically
makes lot of functions support bytes.
2014-05-11 13:51:24 +03:00
stijn
a4dbc73e8a
tests: Fix handling of newlines from expected output files
2014-05-11 12:45:02 +02:00
Paul Sokolovsky
b2d4fc06fc
objstr: Make *strip() accept bytes.
2014-05-11 13:17:29 +03:00
Paul Sokolovsky
ce6c10172b
tests: Really fix import.
2014-05-11 03:45:42 +03:00
Paul Sokolovsky
b4acd028b6
tests: Fix import.
2014-05-11 03:40:32 +03:00
Paul Sokolovsky
ea9708092e
objtuple: Go out of the way to support comparison of subclasses.
...
Two things are handled here: allow to compare native subtypes of tuple,
e.g. namedtuple (TODO: should compare type too, currently compared
duck-typedly by content). Secondly, allow user sunclasses of tuples
(and its subtypes) be compared either. "Magic" I did previously in
objtype.c covers only one argument (lhs is many), so we're in trouble
when lhs is native type - there's no other option besides handling
rhs in special manner. Fortunately, this patch outlines approach with
fast path for native types.
2014-05-11 03:33:19 +03:00
Paul Sokolovsky
9511f60f01
py: Don't try to "bind" types store as attributes of objects.
...
This was hit when trying to make urlparse.py from stdlib run. Took
quite some time to debug.
TODO: Reconsile bound method creation process better, maybe callable is
to generic type to bind at all?
2014-05-11 03:33:19 +03:00
Paul Sokolovsky
69f3eb2c96
objstr: Make .[r]partition() work with bytes.
2014-05-11 03:33:19 +03:00
Paul Sokolovsky
3f8d34ca83
objlist: Support list slice deletion.
2014-05-10 23:03:30 +03:00
Paul Sokolovsky
94d8246272
objlist: Implement non-growing slice assignment.
...
Slice value to assign can be only a list so far too.
2014-05-10 22:24:31 +03:00
Paul Sokolovsky
1a7403bb74
objtype: Implement ->getiter() method for instances.
...
Includes support for native bases.
2014-05-10 21:26:08 +03:00
Paul Sokolovsky
7067d69bcc
objnamedtuple: Support iteration.
2014-05-10 21:26:07 +03:00
Paul Sokolovsky
6913521911
objstr: Implement .lower() and .upper().
2014-05-10 19:49:07 +03:00
Paul Sokolovsky
37b0f33545
objset: Add frozenset tests, skippable if frozenset not available.
2014-05-10 16:56:21 +03:00
Paul Sokolovsky
43d4a6fa31
run-tests: Add support for skipping tests.
...
MicrpPython test should print single "SKIP" line for test to be skipped.
2014-05-10 16:56:21 +03:00
Paul Sokolovsky
d86020ac4f
objtype: Don't treat inheritance from "object" as from native type.
...
"object" type in MicroPython currently doesn't implement any methods, and
hopefully, we'll try to stay like that for as long as possible. Even if we
have to add something eventually, look up from there might be handled in
adhoc manner, as last resort (that's not compliant with Python3 MRO, but
we're already non-compliant). Hence: 1) no need to spend type trying to
lookup anything in object; 2) no need to allocate subobject when explicitly
inheriting from object; 3) and having multiple bases inheriting from object
is not a case of incompatible multiple inheritance.
2014-05-10 16:56:20 +03:00
Damien George
04b7cc4df0
stmhal: Fix setting of RTC: was BCD now BIN encoded.
...
Addresses issue #592 .
2014-05-10 11:56:58 +01:00
Paul Sokolovsky
6e8085b425
py: Fix base "detection" for int('0<hexdigit>', 16).
2014-05-10 04:45:15 +03:00
Paul Sokolovsky
7b0f9a7d9b
bytes: Implement comparison and other binary operations.
...
Should support everything supported by strings.
2014-05-10 04:45:02 +03:00
Damien George
ffae48d750
py, compiler: Add basic support for A=const(123).
...
You can now do:
X = const(123)
Y = const(456 + X)
and the compiler will replace X and Y with their values.
See discussion in issue #266 and issue #573 .
2014-05-08 15:58:39 +00:00
Damien George
d509ac25f9
py: Fix stack access in thumb native emitter.
2014-05-07 23:27:45 +01:00
Paul Sokolovsky
69cbec4afb
tests/bench: Add testcase for positional/kwargs to enumerate().
...
Inspired by discussion in #577 . So, in this case of builtin function,
passing args by keyword has less than 1% overhead.
2014-05-07 22:34:06 +03:00
Paul Sokolovsky
2a05f05f44
tests/bench: Add tests for various ways to pass function args.
...
Passing 3 args with keywords is for example 50% slower than via positional
args.
2014-05-07 22:34:04 +03:00
Paul Sokolovsky
1695151267
tests/bench: Add variation on loop_count/while_down_ne test.
2014-05-07 22:34:04 +03:00
Paul Sokolovsky
6638ea9ca3
tests/bench: Add testcases for lookup in 5-el instance and namedtuple.
...
... and we have not that bad mapping type after all - lookup time is ~ the
same as in one-attr instance. My namedtuple implementation on the other
hand degrades awfully.
So, need to rework it. First observation is that named tuple fields are
accessed as attributes, so all names are interned at the program start.
Then, really should store field array as qstr[], and do quick 32/64 bit
scan thru it.
2014-05-07 22:34:00 +03:00
Paul Sokolovsky
52b25293e2
tests/bench: Time namedtuple field access.
...
That's higher than instance field access - behold the power of hashing.
2014-05-07 22:33:37 +03:00
Damien George
9102af6afb
tests: Add a test for native code on pyboard.
2014-05-07 18:55:31 +01:00
Damien George
c4ccb078a5
tests: Add inline assembler test for pyboard.
2014-05-07 18:31:14 +01:00
Damien George
491cbd6a7c
py: Add keyword arg support to enumerate constructor.
...
Need to have a policy as to how far we go adding keyword support to
built ins. It's nice to have, and gets better CPython compatibility,
but hurts the micro nature of uPy.
Addresses issue #577 .
2014-05-06 16:38:54 +00:00
Paul Sokolovsky
f01fa458d8
tests/bench/var: Add tests for class/instance var access.
...
Also compared with method abstraction for accessing instance vars -
it's more than 3 times slower than accessing var directly.
2014-05-05 02:17:13 +03:00
Paul Sokolovsky
aaff82afe5
tests: Add framework for comparative benchmarking.
...
Motivation is optimizing handling of various constructs as well as
understanding which constructs are more efficient in MicroPython.
More info: http://forum.micropython.org/viewtopic.php?f=3&t=77
Results are wildly unexpected. For example, "optimization" of range
iteration into while loop makes it twice as slow. Generally, the more
bytecodes, the slower the code.
2014-05-05 01:24:16 +03:00
Damien George
cda363a036
tests, pyb: Add 'import pyb' when needed.
2014-05-04 12:40:51 +01:00
Damien George
d5f5b2f766
py, stream: Implement readlines for a stream.
2014-05-03 22:01:32 +01:00
Damien George
41f768f3f3
tests: Add a suite of tests specifically for the pyboard.
...
In tests/pyb is now a suite of tests that tests the pyb module on the
pyboard. They include expected output files because we can't run
CPython on the pyboard to compare against.
run-tests script has now been updated to allow pyboard tests to be run.
Just pass the option --pyboard. This runs all basic, float and pyb
tests. Note that float/math-fun.py currently fails because not all math
functions are implemented in stmhal/.
2014-05-03 16:43:27 +01:00
Paul Sokolovsky
e276753b45
tests: Add testcases for catching user Exception subclasses.
2014-05-02 02:31:30 +03:00
Paul Sokolovsky
d8351ca8a0
objtype: .print() Exception instances in adhoc way.
...
This is ugly, just as expected.
2014-05-02 02:00:47 +03:00
Andrew Scheller
37067666ee
Fix the builtin min() and max() functions (and add tests).
...
Fixes #539
2014-05-01 21:21:43 +01:00
Paul Sokolovsky
c963310123
tests: Add test for calling inherited native method on subclass.
2014-04-30 02:17:45 +03:00
Paul Sokolovsky
5a12137c3e
tests: Add test for accessing attribute of inherited native type.
2014-04-29 20:31:13 +03:00
Paul Sokolovsky
4f46c441ef
tests: Add basic tests for subclassing native types and using special methods.
...
Even of these, some features do not yet work as expected.
2014-04-29 20:31:13 +03:00
Damien George
186e463a9e
py: Fix bug in map lookup of interned string vs non-interned.
...
Had choice of either interning or forcing full equality comparison, and
chose latter. See comments in mp_map_lookup.
Addresses issue #523 .
2014-04-28 12:11:57 +01:00
Damien George
2827d62e8b
py: Implement keyword-only args.
...
Implements 'def f(*, a)' and 'def f(*a, b)', but not default
keyword-only args, eg 'def f(*, a=1)'.
Partially addresses issue #524 .
2014-04-27 15:50:52 +01:00
Paul Sokolovsky
cb9dc086a3
modio: Implement io.StringIO class.
2014-04-26 20:26:14 +03:00
Paul Sokolovsky
881078403e
objstr: Implement .lstrip() & .rstrip().
...
Share code with .strip(). TODO: optimize .rstrip().
2014-04-26 06:20:08 +03:00
Paul Sokolovsky
755565d2cb
py: Support instance __call__ method.
2014-04-25 21:17:42 +03:00
Paul Sokolovsky
efc36f0cea
test/class-super: Expose super() breakage.
2014-04-19 21:54:06 +03:00
Paul Sokolovsky
d6e12723ed
objarray: Implement slice subscription.
2014-04-19 20:06:57 +03:00
Paul Sokolovsky
6204460461
modstruct: Initial implementation of struct.pack().
2014-04-19 03:22:08 +03:00
Paul Sokolovsky
83eba5dec5
sequence: Fix glaring bug in sequence comparison.
2014-04-18 21:42:54 +03:00