Commit Graph

293 Commits

Author SHA1 Message Date
Paul Sokolovsky
a985b4593d objint: Implement int.from_bytes() class method and .to_bytes() method.
These two are apprerently the most concise and efficient way to convert
int to/from bytes in Python. The alternatives are struct and array modules,
but methods using them are more verbose in Python code and less efficient
in memory/cycles.
2014-04-09 01:07:37 +03:00
Damien George
2b0091983f tests: Oops: fix del-attr. 2014-04-08 23:02:24 +01:00
Damien George
f4c9b33abf py: Remove DELETE_SUBSCR opcode, combine with STORE_SUBSCR.
This makes the runtime and object APIs more consistent.  mp_store_subscr
functionality now moved into objects (ie list and dict store_item).
2014-04-08 21:32:29 +01:00
Paul Sokolovsky
4dcb605ac4 py: Make bytearray a proper type. 2014-04-08 22:11:40 +03:00
Damien George
134c10e776 Merge branch 'master' of github.com:micropython/micropython 2014-04-08 18:29:50 +01:00
Damien George
495d781a36 py: implement UNPACK_EX byte code (for: a, *b, c = d) 2014-04-08 17:51:47 +01:00
Paul Sokolovsky
b9cf3d3730 bytearray: Support bytearray(int) constructor.
To create bytearray of given length.
2014-04-08 19:08:34 +03:00
Andrew Scheller
12968fb6b2 Display \r and \t escape codes in string repr 2014-04-08 02:42:50 +01:00
Dave Hylands
c4029e5079 Add string formatting support for longlong and mpz. 2014-04-07 11:38:45 -07:00
Damien George
1422865c99 Merge pull request #445 from lurch/test-sorted-sets
Modify set tests to print sorted sets directly
2014-04-07 13:15:33 +01:00
Andrew Scheller
1ff6011abc Modify set tests to print sorted sets directly
instead of creating temporary lists and sorting those in-place
2014-04-07 05:00:03 +01:00
Andrew Scheller
a1a9ab2b2c Add tests for sorted() function
and check that sorted(list) produces same output as list.sort()
2014-04-07 04:41:54 +01:00
Paul Sokolovsky
4d2238d2ce tests: Fix more tests which depend on order of elements in set. 2014-04-07 03:08:46 +03:00
Paul Sokolovsky
bd6f3d31d2 tests: Fix few tests which depend on order of elements in set. 2014-04-07 02:54:16 +03:00
Damien George
07e24a6294 tests: Fix tests with sets to print sorted set. 2014-04-07 00:42:09 +01:00
Damien George
ff715429ea py: Fix str.replace for case when arg 0 or 1 is empty string. 2014-04-07 00:39:13 +01:00
Paul Sokolovsky
b4dea46d8b tests: Fix few tests which depend on order of elements in dict.
With dict being unordered of course.
2014-04-06 21:31:42 +03:00
Paul Sokolovsky
e2adff3608 tests/dict2.py: Add combined test for dict(dict) and dict equality. 2014-04-06 21:31:42 +03:00
Damien George
cdd96dff2c py: Implement more features in native emitter.
On x64, native emitter now passes 70 of the tests.
2014-04-06 12:58:40 +01:00
Damien George
deed087e2c py: str.split: handle non-default separator. 2014-04-06 11:11:15 +01:00
Damien George
2a037408af tests: Add test to check issue #429. 2014-04-05 18:17:51 +01:00
Damien George
327a3e2faa Merge pull request #435 from dhylands/str-modulo-float
Allow floating point arguments with %d,i,u,o,x,X formats
2014-04-05 18:10:11 +01:00
Damien George
23419a2f8a Merge pull request #433 from pfalcon/getattr-3arg
py: Support 3-arg getattr() builtin (with default value).
2014-04-05 18:00:04 +01:00
Damien George
95004e5114 py: Fix delete operation on map/dict and set objects.
Hash table can now be completely full (ie now NULL entry) before a
resize is triggered.  Use sentinel value to indicate delete entry in the
table.
2014-04-05 17:17:19 +01:00
Dave Hylands
f81a49e464 Allow floating point arguments with %d,i,u,o,x,X formats 2014-04-05 08:26:51 -07:00
Damien George
b6ec51bbf0 tests: Add test for dict delete. It fails. 2014-04-05 13:26:00 +01:00
Paul Sokolovsky
bfb7d6a26d py: Support 3-arg getattr() builtin (with default value). 2014-04-05 13:34:02 +03:00
Paul Sokolovsky
438d504e27 objtype: Add equality test for type types. 2014-04-05 13:10:56 +03:00
Paul Sokolovsky
91cbe6033a py: Allow types to be hashable.
Quite natural to have d[int] = handle_int .
2014-04-05 12:51:58 +03:00
Paul Sokolovsky
a7752a4540 run-tests: Elaborate python3 command override capabilities. 2014-04-04 17:28:34 +03:00
Damien George
9b1599c663 Merge pull request #422 from dhylands/str-modulo
Str modulo
2014-04-04 12:37:52 +01:00
Damien George
28390340e5 tests: Make rge-sm.py use less memory (integration step increased).
In addition to memory allocation failure, other problem was that 10**17
was overflowing.  Now passes.
2014-04-04 11:15:54 +00:00
Damien George
6902eeda25 py: Add m_malloc_fail function to handle memory allocation error.
A malloc/realloc fail now throws MemoryError.
2014-04-04 10:52:59 +00:00
Paul Sokolovsky
072cf022e0 tests/file-with: Add testcase which failed for @dpgeorge.
Works on x86.
2014-04-04 12:15:39 +03:00
Dave Hylands
6756a37a77 Implements most of str.modulo
The alternate form for floating point doesn't work yet.
The %(name)s form doesn't work yet.
2014-04-03 23:55:02 -07:00
Damien George
4b34c76fd6 Changes to get unix/ port compiling on Cygwin. 2014-04-03 23:51:16 +01:00
Damien George
2309369291 tests: Allow to run tests on pyboard.
To run the tests on the pyboard you need to set the "test_on_pyboard"
variable to "True", and also have tools/pyboard.py available for import
(easiest is to symlink to it).
2014-04-03 22:44:51 +01:00
Paul Sokolovsky
34e1199b3a run-tests: Allow to override python3 command to use via environment var. 2014-04-03 22:09:12 +03:00
Paul Sokolovsky
c61ce96590 unix file: Implement context manager protocol (for "with" statement). 2014-04-03 22:09:05 +03:00
Damien George
c322c5f07f py: Fix regress for printing of floats and #if.
Also change formating modifier in test script (it still passes with
original format though).
2014-04-02 20:04:15 +01:00
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