Commit Graph

228 Commits

Author SHA1 Message Date
Windel Bouwman
235aa864f4 Merge pull request #296 from agude/int_conj
Add .conjugate() method to int type
2019-02-04 07:43:13 +01:00
Alexander Gude
33523d492c Change int.conjugate() to return a new int
This results in the correct behavior (that is, matching CPython) for
both int and bool types.

Also adding a bool conjugate test.
2019-02-03 13:31:09 -08:00
Alexander Gude
a95747f161 Add .conjugate() method to int type
Also add tests for for the int type, and a commented out one for the
bool type.
2019-02-03 11:18:23 -08:00
HomerMcMillan
168e0e5471 Merge branch 'master' into list-orderable-ops 2019-02-03 11:17:09 -05:00
Windel Bouwman
a7d011f9c7 Merge pull request #270 from ZapAnton/str_isdecimal
Added the isdecimal method to the 'str' class
2019-02-03 15:37:20 +01:00
Windel Bouwman
ac0ea87ead Merge pull request #271 from holygits/bitshift
Implement `__rshift__` and `__lshift__` for integer type
2019-02-03 15:35:50 +01:00
Windel Bouwman
1d7149e131 Merge pull request #280 from HomerMcMillan/list-pop
Add list.pop
2019-02-03 11:49:01 +01:00
Homer McMillan
7b27fbf369 Add list.pop
Also include IndexError in the __builtin__ module.
2019-02-03 00:49:52 -05:00
Homer McMillan
2b74727783 Fix broken test 2019-02-02 22:41:34 -05:00
Homer McMillan
ea1a7bb395 Add list.{__lt__, __gt__, __le__, __ge__} 2019-02-02 22:04:26 -05:00
ben
8f9b733a77 Add tuple.__mul__ 2019-02-03 13:59:43 +13:00
holygits
e8d1e10226 Implement __rshift__ and __lshift__ for integer 2019-02-03 12:38:38 +13:00
ZapAnton
23de5581bd Added tests for the isdecimal method 2019-02-03 02:05:57 +03:00
Windel Bouwman
31523fe4d7 Merge pull request #265 from rmliddle/implement-io
File-IO: IO Module and Open Builtin
2019-01-29 20:43:28 +01:00
rmliddle
0ee535e49a Removed append + create 2019-01-28 20:14:19 +11:00
rmliddle
3ce9972c9c removed os.O_NONBLOCK from snippet 2019-01-28 20:07:57 +11:00
rmliddle
507f7bdca9 Fix for os open (optional params not allowed) 2019-01-28 19:38:06 +11:00
rmliddle
c011db2819 fmt w/nightly 2019-01-28 19:21:27 +11:00
rmliddle
9a86bbd718 ByteArray Usage 2019-01-28 18:30:19 +11:00
rmliddle
c2e73cc829 Test Snippets for buffered_read, open builtin 2019-01-23 19:16:03 +11:00
rmliddle
dda3d7ffb7 Bug fix for sequential Writes, New File Writes 2019-01-21 20:03:36 +11:00
Shing Lyu
5e8eb8a001 Added list.index() 2019-01-10 22:01:42 +01:00
Riccardo Magliocchetti
e4ca1655e9 Implement most string module constants
whitespace and thus printable are excluded because i haven't found
a way to make tests pass.
2018-12-27 23:48:11 +01:00
AgentMacklin
79a3b13252 Implement most of the string methods. (#239)
* implemented more functions

* backup

* Improve demo site

* Formatting; move the `+ '\n'` hack to eval().

* Rename run_code() to run_from_textbox()

* Switch to using json.dumps for py_to_js()

* Clarify names of wasm builtins

* Remove dependency on num_bigint

* Allow injecting JS variables into python with eval_py()

eval_py(`return js_vars["a"]`, { a: 9 }) == 9

* dict() now should work properly

e.g.
``` dict(a=2, b=3) == {"a": 2, "b": 3} ```

* Add documentation for eval_py() and update error message handling

Also, switch from iterating over the values of js_injections and
serializing each of them individually to asserting it's an object and
then just stringifying the whole thing.

* Finish revamping `dict_new()`

* Add 'from x import *' syntax.

This is a separate opcode in CPython so I added it as such here.

* Add test for dicts

* added functions

* ran rustfmt and fixed isidentifier

* fixed zfill and make_title

* python3.6 doesn't contain isascii()
2018-12-27 20:22:04 +01:00
Windel Bouwman
946df53077 Merge pull request #237 from johndaniels/add-star-import
Add 'from x import *' syntax.
2018-12-23 17:55:34 +01:00
Gitea
ac3da8b453 Add 'from x import *' syntax.
This is a separate opcode in CPython so I added it as such here.
2018-12-22 22:40:02 -05:00
Windel Bouwman
366f3e2b13 Merge pull request #236 from coolreader18/proper-dict
Make `dict()` work like it does in cpython
2018-12-22 16:05:31 +01:00
coolreader18
427ce4347e Add test for dicts 2018-12-22 00:04:13 -06:00
Windel Bouwman
bbe333d6c7 Merge pull request #233 from rossjones/232-impl-mul-for-list
Implements __mul__ for lists
2018-12-17 11:55:44 +01:00
Windel Bouwman
8aaadb16c0 Merge pull request #234 from johndaniels/indentation
Handle mixed spaces and tabs.
2018-12-17 11:55:20 +01:00
Gitea
c74cd90d8e Handle mixed spaces and tabs.
This allows the parser to handle tabs and spaces. Currently it
requires that spaces come after any tabs, which is slightly more
strict than python3. It also requires that neighboring indentation
levels have either both more spaces and tabs or less spaces and
tabs so that tab size can't make perception of indentation
differ from what the parser interprets.

I didn't opt to implement PartialOrd on IndentationLevel because I
wasn't sure that the comparison logic would meet the logical
requirements for that trait. One could easily switch to having it
implement PartialOrd though. This would necessitate switching to
manually implementing PartialEq so that it's behavior 'matches'.
It's unclear from the docs what 'matches' exactly means so for
now I'm avoiding implementing the traits.
2018-12-16 17:11:37 -05:00
Gitea
95d4073dd8 Add newline to end of file.
The parser currently doesn't handle missing newline gracefully.
2018-12-16 16:21:40 -05:00
Gitea
bbe4844f6c Fix snippet to not use tab.
We should add support for '\t', but that should probably be a separate ticket.
2018-12-16 15:43:07 -05:00
Ross Jones
ae2f7ed1cb Implements __mul__ for lists
Implements __mul__ for lists so that it is possible to do things like

```
s = [1, 2,] * 3
s == [1, 2, 1, 2, 1, 2]
```
2018-12-16 12:22:31 +00:00
Gitea
b726e675ff Add format builtin and String formatting stuff.
This includes everything needed to call str.format with integers
as positional and keyword parameters.
2018-12-15 19:46:09 -05:00
Adam Kelly
a1b7c61fcf Implement sys._getframe() to the point where we can use it to get locals. 2018-11-11 17:54:30 +00:00
Windel Bouwman
c4cbedae2f Extend min builtin function to support key and default. 2018-11-07 19:25:18 +01:00
Windel Bouwman
99af466a88 Move max function test cases to snippet dir. Implement key and default argument on max function. 2018-11-07 17:26:18 +01:00
Windel Bouwman
df0400dffb Add filter and zip builtins 2018-11-07 09:41:16 +01:00
Windel Bouwman
3c4aaa0d3c Merge pull request #188 from RustPython/sub
Implement __sub__/__rsub__.
2018-11-06 22:33:40 +01:00
Windel Bouwman
c69b43d13b Add frozenset class, callable function and enumerate function. 2018-11-06 21:42:42 +01:00
Windel Bouwman
ce5bb72ed0 Minor delta on super class. 2018-11-05 20:46:32 +01:00
Adam Kelly
7bf8378a18 type.__getattribute__ should be bound to type! 2018-11-04 18:43:39 +00:00
Windel Bouwman
a389b55ec1 Initial version of property class. 2018-11-04 17:14:07 +01:00
Windel Bouwman
6746784db8 Add classmethod and staticmethod classes. 2018-11-04 13:27:50 +01:00
Windel Bouwman
5ffb20b26e Add builtin oct function. Add weakref.ref class. 2018-11-04 12:07:53 +01:00
Adam Kelly
60f29149ef Add test for class with sub and rsub. 2018-11-04 10:17:07 +00:00
Adam Kelly
ff4e8da07e Merge branch 'master' into newinit 2018-11-03 22:42:40 +00:00
Adam Kelly
bcdb2089d5 Add logic for inheriting metaclass from bases. 2018-11-03 18:09:32 +00:00
Windel Bouwman
0199137fb0 Add sum builtin function. 2018-11-03 15:45:50 +01:00