10000 Add List by kanghyojun · Pull Request #65 · nirum-lang/nirum-python · GitHub
[go: up one dir, main page]

Skip to content

Add List #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 20, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename ImmutableList -> List
  • Loading branch information
kanghyojun committed Mar 20, 2017
commit 1411455f7c7b3ce9a106b83e482cd58227baaea7
8 changes: 4 additions & 4 deletions nirum/datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
import collections

__all__ = 'Map', 'ImmutableList'
__all__ = 'List', 'Map'


class Map(collections.Mapping):
Expand Down Expand Up @@ -51,7 +51,7 @@ def __repr__(self):
return '{0.__module__}.{0.__name__}({1})'.format(type(self), args)


class ImmutableList(collections.Sequence):
class List(collections.Sequence):

def __init__(self, l):
self.l = l
Expand All @@ -71,5 +71,5 @@ def __iter__(self):
def index(self, item):
return self.l.index(item)

def count(self):
return self.l.count()
def count(self, item):
return self.l.count(item)
6 changes: 3 additions & 3 deletions tests/datastructures_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pytest import raises

from nirum.datastructures import Map, ImmutableList
from nirum.datastructures import List, Map


def test_map_init():
Expand Down Expand Up @@ -70,8 +70,8 @@ def test_map_repr():
assert repr(Map(a=1, b=2)) == "nirum.datastructures.Map({'a': 1, 'b': 2})"


def test_immutable_list():
immutable_list = ImmutableList([1, 2])
def test_list():
immutable_list = List([1, 2])
with raises(AttributeError):
immutable_list.append(1)

Expand Down
0