Commit Graph

51 Commits

Author SHA1 Message Date
Timur Makarchuk
027a25c123 Merge branch 'master' into string.__repr__ 2019-10-05 22:14:34 +03:00
Timur Makarchuk
4b962b89d7 Implement some __ne__ methods (#1446)
* Implement some __ne__ methods

Added test snippets from `__ne__` methods

* Fix incompatability in str.__eq__ befaviour

Previously "".__eq__(1) returned "False", which is not the case in
cpython.
Not it's returning 'NotImplemented', as it should
2019-10-06 00:50:02 +09:00
Timur
70fb3f69ef cpython compatible "".__repr__
Fixes #1390
2019-10-05 01:17:17 +03:00
Daniel Alley
02ea0b629f Handle unicode indexing by character, not by grapheme
Python isn't grapheme aware, so for compatibility sake, we shouldn't be
either.

closes #1417
2019-10-01 12:37:16 -04:00
Jeong YunWon
758073db07 Add _msg back to assert_raises 2019-09-17 18:52:16 +09:00
Jeong YunWon
dc8057a1c2 Refactor snippets/testutil 2019-09-17 17:37:24 +09:00
HyeockJinKim
9a0078214a Add test for str 2019-09-12 06:52:34 +09:00
Noah
aa14a6bc48 Merge pull request #1273 from jmg7173/master
Add floating point formatting
2019-08-16 03:29:31 -05:00
ChJR
1dceae9205 Add str.__rmod__() method. #190 (#1262)
* Add str.__rmod__ method.

* Add tests for str.__rmod__ method.

* Improve test for str.__rmod__ method.

* Change str.__rmod__ method return value type.

* Format with rustfmt.

* Remove not required code of str.__rmod__ method.

* Improve with clippy.
2019-08-16 08:40:32 +02:00
MinGyo Jung
e1ac729770 #1224 Add floating point formatting test for int 2019-08-15 18:52:57 +09:00
MinGyo Jung
d508f8ad7c #1224 Add test code for floating point formatting
Not supports #.#f format
2019-08-15 17:36:11 +09:00
Marcin Pajkowski
6aeec34df0 Add tests for str.__iter__ and str.__next__ 2019-07-24 03:17:05 +02:00
Windel Bouwman
30979d9f27 Merge pull request #1043 from yanganto/feat/unicode-iterals
support unicode literal
2019-06-19 19:13:13 +02:00
Antonio Yang
974dc683e4 support unicode literal
- support unicode literal \x with 2 digits
- support unicode literal \u with 4 digits
- support unicode literal \U with 8 digits
- avoid to parse \x as unicode literal in bytes
2019-06-20 00:30:38 +08:00
Michel Heily
64af5c43df Add some test snippets for modulo string formatting 2019-06-17 19:35:09 +03:00
coolreader18
740e8387b8 Merge pull request #1027 from alanjds/format-bang
Feature: str.format accepting !r, !s and !a
2019-06-10 10:56:00 -05:00
Alan Justino
f0a2b4c50b Apply the {!r} on str.format calls
By the Python docs, the `!` forces a conversion of the argument before
applying the normal formating logic described after the `:` marker.

See: https://docs.python.org/3.4/library/string.html#format-string-syntax
2019-06-09 18:11:10 -03:00
Alan Justino
65d0093822 Dont fail on '{!r}'.format(...) 2019-06-09 13:46:13 -03:00
Antonio Yang
f76be43d26 str.isprintable
- check unicode type by unicode_categories
- rm redundant check of empty string
2019-06-09 23:33:38 +08:00
Jeong YunWon
7f2560c9e1 Add str.encode for utf-8 2019-05-29 21:25:34 +09:00
ZapAnton
a2e64c0425 objstr: Replaced the unwrap_or with the OverflowError 2019-05-25 16:38:51 +03:00
Seo Sanghyeon
433434a1bb Fix rsplit 2019-05-21 23:01:04 +09:00
Windel Bouwman
e1416f5ecc Merge pull request #967 from skinny121/str_xwith_tuple_arg
Accept tuple for first arg in str.startswith and str.endswith
2019-05-12 16:13:25 +02:00
Windel Bouwman
878cc3b120 Merge pull request #943 from Furyzer0/master
[WIP] implement str.translate and str.maketrans
2019-05-12 15:04:31 +02:00
ben
90711f10a0 Accept tuple for first arg in str.startswith and str.endswith 2019-05-12 13:14:27 +12:00
zer0
268cb8d217 fix str.maketrans 2 and 3 arguments cases 2019-05-11 23:58:42 +03:00
Jeong YunWon
c0f14eace3 Fix str.isidentifier() and add tests snippets 2019-05-11 14:30:47 +09:00
zer0
6e05795521 added str.maketrans 2019-05-11 01:03:22 +03:00
zer0
b15a584168 added small test to snippets 2019-05-10 23:47:11 +03:00
Yonatan Goldschmidt
857a7014c2 Enable and extend strings/membership tests 2019-05-03 15:11:14 +03:00
Yonatan Goldschmidt
d1730a53ad Add basic string multiplication tests 2019-05-03 03:07:15 +03:00
Seo Sanghyeon
0e9acdc12b Fix justification 2019-04-26 15:33:37 +09:00
Seo Sanghyeon
f38f263d93 Implement stripping with arguments 2019-04-25 20:33:30 +09:00
ben
d84b8b52a5 Fix the tuple from rpartition being in wrong order when sub isn't
contained within the string
2019-04-25 10:37:59 +12:00
jgirardet
73dbcfbe01 Add bytes.center
fix str.center
add some tests
introduce is_byte
2019-04-13 08:23:40 +02:00
Adrian Wielgosik
2131a8130c Clean up some tests 2019-03-25 17:59:51 +01:00
Adrian Wielgosik
b81a0a16d8 Convert most remaining string methods to implicit args
Also support out-of-range start/end params for some functions.
2019-03-07 20:39:57 +01:00
janczer
aac1ce4e07 Fix the str.{__lt__, __gt__} and add the methods str.{__le__, __ge__} 2019-02-10 16:40:09 +01:00
ichyo
d1b034e3b9 Avoid using \xhh for string 2019-02-05 23:54:39 +09:00
ichyo
fc779c2e3a Use the number of characters instead of bytes for str.__len__ 2019-02-05 23:26:13 +09:00
ZapAnton
23de5581bd Added tests for the isdecimal method 2019-02-03 02:05:57 +03: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
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
Windel Bouwman
5053d6d167 Add bytes literal support. 2018-10-28 21:15:46 +01:00
Akshay Verma
4da6c94602 Added test for capitalize method to string 2018-10-18 16:46:43 +02:00
Akshay Verma
8c04cb5dc3 Added tests for capitalize method to string 2018-10-18 16:25:27 +02:00
Windel Bouwman
d650476f85 Add additional methods to string objects 2018-09-29 10:31:59 +02:00
Adam Kelly
8816e5d362 Implement more complete version of str_repr. 2018-09-02 13:05:03 +01:00
Adam Kelly
7277e63a53 Add vm.to_repr and call for formatting list/tuple/dict elements. 2018-09-02 12:09:57 +01:00
Adam Kelly
91a11e25c2 Replace str built-in with str.__new__ 2018-08-24 15:13:06 +01:00