Skip to content

Commit bef2052

Browse files
committed
hdl.ast: implement Value.__pos__.
1 parent 342fd5f commit bef2052

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

amaranth/hdl/ast.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ def __init__(self, *, src_loc_at=0):
166166
def __bool__(self):
167167
raise TypeError("Attempted to convert Amaranth value to Python boolean")
168168

169+
def __pos__(self):
170+
return self
171+
169172
def __invert__(self):
170173
return Operator("~", [self])
171174
def __neg__(self):

tests/test_hdl_ast.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ def test_as_signed(self):
397397
self.assertEqual(repr(v), "(s (const 4'd1))")
398398
self.assertEqual(v.shape(), signed(4))
399399

400+
def test_pos(self):
401+
self.assertRepr(+Const(10), "(const 4'd10)")
402+
400403
def test_neg(self):
401404
v1 = -Const(0, unsigned(4))
402405
self.assertEqual(repr(v1), "(- (const 4'd0))")

0 commit comments

Comments
 (0)