commit 2b614b00ef2d4c48b26082e18f6996f19f45bbb0
parent bddf335a53858254e94e27f1d8d8964440a49361
Author: lash <dev@holbrook.no>
Date: Tue, 29 Mar 2022 11:29:10 +0000
Include leftmost bit in elements generation
Diffstat:
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/shep/state.py b/shep/state.py
@@ -233,7 +233,7 @@ class State:
if v == None or v == 0:
return self.base_state_name
c = 1
- for i in range(1, self.__bits):
+ for i in range(self.__bits):
if v & c > 0:
r.append(self.name(c))
c <<= 1
diff --git a/tests/test_state.py b/tests/test_state.py
@@ -117,12 +117,13 @@ class TestState(unittest.TestCase):
states = State(3, check_alias=False)
states.add('foo')
states.add('bar')
+ states.add('baz')
states.put('abcd')
states.set('abcd', states.FOO)
- states.set('abcd', states.BAR)
+ states.set('abcd', states.BAZ)
v = states.state('abcd')
s = states.name(v)
- self.assertEqual(s, '_FOO_BAR')
+ self.assertEqual(s, '_FOO_BAZ')
def test_peek(self):