コード例 #1
0
ファイル: base.py プロジェクト: vdel/CoMFoRT
                if n==id:
                    return behavior
        else:
            return __behaviorRegistry[name][0][1]
    return None

def newFromBehavior(name, id=None):
    """Given a name, return a behaviored ContentLine or Component."""
    name = name.upper()
    behavior = getBehavior(name, id)
    if behavior is None:
        raise VObjectError("No behavior found named %s" % name)
    if behavior.isComponent:
        obj = Component(name)
    else:
        obj = ContentLine(name, [], '')
    obj.behavior = behavior
    obj.isNative = False
    return obj


#--------------------------- Helper function -----------------------------------
def backslashEscape(s):
    s=s.replace("\\","\\\\").replace(";","\;").replace(",","\,")
    return s.replace("\r\n", "\\n").replace("\n","\\n").replace("\r","\\n")

#------------------- Testing and running functions -----------------------------
if __name__ == '__main__':
    import tests
    tests._test()   
コード例 #2
0
ファイル: run_tests.py プロジェクト: viperproject/2vyper
def test_file(file):
    _test(file)
コード例 #3
0
ファイル: edsac.py プロジェクト: nishio/EDSAC-on-browser
                        action='store_true',
                        help='show runnning instruction')
    parser.add_argument('--debug-io',
                        dest='debug_io',
                        action='store_true',
                        help='use a line for one IO')
    parser.add_argument('--tape',
                        dest='tape',
                        action='store',
                        default='square.txt',
                        help='filename of tape to run (default=square.txt)')

    args = parser.parse_args()
    SHOW_RUNNNING_INSTRUCTION = args.show_runnning_instruction
    DEBUG_IO = args.debug_io

    if args.test:
        print "Running tests..."
        from tests import _test
        edsac = Edsac()
        _test(edsac)
    elif globals().get("DEBUG"):
        # make easy debug on ipython
        print "Running tests..."
        import tests
        reload(tests)
        edsac = Edsac()
        tests._test(edsac)
    else:
        main()
コード例 #4
0

def newFromBehavior(name, id=None):
    """Given a name, return a behaviored ContentLine or Component."""
    name = name.upper()
    behavior = getBehavior(name, id)
    if behavior is None:
        raise VObjectError("No behavior found named %s" % name)
    if behavior.isComponent:
        obj = Component(name)
    else:
        obj = ContentLine(name, [], '')
    obj.behavior = behavior
    obj.isNative = False
    return obj


#--------------------------- Helper function -----------------------------------
def backslashEscape(s):
    if isinstance(s, basestring):
        s = s.replace("\\", "\\\\").replace(";", "\;").replace(",", "\,")
        return s.replace("\r\n", "\\n").replace("\n",
                                                "\\n").replace("\r", "\\n")
    return ''


#------------------- Testing and running functions -----------------------------
if __name__ == '__main__':
    import tests
    tests._test()
コード例 #5
0
ファイル: edsac.py プロジェクト: BigEd/EDSAC-on-browser
                        action='store_true',
                        help='show runnning instruction')
    parser.add_argument('--debug-io',
                        dest='debug_io',
                        action='store_true',
                        help='use a line for one IO')
    parser.add_argument('--tape',
                        dest='tape',
                        action='store',
                        default='square.txt',
                        help='filename of tape to run (default=square.txt)')

    args = parser.parse_args()
    SHOW_RUNNNING_INSTRUCTION = args.show_runnning_instruction
    DEBUG_IO = args.debug_io

    if args.test:
        print "Running tests..."
        from tests import _test
        edsac = Edsac()
        _test(edsac)
    elif globals().get("DEBUG"):
        # make easy debug on ipython
        print "Running tests..."
        import tests
        reload(tests)
        edsac = Edsac()
        tests._test(edsac)
    else:
        main()