Paul Sokolovsky
e276753b45
tests: Add testcases for catching user Exception subclasses.
11 years ago
Paul Sokolovsky
d8351ca8a0
objtype: .print() Exception instances in adhoc way.
This is ugly, just as expected.
11 years ago
Andrew Scheller
37067666ee
Fix the builtin min() and max() functions (and add tests).
Fixes #539
11 years ago
Paul Sokolovsky
c963310123
tests: Add test for calling inherited native method on subclass.
11 years ago
Paul Sokolovsky
5a12137c3e
tests: Add test for accessing attribute of inherited native type.
11 years ago
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.
11 years ago
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 .
11 years ago
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 .
11 years ago
Paul Sokolovsky
881078403e
objstr: Implement .lstrip() & .rstrip().
Share code with .strip(). TODO: optimize .rstrip().
11 years ago
Paul Sokolovsky
755565d2cb
py: Support instance __call__ method.
11 years ago
Paul Sokolovsky
efc36f0cea
test/class-super: Expose super() breakage.
11 years ago
Paul Sokolovsky
d6e12723ed
objarray: Implement slice subscription.
11 years ago
Paul Sokolovsky
6204460461
modstruct: Initial implementation of struct.pack().
11 years ago
Paul Sokolovsky
83eba5dec5
sequence: Fix glaring bug in sequence comparison.
11 years ago
Damien George
559d8239ca
tests: Move gen_context to import tests, because it relies on import.
11 years ago
Paul Sokolovsky
b7e90ea078
objgenerator: Generator must execute in its defining lexical context.
I.e. with its own globals. So, just as for functions, we need to switch
globals when resuming a generator.
11 years ago
Damien George
5cd0b2227f
tests: Split out those tests requiring float and import.
Tests in basics (which should probably be renamed to core) should not
rely on float, or import any non-built-in files. This way these tests
can be run when those features are not available.
All test in basics now pass on the pyboard using stmhal port, except for
string-repr which has some issues with character hex printing.
11 years ago
Damien George
7447e80f3d
tests: Remove print('flush') from 2 tests, since stmhal now works.
Fixing the USB problem on stmhal now gets these 2 tests working.
11 years ago
Andrew Scheller
1b997d5244
run-tests can now skip certain tests when run under Travis CI
See the `skip_travis_tests` variable. Fixes #495
(also tidied up usage of os.path.basename() function)
11 years ago
Damien George
897fe0c0d0
py: Add builtin functions bin and oct, and some tests for them.
11 years ago
Damien George
256b319d56
tests: Disable memoryerror.py test, since it fails on travis.
Would be good to test this, but need to find a way to optionally not
running it when on travis.
11 years ago
Damien George
e8ecca21ff
travis: More tests output debugging.
11 years ago
Damien George
35443610b1
travis: More tests debugging.
11 years ago
Damien George
45b4cc77dd
travis: Debugging failing tests.
11 years ago
Paul Sokolovsky
75ffcaeace
py: Implement __delitem__ method for classes.
11 years ago
Damien George
e2a48b66c2
tests: Add property test.
11 years ago
Damien George
4417478d0f
tests: Make tests pass on pyboard.
11 years ago
Paul Sokolovsky
48fdaad824
py: Rename collections module to _collections.
We're not going to implement all the plethora of types in there in C.
Funnily, CPython implements defaultdict in C, and namedtuple in Python.
11 years ago
Paul Sokolovsky
aa6666c45e
objlist: Make .extend accept arbitrary iterable.
11 years ago
Damien George
6ce4277551
py: Make all LOAD_FAST ops check for unbound local.
This is necessary to catch all cases where locals are referenced before
assignment. We still keep the _0, _1, _2 versions of LOAD_FAST to help
reduced the byte code size in RAM.
Addresses issue #457 .
11 years ago
Paul Sokolovsky
a5afc9009f
builtinimport: Implement relative imports.
11 years ago
Paul Sokolovsky
2ff3d9d0b2
builtinimport: Set __path__ attribute ASAP as it's clear we have a package.
This helps with handling "recursive" imports in sane manner, for example
when foo/__init__.py has something like "from foo import submod".
11 years ago
Damien George
8f19317540
py: Remove useless implementations of NOT_EQUAL in binary_op's.
I'm pretty sure these are never reached, since NOT_EQUAL is always
converted into EQUAL in mp_binary_op. No one should call
type.binary_op directly, they should always go through mp_binary_op
(or mp_obj_is_equal).
11 years ago
Paul Sokolovsky
af620abcb5
py: Implement "from pkg import mod" variant of import.
11 years ago
Damien George
686afc5c0a
py: Check that sequence has 2 elements for dict iterable constructor.
11 years ago
Paul Sokolovsky
be019ce063
objdict: Implement construction from iterable of pairs.
Pairs are limited to tuples so far.
11 years ago
Paul Sokolovsky
12a04392b9
objdict: Implement __getitem__ method.
11 years ago
Paul Sokolovsky
0c43cf9154
modstruct: Basic implementation of native struct alignment and types.
11 years ago
Paul Sokolovsky
6582d64d01
modstruct: Refactor to support both LE and BE packed structs.
11 years ago
Damien George
f31b6ff334
tests: Add test for multi-comparison.
11 years ago
Paul Sokolovsky
978607aeff
objfun: Fix default arguments filling loop, was broken in presense of kwargs.
11 years ago
Paul Sokolovsky
e9db840480
py: Start implementing "struct" module.
Only calcsize() and unpack() functions provided so far, for little-endian
byte order. Format strings don't support repition spec (like "2b3i").
Unfortunately, dealing with all the various binary type sizes and alignments
will lead to quite a bloated "binary" helper functions - if optimizing for
speed. Need to think if using dynamic parametrized algos makes more sense.
11 years ago
Damien George
a157e4caba
py: str.join can now take arbitrary iterable as argument.
11 years ago
Damien George
13d6739cc7
py: Generators can have their locals closed over.
11 years ago
Damien George
2bf7c09222
py: Properly implement deletion of locals and derefs, and detect errors.
Needed to reinstate 2 delete opcodes, to specifically check that a local
is not deleted twice.
11 years ago
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.
11 years ago
Damien George
2b0091983f
tests: Oops: fix del-attr.
11 years ago
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).
11 years ago
Paul Sokolovsky
4dcb605ac4
py: Make bytearray a proper type.
11 years ago
xbe
3d9a39e211
py: Implement str.[r]index() and add tests for them.
11 years ago