# Path: test/geartalk.py
# _POINT_CHARS = {
#     -1: '<',
#     0:  'X',
#     1:  '>',
# }
# class Client(object):
#     def __init__(self, prog, hill_size):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, traceback):
#     def Set(self, index, code):
#     def Test(self, code):
#     def _Read(self):
# 
# Path: test/reference.py
# def check(left, right, result):
# 
# Path: test/source.py
# def _warriors():
# def count():
# def warriors():
# def pairs():
# 
# Path: tools/runfiles.py
# _WORKSPACE = 'fi_zem_chainlance'
# def _find_runfiles():
# def _runfiles():
# def path(path):
# def open(file, *args, **kwargs):


import itertools
import sys
from test import geartalk
from test import reference
from test import source
from tools import runfiles


def main():
    warriors = source.warriors()
    failed = 0

    with geartalk.Client(runfiles.path('gearlanced'), len(warriors)) as hill:
        for left in warriors:
            with open(left.path) as f:
                hill.Set(left.index, f.read())

        for right in warriors:
            with open(right.path) as f:
                results = hill.Test(f.read())
            if len(results) != len(warriors):
                raise AssertionError('unexpected number of results: {}: expected {}'.format(
                    len(results), len(warriors)))
            for left, result in itertools.izip(warriors, results):

# Path: test/geartalk.py
# _POINT_CHARS = {
#     -1: '<',
#     0:  'X',
#     1:  '>',
# }
# class Client(object):
#     def __init__(self, prog, hill_size):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, traceback):
#     def Set(self, index, code):
#     def Test(self, code):
#     def _Read(self):
# 
# Path: test/reference.py
# def check(left, right, result):
# 
# Path: test/source.py
# def _warriors():
# def count():
# def warriors():
# def pairs():
# 
# Path: tools/runfiles.py
# _WORKSPACE = 'fi_zem_chainlance'
# def _find_runfiles():
# def _runfiles():
# def path(path):
# def open(file, *args, **kwargs):


# Path: gearlanced_test.py
import itertools
import sys
from test import geartalk
from test import reference
from test import source
from tools import runfiles



def main():
    warriors = source.warriors()
    failed = 0

    with geartalk.Client(runfiles.path('gearlanced'), len(warriors)) as hill:
        for left in warriors:
            with open(left.path) as f:
                hill.Set(left.index, f.read())

        for right in warriors:
            with open(right.path) as f:
                results = hill.Test(f.read())
            if len(results) != len(warriors):
                raise AssertionError('unexpected number of results: {}: expected {}'.format(
                    len(results), len(warriors)))
            for left, result in itertools.izip(warriors, results):

                if not reference.check(left.name, right.name, result):