diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-10 06:42:20 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-10 07:13:32 +0200 |
commit | 624eff6a8a948c5ffa7c7d17fab69b3739f2e711 (patch) | |
tree | c650395f4cd9c4a42e7c714f04bee5d65497cac9 /tests/basics | |
parent | 0cd1dc06e673e86058eb14cdd7ae6622cb57fde5 (diff) | |
download | micropython-624eff6a8a948c5ffa7c7d17fab69b3739f2e711.tar.gz micropython-624eff6a8a948c5ffa7c7d17fab69b3739f2e711.zip |
Implement tuple.index().
Diffstat (limited to 'tests/basics')
-rw-r--r-- | tests/basics/tuple_index.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/basics/tuple_index.py b/tests/basics/tuple_index.py new file mode 100644 index 0000000000..1aef100d78 --- /dev/null +++ b/tests/basics/tuple_index.py @@ -0,0 +1,24 @@ +a = (1, 2, 3) +print(a.index(1)) +print(a.index(2)) +print(a.index(3)) +print(a.index(3, 2)) +try: + print(a.index(3, 2, 2)) +except ValueError: + print("Raised ValueError") +else: + print("Did not raise ValueError") + +a = a + a +b = (0, 0, a) +print(a.index(2)) +print(b.index(a)) +print(a.index(2, 2)) + +try: + a.index(2, 2, 2) +except ValueError: + print("Raised ValueError") +else: + print("Did not raise ValueError") |