# Path: vii/RegisterManager.py
# class RegisterManager:
# 
#     def __init__(self):
#         self.numbered = 10 * [tuple(["", False])]
#         self.named = dict()
#         self.unnamed = "0"
# 
#     def shift(self, string, linewise = False):
#         value = tuple([string, linewise])
#         self.unnamed = '1'
#         self.numbered[1:10] = [value] + self.numbered[1:9]
# 
#     def store(self, name, string, linewise = False):
#         if name == '_': return
#         if name == '"':
#             return self.store(0, string, linewise)
#         name = str(name)
#         value = tuple([string, linewise])
#         if name.isdigit():
#             self.numbered[int(name)] = value
#         else:
#             self.named[name] = value
#         self.unnamed = name
# 
#     def fetch(self, name):
#         name = str(name)
#         if name == '"':
#             return self.fetch(self.unnamed)
#         if name.isdigit():
#             try: return self.numbered[int(name)]
#             except IndexError: return ("", False)
#         else:
#             try: return self.named[name]
#             except KeyError: return ("", False)


from vii.RegisterManager import RegisterManager
        assert self.fixture.fetch("11") == ("", False)

    def test_store_fetch_replace(self):
        self.fixture.store("a", "alpha")
        assert self.fixture.fetch("a") == ("alpha", False)
        self.fixture.store("a", "ALPHA", True)
        assert self.fixture.fetch("a") == ("ALPHA", True)
        self.fixture.store("0", "zero")
        assert self.fixture.fetch("0") == ("zero", False)
        self.fixture.store("0", "ZERO", True)
        assert self.fixture.fetch("0") == ("ZERO", True)

    def test_limit_of_numbered(self):
        for i in range(11, 0, -1):
            self.fixture.shift(str(i))
        assert self.fixture.fetch(0) == ("", False)
        assert self.fixture.fetch(1) == ("1", False)
        assert self.fixture.fetch(9) == ("9", False)
        assert self.fixture.fetch(10) == ("", False)

    def test_storing_to_unnamed_register_stores_to_0(self):
        assert self.fixture.fetch('"') == ("", False)
        assert self.fixture.fetch(0) == ("", False)
        self.fixture.store('"', "uuu", True)
        assert self.fixture.fetch('"') == ("uuu", True)
        assert self.fixture.fetch(0) == ("uuu", True)

    def test_access_last_store_by_unnamed(self):
        assert self.fixture.fetch('"') == ("", False)
        assert self.fixture.fetch('a') == ("", False)

# Path: vii/RegisterManager.py
# class RegisterManager:
# 
#     def __init__(self):
#         self.numbered = 10 * [tuple(["", False])]
#         self.named = dict()
#         self.unnamed = "0"
# 
#     def shift(self, string, linewise = False):
#         value = tuple([string, linewise])
#         self.unnamed = '1'
#         self.numbered[1:10] = [value] + self.numbered[1:9]
# 
#     def store(self, name, string, linewise = False):
#         if name == '_': return
#         if name == '"':
#             return self.store(0, string, linewise)
#         name = str(name)
#         value = tuple([string, linewise])
#         if name.isdigit():
#             self.numbered[int(name)] = value
#         else:
#             self.named[name] = value
#         self.unnamed = name
# 
#     def fetch(self, name):
#         name = str(name)
#         if name == '"':
#             return self.fetch(self.unnamed)
#         if name.isdigit():
#             try: return self.numbered[int(name)]
#             except IndexError: return ("", False)
#         else:
#             try: return self.named[name]
#             except KeyError: return ("", False)


# Path: tests/RegisterManager_Test.py
from vii.RegisterManager import RegisterManager

        assert self.fixture.fetch("11") == ("", False)

    def test_store_fetch_replace(self):
        self.fixture.store("a", "alpha")
        assert self.fixture.fetch("a") == ("alpha", False)
        self.fixture.store("a", "ALPHA", True)
        assert self.fixture.fetch("a") == ("ALPHA", True)
        self.fixture.store("0", "zero")
        assert self.fixture.fetch("0") == ("zero", False)
        self.fixture.store("0", "ZERO", True)
        assert self.fixture.fetch("0") == ("ZERO", True)

    def test_limit_of_numbered(self):
        for i in range(11, 0, -1):
            self.fixture.shift(str(i))
        assert self.fixture.fetch(0) == ("", False)
        assert self.fixture.fetch(1) == ("1", False)
        assert self.fixture.fetch(9) == ("9", False)
        assert self.fixture.fetch(10) == ("", False)

    def test_storing_to_unnamed_register_stores_to_0(self):
        assert self.fixture.fetch('"') == ("", False)
        assert self.fixture.fetch(0) == ("", False)
        self.fixture.store('"', "uuu", True)
        assert self.fixture.fetch('"') == ("uuu", True)
        assert self.fixture.fetch(0) == ("uuu", True)

    def test_access_last_store_by_unnamed(self):
        assert self.fixture.fetch('"') == ("", False)
        assert self.fixture.fetch('a') == ("", False)

        self.fixture.store('a', "aaa", True)