# Path: test/base.py
# def     preamble():
#     """
#     process command line flags - see <test-script> -h
#     """
#     flags, args = parseCommandLineArgs(sys.argv)
# 
#     for flag in flags:
#         if flag in ("-ee=0", "--lazy"):
#             systemVariables.setEvaluationMode(0)
# 
#         elif flag in ("-ee=1", "--eager"):
#             systemVariables.setEvaluationMode(1)
# 
#         elif flag in "-io=0":
#             systemVariables.setIndexOrigin(0)
# 
#         elif flag in "-io=1":
#             systemVariables.setIndexOrigin(1)
# 
#         elif flag in ("-h", "--help"):
#             print(_help())
#             aplQuit(0)
# 
#         else:
#             aplQuit(3, "{0} not recognised: perhaps try -h".format(flag))
# 
# def     testOutput(expr):
#     """
#     evaluate a line that may comprise several expressions
# 
#     handle both positive and negative outcomes
#     """
#     try:
#         cio = aplCio()
#         evaluateAndPrint(expr, cio)
#     except aplException as error:
#         print(error.message)
# 
# def     testCommand(expr):
#     """
#     evaluate an expression that is a system command
# 
#     handle both positive and negative outcomes
#     """
#     try:
#         evaluate(expr, aplCio())
#     except aplException as error:
#         print(error.message)
# 
# def     testResult(expr, overrideLazy=False):
#     """
#     evaluate an expression then format and print the result
# 
#     handle both positive and negative outcomes
# 
#     Often the negative outcome in lazy evaluation mode involves printing backspaces
# 
#         doctest.NORMALIZE_WHITESPACE = 1
# 
#     does not have the desired effect, hence the messing around the with the evaluation mode.
#     """
#     if overrideLazy:
#         overrideLazy = not systemVariables.eagerEvaluation()
# 
#     if overrideLazy:
#         systemVariables.setEvaluationMode(1)
# 
#     try:
#         cio = aplCio()
#         cio.printResult(evaluate(expr, cio))
#     except aplException as error:
#         print(error.message)
# 
#     if overrideLazy:
#         systemVariables.setEvaluationMode(0)
# 
# Path: test/base.py
# def     saveIndexOrigin():
#     """
#     return ⎕IO so the test function can save it
#     """
#     return systemVariables.indexOrigin()
# 
# def     setIndexOrigin(io):
#     """
#     set ⎕IO:  it is assumed the test function has saved and will restore the original value
#     """
#     systemVariables.setIndexOrigin(io)
# 
# def     restoreIndexOrigin(io):
#     """
#     restore ⎕IO previously retrieved by the test function using saveIndexOrigin
#     """
#     systemVariables.setIndexOrigin(io)


from test.base import preamble, testOutput, testCommand, testResult as test
from test.base import saveIndexOrigin, setIndexOrigin, restoreIndexOrigin
        import doctest
#!/usr/bin/python3
"""
    doctest style unit tests for the APL parser

    WIP - grows as evaluate.py is extended.

    The tests in this module exercise the functions in evaluate.py:
      - recognition of numbers
      - recognition of strings
      - recognition of names
      - tack functions (⊢ and ⊣)
      - scalar invocation of monadic and dyadic functions
      - parentheses to alter order of execution
      - parsing of vector quantities - including mixed/nested vectors
      - printing of array quantities
      - array prototypes
      - scan and reduce operators
      - parsing of output operators (⎕ ⍞) - but not input operators
      - system variables
      - system commands

    All but the system commnd tests pass an APL expression to the evaluate function.
    Almost all tests are positive.

    Note:
        testDyadic --eager      # run with eager evaluation
        testDyadic --lazy       # run with lazy evaluation
"""


# Path: test/base.py
# def     preamble():
#     """
#     process command line flags - see <test-script> -h
#     """
#     flags, args = parseCommandLineArgs(sys.argv)
# 
#     for flag in flags:
#         if flag in ("-ee=0", "--lazy"):
#             systemVariables.setEvaluationMode(0)
# 
#         elif flag in ("-ee=1", "--eager"):
#             systemVariables.setEvaluationMode(1)
# 
#         elif flag in "-io=0":
#             systemVariables.setIndexOrigin(0)
# 
#         elif flag in "-io=1":
#             systemVariables.setIndexOrigin(1)
# 
#         elif flag in ("-h", "--help"):
#             print(_help())
#             aplQuit(0)
# 
#         else:
#             aplQuit(3, "{0} not recognised: perhaps try -h".format(flag))
# 
# def     testOutput(expr):
#     """
#     evaluate a line that may comprise several expressions
# 
#     handle both positive and negative outcomes
#     """
#     try:
#         cio = aplCio()
#         evaluateAndPrint(expr, cio)
#     except aplException as error:
#         print(error.message)
# 
# def     testCommand(expr):
#     """
#     evaluate an expression that is a system command
# 
#     handle both positive and negative outcomes
#     """
#     try:
#         evaluate(expr, aplCio())
#     except aplException as error:
#         print(error.message)
# 
# def     testResult(expr, overrideLazy=False):
#     """
#     evaluate an expression then format and print the result
# 
#     handle both positive and negative outcomes
# 
#     Often the negative outcome in lazy evaluation mode involves printing backspaces
# 
#         doctest.NORMALIZE_WHITESPACE = 1
# 
#     does not have the desired effect, hence the messing around the with the evaluation mode.
#     """
#     if overrideLazy:
#         overrideLazy = not systemVariables.eagerEvaluation()
# 
#     if overrideLazy:
#         systemVariables.setEvaluationMode(1)
# 
#     try:
#         cio = aplCio()
#         cio.printResult(evaluate(expr, cio))
#     except aplException as error:
#         print(error.message)
# 
#     if overrideLazy:
#         systemVariables.setEvaluationMode(0)
# 
# Path: test/base.py
# def     saveIndexOrigin():
#     """
#     return ⎕IO so the test function can save it
#     """
#     return systemVariables.indexOrigin()
# 
# def     setIndexOrigin(io):
#     """
#     set ⎕IO:  it is assumed the test function has saved and will restore the original value
#     """
#     systemVariables.setIndexOrigin(io)
# 
# def     restoreIndexOrigin(io):
#     """
#     restore ⎕IO previously retrieved by the test function using saveIndexOrigin
#     """
#     systemVariables.setIndexOrigin(io)


# Path: test/parser.py
from test.base import preamble, testOutput, testCommand, testResult as test
from test.base import saveIndexOrigin, setIndexOrigin, restoreIndexOrigin
        import doctest

#!/usr/bin/python3
"""
    doctest style unit tests for the APL parser

    WIP - grows as evaluate.py is extended.

    The tests in this module exercise the functions in evaluate.py:
      - recognition of numbers
      - recognition of strings
      - recognition of names
      - tack functions (⊢ and ⊣)
      - scalar invocation of monadic and dyadic functions
      - parentheses to alter order of execution
      - parsing of vector quantities - including mixed/nested vectors
      - printing of array quantities
      - array prototypes
      - scan and reduce operators
      - parsing of output operators (⎕ ⍞) - but not input operators
      - system variables
      - system commands

    All but the system commnd tests pass an APL expression to the evaluate function.
    Almost all tests are positive.

    Note:
        testDyadic --eager      # run with eager evaluation
        testDyadic --lazy       # run with lazy evaluation
"""


from test.base import saveIndexOrigin, setIndexOrigin, restoreIndexOrigin