Skip to content

Commit

Permalink
Fix repr bug add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cdonovick committed Jun 19, 2019
1 parent 78f178a commit 4e1723a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hwtypes/adt.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __new__(cls, *args, **kwargs):
raise TypeError('Cannot instance unbound product type')

def __repr__(self):
return f'{type(self).__name__}({", ".join(f"{k}={v}" for k,v in self.value_dict)})'
return f'{type(self).__name__}({", ".join(f"{k}={v}" for k,v in self.value_dict.items())})'

@property
def value_dict(self):
Expand Down
11 changes: 11 additions & 0 deletions tests/test_adt.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,14 @@ def test_new():

t = new(Sum, (En1, Pr), module=__name__)
assert t.__module__ == __name__

@pytest.mark.parametrize("T", [En1, Tu, Su, Pr])
def test_repr(T):
s = repr(T)
assert isinstance(s, str)
assert s != ''
for e in T.enumerate():
s = repr(e)
assert isinstance(s, str)
assert s != ''

0 comments on commit 4e1723a

Please sign in to comment.