# Path: zvm/zmachine.py
# class ZMachineError(Exception):
# class ZMachine(object):
#   def __init__(self, story, ui, debugmode=False):
#   def run(self):
# 
# Path: zvm/trivialzui.py
# class TrivialAudio(zaudio.ZAudio):
# class TrivialScreen(zscreen.ZScreen):
# class TrivialKeyboardInputStream(zstream.ZInputStream):
# class TrivialFilesystem(zfilesystem.ZFilesystem):
#   def __init__(self):
#   def play_bleep(self, bleep_type):
#   def __init__(self):
#   def split_window(self, height):
#   def select_window(self, window_num):
#   def set_cursor_position(self, x, y):
#   def erase_window(self, window=zscreen.WINDOW_LOWER,
#                    color=zscreen.COLOR_CURRENT):
#   def set_font(self, font_number):
#   def set_text_style(self, style):
#   def __show_more_prompt(self):
#   def on_input_occurred(self, newline_occurred=False):
#   def __unbuffered_write(self, string):
#   def write(self, string):
#   def __init__(self, screen):
#   def read_line(self, original_text=None, max_length=0,
#                 terminating_characters=None,
#                 timed_input_routine=None, timed_input_interval=0):
#   def read_char(self, timed_input_routine=None,
#                 timed_input_interval=0):
#   def __report_io_error(self, exception):
#   def save_game(self, data, suggested_filename=None):
#   def restore_game(self):
#   def open_transcript_file_for_writing(self):
#   def open_transcript_file_for_reading(self):
# def create_zui():
# def _win32_read_char():
# def _unix_read_char():
# def _read_char():
# def _read_line(original_text=None, terminating_characters=None):
# def _word_wrap(text, width):
#     MORE_STRING = "[MORE]"
# _INTERRUPT_CHAR = chr(3)
# _BACKSPACE_CHAR = chr(8)
# _DELETE_CHAR = chr(127)
# 
# Path: zvm/quetzal.py
# class QuetzalError(Exception):
# class QuetzalMalformedChunk(QuetzalError):
# class QuetzalNoSuchSavefile(QuetzalError):
# class QuetzalUnrecognizedFileFormat(QuetzalError):
# class QuetzalIllegalChunkOrder(QuetzalError):
# class QuetzalMismatchedFile(QuetzalError):
# class QuetzalMemoryOutOfBounds(QuetzalError):
# class QuetzalMemoryMismatch(QuetzalError):
# class QuetzalStackFrameOverflow(QuetzalError):
# class QuetzalParser(object):
# class QuetzalWriter(object):
#   def __init__(self, zmachine):
#   def _parse_ifhd(self, data):
#   def _parse_cmem(self, data):
#   def _parse_umem(self, data):
#   def _parse_stks(self, data):
#   def _parse_intd(self, data):
#   def _parse_auth(self, data):
#   def _parse_copyright(self, data):
#   def _parse_anno(self, data):
#   def get_last_loaded(self):
#   def load(self, savefile_path):
#   def __init__(self, zmachine):
#   def _generate_ifhd_chunk(self):
#   def _generate_cmem_chunk(self):
#   def _generate_stks_chunk(self):
#   def _generate_anno_chunk(self):
#   def write(self, savefile_path):


from unittest import TestCase
from zvm import zmachine, trivialzui
from zvm import quetzal
#
# Unit tests for the two quetzal classes.
#
# For the license of this file, please consult the LICENSE file in the
# root directory of this distribution.
#

def make_zmachine():
    # We use Graham Nelson's 'curses' game for our unittests.
    with open("stories/curses.z5", "rb") as story:
      story_image = story.read()
    ui = trivialzui.create_zui()
    return zmachine.ZMachine(story_image, ui, debugmode=True)

class QuetzalWriterTest(TestCase):
  def testWriteQuetzalFile(self):
    machine = make_zmachine()
    writer = quetzal.QuetzalWriter(machine)
    writer.write("tests/test_savefile")

class QuetzalParserTest(TestCase):
  def testLoadCurses(self):
    "Try loading a specific curses save-file, verify expected metadata."
    machine = make_zmachine()

# Path: zvm/zmachine.py
# class ZMachineError(Exception):
# class ZMachine(object):
#   def __init__(self, story, ui, debugmode=False):
#   def run(self):
# 
# Path: zvm/trivialzui.py
# class TrivialAudio(zaudio.ZAudio):
# class TrivialScreen(zscreen.ZScreen):
# class TrivialKeyboardInputStream(zstream.ZInputStream):
# class TrivialFilesystem(zfilesystem.ZFilesystem):
#   def __init__(self):
#   def play_bleep(self, bleep_type):
#   def __init__(self):
#   def split_window(self, height):
#   def select_window(self, window_num):
#   def set_cursor_position(self, x, y):
#   def erase_window(self, window=zscreen.WINDOW_LOWER,
#                    color=zscreen.COLOR_CURRENT):
#   def set_font(self, font_number):
#   def set_text_style(self, style):
#   def __show_more_prompt(self):
#   def on_input_occurred(self, newline_occurred=False):
#   def __unbuffered_write(self, string):
#   def write(self, string):
#   def __init__(self, screen):
#   def read_line(self, original_text=None, max_length=0,
#                 terminating_characters=None,
#                 timed_input_routine=None, timed_input_interval=0):
#   def read_char(self, timed_input_routine=None,
#                 timed_input_interval=0):
#   def __report_io_error(self, exception):
#   def save_game(self, data, suggested_filename=None):
#   def restore_game(self):
#   def open_transcript_file_for_writing(self):
#   def open_transcript_file_for_reading(self):
# def create_zui():
# def _win32_read_char():
# def _unix_read_char():
# def _read_char():
# def _read_line(original_text=None, terminating_characters=None):
# def _word_wrap(text, width):
#     MORE_STRING = "[MORE]"
# _INTERRUPT_CHAR = chr(3)
# _BACKSPACE_CHAR = chr(8)
# _DELETE_CHAR = chr(127)
# 
# Path: zvm/quetzal.py
# class QuetzalError(Exception):
# class QuetzalMalformedChunk(QuetzalError):
# class QuetzalNoSuchSavefile(QuetzalError):
# class QuetzalUnrecognizedFileFormat(QuetzalError):
# class QuetzalIllegalChunkOrder(QuetzalError):
# class QuetzalMismatchedFile(QuetzalError):
# class QuetzalMemoryOutOfBounds(QuetzalError):
# class QuetzalMemoryMismatch(QuetzalError):
# class QuetzalStackFrameOverflow(QuetzalError):
# class QuetzalParser(object):
# class QuetzalWriter(object):
#   def __init__(self, zmachine):
#   def _parse_ifhd(self, data):
#   def _parse_cmem(self, data):
#   def _parse_umem(self, data):
#   def _parse_stks(self, data):
#   def _parse_intd(self, data):
#   def _parse_auth(self, data):
#   def _parse_copyright(self, data):
#   def _parse_anno(self, data):
#   def get_last_loaded(self):
#   def load(self, savefile_path):
#   def __init__(self, zmachine):
#   def _generate_ifhd_chunk(self):
#   def _generate_cmem_chunk(self):
#   def _generate_stks_chunk(self):
#   def _generate_anno_chunk(self):
#   def write(self, savefile_path):


# Path: tests/quetzal_tests.py
from unittest import TestCase
from zvm import zmachine, trivialzui
from zvm import quetzal

#
# Unit tests for the two quetzal classes.
#
# For the license of this file, please consult the LICENSE file in the
# root directory of this distribution.
#

def make_zmachine():
    # We use Graham Nelson's 'curses' game for our unittests.
    with open("stories/curses.z5", "rb") as story:
      story_image = story.read()
    ui = trivialzui.create_zui()
    return zmachine.ZMachine(story_image, ui, debugmode=True)

class QuetzalWriterTest(TestCase):
  def testWriteQuetzalFile(self):
    machine = make_zmachine()
    writer = quetzal.QuetzalWriter(machine)
    writer.write("tests/test_savefile")

class QuetzalParserTest(TestCase):
  def testLoadCurses(self):
    "Try loading a specific curses save-file, verify expected metadata."
    machine = make_zmachine()

    parser = quetzal.QuetzalParser(machine)