8000 Enable and extend strings/membership tests · RustPython/RustPython@b54e108 · GitHub
[go: up one dir, main page]

Skip to content

Commit b54e108

Browse files
committed
Enable and extend strings/membership tests
1 parent d1730a5 commit b54e108

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

tests/snippets/membership.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
assert "whatever" not in "foobar"
1313

1414
# test bytes
15-
# TODO: uncomment this when bytes are implemented
16-
# assert b"foo" in b"foobar"
17-
# assert b"whatever" not in b"foobar"
15+
assert b"foo" in b"foobar"
16+
assert b"whatever" not in b"foobar"
1817
assert b"1" < b"2"
1918
assert b"1" <= b"2"
2019
assert b"5" <= b"5"
@@ -32,18 +31,20 @@
3231
assert 3 not in set([1, 2])
3332

3433
# test dicts
35-
# TODO: test dicts when keys other than strings will be allowed
3634
assert "a" in {"a": 0, "b": 0}
3735
assert "c" not in {"a": 0, "b": 0}
36+
assert 1 in {1: 5, 7: 12}
37+
assert 5 not in {9: 10, 50: 100}
38+
assert True in {True: 5}
39+
assert False not in {True: 5}
3840

3941
# test iter
4042
assert 3 in iter([1, 2, 3])
4143
assert 3 not in iter([1, 2])
4244

4345
# test sequence
44-
# TODO: uncomment this when ranges are usable
45-
# assert 1 in range(0, 2)
46-
# assert 3 not in range(0, 2)
46+
assert 1 in range(0, 2)
47+
assert 3 not in range(0, 2)
4748

4849
# test __contains__ in user objects
4950
class MyNotContainingClass():

tests/snippets/strings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
]
103103

104104

105-
# assert c.isascii()
105+
assert c.isascii()
106106
assert c.index('a') == 1
107107
assert c.rindex('l') == 3
108108
assert c.find('h') == 0

0 commit comments

Comments
 (0)
0