def testRepl3Sub(): # test zur ueberleitung auf ar_codeListParameters te.checkComplainAndAdjustExpected( 0) codeList= codeListMake( codeListConfigMake(), codeListParametersMake( nil)) te.test( codeListCheck( codeList)) te.test( codeListConfigCheck( codeListGetConfig( codeList))) te.test( codeListParametersCheck( codeListGetParameters( codeList))) codeList= codeListMake( codeListConfigMake(), codeListParametersMake( ConsSimple( true, nil))) te.test( codeListCheck( codeList)) te.test( codeListConfigCheck( codeListGetConfig( codeList))) codeListParameters= codeListGetParameters( codeList) te.test( codeListParametersCheck( codeListParameters)) te.test( id( true) == id( codeListGetParameterValues( codeList).car())) te.test( id( true) == id( codeListGetParameterValuesCdrContainer( codeList).cdr().car())) te.test( id( true) == id( codeListParametersGetParameterValues( codeListParameters).car())) te.test( id( true) == id( codeListGetParameterValuesCdrContainer2( codeList).cdr().cdr().car())) te.checkComplainAndAdjustExpected( 10)
def testEnvironment1(): te.checkComplainAndAdjustExpected(0) e1 = Environment() try: e1.get("a") except KeyError: test(True, True) e1.set("a", 1) test(1, e1.get("a")) e2 = e1.newChild() # | Environment( e1) test(1, e2.get("a")) try: e2.get("b") except KeyError: test(True, True) te.test(e2.has_key("a")) te.test(not e2.has_key("b")) te.checkComplainAndAdjustExpected(6)
def testConsTrait5(): def testCrCr( ex, ou, htEnvLocals= None): if None==htEnvLocals: htEnvLocals= dict() test( ConsRepr( ex ).repr_wrapped( htEnvLocals), ConsRepr( ou ).repr_wrapped( htEnvLocals)) s= Symbol cs= ConsSimple te.checkComplainAndAdjustExpected( 0) uNames.next( usRename( ConsSimple, 'cs')) uNames.next( usRename( Symbol, 's')) csTest5= consesMake( 1, 2, 3, 4, 5) csTest2= consesMake( 6, 7) csTest1= consesMake( 8) testCrCr( csTest5.cdr().cdr().cdr().cdr(), consesDistanceSeek( csTest5, 0)) testCrCr( csTest5.cdr().cdr().cdr(), consesDistanceSeek( csTest5, 1)) testCrCr( csTest5.cdr().cdr(), consesDistanceSeek( csTest5, 2)) testCrCr( csTest5.cdr(), consesDistanceSeek( csTest5, 3)) testCrCr( csTest5, consesDistanceSeek( csTest5, 4)) testCrCr( csTest5, consesDistanceSeek( csTest5, 5)) testCrCr( csTest5, consesDistanceSeek( csTest5, 6)) testCrCr( csTest2, consesDistanceSeek( csTest2, 6)) testCrCr( csTest1, consesDistanceSeek( csTest1, 6)) uNames.undo() uNames.undo() te.checkComplainAndAdjustExpected( 9)
def testHashes1(): te.checkComplainAndAdjustExpected(0) c1 = ConsSimple(1, 2) c2 = ConsSimple(1, 2) cons_addType(c1, ConsType("test1")) cons_addType(c1, ConsType("test2")) cons_delType(c2, ConsType("test1")) test(2, len(ht_cons_consid2consAndTypeSet[id(c1)][1])) test(True, ConsType("test1") in ht_cons_consid2consAndTypeSet[id(c1)][1]) test(True, ConsType("test2") in ht_cons_consid2consAndTypeSet[id(c1)][1]) test(0, len(ht_cons_consid2consAndTypeSet[id(c2)][1])) test(True, set([id(c1)]) == (ht_cons_consType2ConsidSetAndFunctionSet[ConsType("test1")][0])) cons_delType(c1, ConsType("test1")) test(1, len(ht_cons_consid2consAndTypeSet[id(c1)][1])) test(False, ConsType("test1") in ht_cons_consid2consAndTypeSet[id(c1)][1]) test(True, ConsType("test2") in ht_cons_consid2consAndTypeSet[id(c1)][1]) test(0, len(ht_cons_consid2consAndTypeSet[id(c2)][1])) test(False, set([id(c1)]) == (ht_cons_consType2ConsidSetAndFunctionSet[ConsType("test1")][0])) te.checkComplainAndAdjustExpected(10)
def testInterpreter3(): te.checkComplainAndAdjustExpected( 0) i= Interpreter() i.evalToken( s( '(')) # baustelle: testbarkeit der repl te.checkComplainAndAdjustExpected( 0)
def testSymbols2(): te.checkComplainAndAdjustExpected( 0) test( 'ar_list', ar_list) sy= Symbol( 'sy') sy2= Symbol( 'sy') te.test( not id( sy) == id( sy2)) test( sy, sy2) test( "Symbol( 'sy')", repr( sy)) test( "Symbol( 'sy')", repr( sy2)) te.checkComplainAndAdjustExpected( 5)
def testConsTrait4(): def testCrCr( ex, ou, htEnvLocals= None): if None==htEnvLocals: htEnvLocals= dict() test( ConsRepr( ex ).repr_wrapped( htEnvLocals), ConsRepr( ou ).repr_wrapped( htEnvLocals)) s= Symbol cs= ConsSimple te.checkComplainAndAdjustExpected( 0) uNames.next( usRename( ConsSimple, 'cs')) uNames.next( usRename( Symbol, 's')) test( nil, consesMake()) testCrCr( cs( 1, nil), consesMake( 1)) testCrCr( cs( 1, cs( 2, nil)), consesMake( 1, 2)) testCrCr( cs( ar_list, nil), listMake()) testCrCr( cs( ar_assoc, nil), assocMake()) testCrCr( cs( ar_assoc, nil), assocMakeIntern()) as1= assocMake( consesMake( '1'), consesMake( '2')) as2= assocMakeIntern( assocElemMake( '1'), assocElemMake( '2')) exp1= "assocInternGeneral( assocElemGeneral( '1'), assocElemGeneral( '2'))" exp2= "assocGeneral( consesMake( '1'), consesMake( '2'))" exp3= "consesMake( s( 'ar_assoc'), consesMake( s( 'ar_assocElem'), '1'), consesMake( s( 'ar_assocElem'), '2'))" test( exp1, ConsRepr( as1).repr_wrapped( None, [ CpctReprAssocInternGeneral, CpctReprAssocElemGeneral])) test( exp1, ConsRepr( as2).repr_wrapped( None, [ CpctReprAssocInternGeneral, CpctReprAssocElemGeneral])) test( exp2, ConsRepr( as1).repr_wrapped( None, [ CpctReprAssocGeneral, CpctReprConses])) test( exp2, ConsRepr( as2).repr_wrapped( None, [ CpctReprAssocGeneral, CpctReprConses])) test( exp3, ConsRepr( as1).repr_wrapped( None, [ CpctReprConses])) test( exp3, ConsRepr( as2).repr_wrapped( None, [ CpctReprConses])) testCrCr( as1, as2) uNames.undo() uNames.undo() te.checkComplainAndAdjustExpected( 13)
def testConsTrait1(): te.checkComplainAndAdjustExpected( 0) cs1= ConsSimple( 1, 2) cs2= ConsSimple( cs1, ConsSimple( cs1, cs1)) ctcs2= ConsTrait( cs2) ctcs2parameters= ctcs2.find_repetitions_parameter_template() ctcs2.find_repetitions( ctcs2parameters) test( id( cs2.ar), id( cs2.dr.ar)) test( id( cs2.ar), id( cs2.dr.dr)) test( id( ctcs2.ar), id( ctcs2.dr.ar)) test( id( ctcs2.ar), id( ctcs2.dr.dr)) test( "ConsSimple( ConsSimple( 1, 2), ConsSimple( ConsSimple( 1, 2), ConsSimple( 1, 2)))", ctcs2.repr_wrapped()) test( "ConsSimple( repr_1, ConsSimple( repr_1, repr_1))", ctcs2.repr_wrapped( ctcs2parameters[ 'ht_selfid2Name'])) # problem P001 dabei: ht_selfid2Name kann nicht von Hand bereitgestellt werden, # da hier an ConsSimple gebunden test( 'repr_1', ctcs2parameters[ 'ht_selfid2Name'][ id( ctcs2.ar)]) crcs2parameters= ConsRepr( cs2).find_repetitions_parameter_template() ConsRepr( cs2).find_repetitions( crcs2parameters) test( "ConsSimple( ConsSimple( 1, 2), ConsSimple( ConsSimple( 1, 2), ConsSimple( 1, 2)))", ConsRepr( cs2).repr_wrapped()) test( "ConsSimple( repr_1, ConsSimple( repr_1, repr_1))", ConsRepr( cs2).repr_wrapped( crcs2parameters[ 'ht_selfid2Name'])) # problem P001 geloest test( "ConsSimple( ox1, ConsSimple( ox1, ox1))", ConsRepr( cs2).repr_wrapped( dict( { id( cs1): 'ox1'}))) test( 'repr_1', crcs2parameters[ 'ht_selfid2Name'][ id( cs2.ar)]) te.checkComplainAndAdjustExpected( 11)
def testConsTrait2(): te.checkComplainAndAdjustExpected( 0) def f( a, b, c): return ConsSimple( 'f', ConsSimple( a, ConsSimple( b, c))) class crsF( CpctRepr): def test( self): try: return 'f' == self.consWrapped.car() except: return False def paramList( self): assert( 0==len( self.lParams)) self.lParams.append( self.consWrapped.cdr().car()) self.lParams.append( self.consWrapped.cdr().cdr().car()) self.lParams.append( self.consWrapped.cdr().cdr().cdr()) return self.lParams def repr_wrapped( self, ht_selfid2Name, lCpctRepr): assert( 3==len( self.lParams)) return 'f( %s, %s, %s)' % tuple( self.lParams) uNames.next( usRename( ConsSimple, 'cs')) cs= ConsSimple cs1= cs( 'q', cs( 'f', cs( cs( 3, 4), cs( cs( 5, 6), cs( 7, 8))))) cs2= cs( 'q', f( cs( 3, 4), cs( 5, 6), cs( 7, 8))) rep1= "cs( 'q', cs( 'f', cs( cs( 3, 4), cs( cs( 5, 6), cs( 7, 8)))))" rep2= "cs( 'q', f( cs( 3, 4), cs( 5, 6), cs( 7, 8)))" test( rep1, ConsRepr( cs1).repr_wrapped()) test( rep2, ConsRepr( cs1).repr_wrapped( None, [crsF])) test( rep2, ConsRepr( cs2).repr_wrapped( None, [crsF])) test( rep1, ConsRepr( cs2).repr_wrapped()) uNames.undo() te.checkComplainAndAdjustExpected( 4)
def testInterpreterGeneral4( ConsClass): # pruefung des execute-symbols (erstes symbol einer Liste) te.checkComplainAndAdjustExpected( 0) i= Interpreter() test( False, i.currentEvalTokenIsInExecutePosition()) i.evalToken( cs( ar_value, s( '('))) test( False, i.currentEvalTokenIsInExecutePosition()) i.evalToken( cs( ar_value, s( 'a'))) test( True, i.currentEvalTokenIsInExecutePosition()) i.evalToken( cs( ar_value, s( 'a'))) test( False, i.currentEvalTokenIsInExecutePosition()) i.evalToken( cs( ar_value, s( ')'))) test( False, i.currentEvalTokenIsInExecutePosition()) i= Interpreter() test( False, i.currentEvalTokenIsInExecutePosition()) i.evalToken( cs( ar_value, s( '('))) test( False, i.currentEvalTokenIsInExecutePosition()) i.evalToken( cs( ar_value, s( '('))) test( False, i.currentEvalTokenIsInExecutePosition()) i.evalToken( cs( ar_value, s( 'a'))) test( True, i.currentEvalTokenIsInExecutePosition()) i.evalToken( cs( ar_value, s( 'a'))) test( False, i.currentEvalTokenIsInExecutePosition()) i.evalToken( cs( ar_value, s( ')'))) test( True, i.currentEvalTokenIsInExecutePosition()) i.evalToken( cs( ar_value, s( ')'))) test( False, i.currentEvalTokenIsInExecutePosition()) te.checkComplainAndAdjustExpected( 12)
def testSymbols3(): te.checkComplainAndAdjustExpected( 0) s1= Symbol( 's1') s2= Symbol( 's2') s3= Symbol( 's3') s4= Symbol( 's4') s5= Symbol( 's5') typeSymbol.symAdd( s2, [s1]) typeSymbol.symAdd( s3, [s2]) typeSymbol.symAdd( s4, [s3]) typeSymbol.symAdd( s5, [s4]) te.test( typeSymbolChk( s5, s1)) typeSymbolNot.symAdd( s4, [s2]) te.test( not typeSymbolChk( s5, s1)) te.test( not typeSymbolChk( s5, s2)) te.test( typeSymbolChk( s5, s3)) te.test( typeSymbolChk( s5, s4)) te.test( not typeSymbolChk( s4, s1)) te.test( not typeSymbolChk( s4, s2)) te.test( typeSymbolChk( s4, s3)) te.test( typeSymbolChk( s3, s1)) te.test( typeSymbolChk( s3, s2)) te.test( typeSymbolChk( s2, s1)) typeSymbol.symDel( s5) typeSymbol.symDel( s4) typeSymbol.symDel( s3) typeSymbol.symDel( s2) typeSymbolNot.symDel( s4) te.checkComplainAndAdjustExpected( 11)
def testConsTrait6(): def testCrCr( ex, ou, htEnvLocals= None): if None==htEnvLocals: htEnvLocals= dict() test( ConsRepr( ex ).repr_wrapped( htEnvLocals), ConsRepr( ou ).repr_wrapped( htEnvLocals)) s= Symbol cs= ConsSimple te.checkComplainAndAdjustExpected( 0) uNames.next( usRename( ConsSimple, 'cs')) uNames.next( usRename( Symbol, 's')) cs= consesMakeRest( 1, 2, 3, 4, 6) test( 'cs( 1, cs( 2, cs( 3, cs( 4, 6))))', ConsRepr( cs).repr_wrapped()) test( 'consesMakeRest( 1, 2, 3, 4, 6)', ConsRepr( cs).repr_wrapped( None, [ CpctReprConsesRest ])) test( 'cs( 1, cs( 2, cs( drei, cs( 4, 6))))', ConsRepr( cs).repr_wrapped( { id( 3):'drei'} )) test( 'cs( 1, cs( 2, cs( drei, cs( 4, 6))))', ConsRepr( cs).repr_wrapped( None, [ CpctReprHTselfID2NameCreate( { id( 3):'drei'} ) ] )) test( 'drei', ConsRepr( 3).repr_wrapped( { id( 3):'drei'} )) test( 'drei', ConsRepr( 3).repr_wrapped( None, [ CpctReprHTselfID2NameCreate( { id( 3):'drei'} ) ] )) # 0b539c705e06404d83a6966c52cb08a5 test( 'consesMakeRest( 1, 2, drei, 4, 6)', ConsRepr( cs).repr_wrapped( { id( 3):'drei'}, [ CpctReprConsesRest ] )) test( 'consesMakeRest( 1, 2, drei, 4, 6)', ConsRepr( cs).repr_wrapped( None, [ CpctReprHTselfID2NameCreate( { id( 3):'drei'}), CpctReprConsesRest ] )) test( 'consesMakeRest( 1, 2, drei, 4, 6)', ConsRepr( cs).repr_wrapped( None, [ CpctReprConsesRest, CpctReprHTselfID2NameCreate( { id( 3):'drei'})] )) # 0b539c705e06404d83a6966c52cb08a5 cs2= cs.cdr().cdr() test( 'cs( 3, cs( 4, 6))', ConsRepr( cs2).repr_wrapped()) test( 'cs( 1, cs( 2, cs2))', ConsRepr( cs).repr_wrapped( { id( cs2):'cs2'})) test( 'consesMakeRest( 1, 2, 3, 4, 6)', ConsRepr( cs).repr_wrapped( { id( cs2):'cs2'}, [CpctReprConsesRest])) # die schwaeche, weswegen CpctReprHTselfID2NameCreate eingefuehrt wurde test( 'consesMakeRest( 1, 2, cs2)', ConsRepr( cs).repr_wrapped( None, [ CpctReprHTselfID2NameCreate( { id( cs2):'cs2'}), CpctReprConsesRest])) # die Loesung uNames.undo() uNames.undo() te.checkComplainAndAdjustExpected( 13)
def testConsAbstraction4(): # pruefung von mehrfach-referenzierung und zyklen te.checkComplainAndAdjustExpected( 0) CACH= makeConsAbstractCarAutoHistory( ConsSimple, ConsSimple) CACH.__name__= 'CACH' c1= CACH( 1, 2) c2= CACH( c1, c1) test( "CACH( CACH( 1, 2), CACH( 1, 2))", ConsTrait( c2).repr_wrapped()) c1Wrapped= c1.consWrapped testCrCr( cs( cs( consHistory, cs( 1, nil)), 2), c1Wrapped) testCrCr( cs( cs( consHistory, cs( c1Wrapped, nil)), c1Wrapped), c2.consWrapped, { id( c1Wrapped): 'c1Wrapped'}) c2.car( c1) c2.cdr( c1) test( "CACH( CACH( 1, 2), CACH( 1, 2))", ConsTrait( c2).repr_wrapped()) testCrCr( cs( cs( consHistory, cs( 1, nil)), 2), c1Wrapped) testCrCr( cs( cs( consHistory, cs( c1Wrapped, cs( c1Wrapped, nil))), c1Wrapped) , c2.consWrapped, { id( c1Wrapped): 'c1Wrapped'}) c1.cdr( c2) # die zyklen sind noch nicht zufriedenstellend test( "CACH( 1, CACH( CACH( 1, <cycle>), CACH( 1, <cycle>)))", ConsTrait( c1).repr_wrapped()) test( "CACH( CACH( 1, CACH( <cycle>, <cycle>)), CACH( 1, CACH( <cycle>, <cycle>)))", ConsTrait( c2).repr_wrapped()) # aber jetzt test( "CACH( 1, c2)", ConsRepr( c1).repr_wrapped( { id( c2): 'c2'})) test( "CACH( c1, c1)", ConsRepr( c2).repr_wrapped( { id( c1): 'c1'})) te.checkComplainAndAdjustExpected( 10)
def testConsAbstraction2(): te.checkComplainAndAdjustExpected( 0) CACH= makeConsAbstractCarHistory( ConsSimple, ConsSimple) CACH.__name__= 'CACH' cach1= CACH( 1, 2) test( 'CACH( 1, 2)', ConsTrait( cach1).repr_wrapped()) testCrCr( cs( cs( consHistory, cs( 1, nil)), 2), cach1.consWrapped) test( 1, cach1.car()) test( 2, cach1.cdr()) cach1.car( 3) cach1.cdr( 4) testCrCr( cs( cs( consHistory, cs( 3, nil)), 4), cach1.consWrapped) test( 3, cach1.car()) test( 4, cach1.cdr()) te.checkComplainAndAdjustExpected( 7)
def testRepl4(): te.checkComplainAndAdjustExpected( 0) # ios= InterpreterOverridings() # i= Interpreter() # i.readTokenRawInput= ios.readTokenRawInput # i.essentials_macro_function.ess_print= ios.ess_ess_print # i.s_print= ios.s_print ( ios, i)= makeOverridenInterpreter() ios.setInputString( '(pyprint (pyprint (q1 (q1') # )))) #ios.setInputString( '(pyprint') # ) ios.setEOF() i.replStep() while not id( nil) == id( i.readbuf.cdr()): # print i.readbuf.cdr().car() i.replStep() stack= stackMakeFromInterpreter( i) stack_cloned= stackClone4Try1( stack) stack_cloned2= stackClone4Try1( stack_cloned) def stack_repr_wrapped( stack): return ConsRepr( stack).repr_wrapped( None, [ CpctReprStack, CpctReprCodeListConfigMake, CpctReprConses, CpctReprConsesRest]) stack_repr= stack_repr_wrapped( stack) stack_cloned_repr= stack_repr_wrapped( stack_cloned) stack_cloned2_repr= stack_repr_wrapped( stack_cloned2) # CpctReprStack / CpctReprStack2 zeigt bei falscher Verknuepfung die Fehler, die anderen CpctRepr* nicht test( stack_repr, stack_cloned_repr) test( stack_repr, stack_cloned2_repr) te.checkComplainAndAdjustExpected( 2)
def testRepl2(): # auf zu neuen Tests def testCrCr( ex, ou, d= None): htEnvLocals= { id( env_locals1) : "env_locals1"} if not None == d: htEnvLocals.update( d) test( ConsRepr( ex ).repr_wrapped( htEnvLocals), ConsRepr( ou ).repr_wrapped( htEnvLocals)) te.checkComplainAndAdjustExpected( 0) def loop1( ios, i): while [] == ios.ess_ess_pront: i.replStep() def loopEmptyString( ios, i): while not None == ios.input_string: i.replStep() def loop2( ios, i): while [] == ios.ess_ess_pront: #print 'ios.ess_ess_pront ', ios.ess_ess_pront print 'i.codeLevel ', i.codeLevel print 'i.readbuf ', i.readbuf print 'i.macroBufRepr() ', i.macroBufRepr() print 'i.quotationModeIsActivated() ', i.quotationModeIsActivated() i.replStep() subtestCount= [0] def subtest( query, results, loop= loop1): subtestCount[0]+= 1 ( ios, i)= makeOverridenInterpreter() env_locals1= i.getEnvLocals() ios.__init__() ios.setInputString( query) loop( ios, i) test( results, ios.ess_ess_pront) ios.setEOF() try: i.repl() te.test( False) except EOFError: te.test( True) cmpStatementsCount= [0] def cmpStatements( stmt1, stmt2, loop= loop1): cmpStatementsCount[0]+= 1 ( ios1, i1)= makeOverridenInterpreter() env_locals1= i1.getEnvLocals() ios1.__init__() ios1.setInputString( stmt1) loop( ios1, i1) ( ios2, i2)= makeOverridenInterpreter() env_locals1= i2.getEnvLocals() ios2.__init__() ios2.setInputString( stmt2) loop( ios2, i2) ios1.setEOF() ios2.setEOF() try: i1.repl() te.test( False) except EOFError: te.test( True) try: i2.repl() te.test( False) except EOFError: te.test( True) #test( results, ios.ess_ess_pront) test( ios1.ess_ess_pront, ios2.ess_ess_pront) interpretCount= [0] def interpret( query, loop= loop1): interpretCount[0]+= 1 ( ios, i)= makeOverridenInterpreter() env_locals1= i.getEnvLocals() ios.__init__() ios.setInputString( query) loop( ios, i) ret= ios.ess_ess_pront ios.setEOF() try: i.repl() te.test( False) except EOFError: te.test( True) return ret codeListConfigMake= 'codeListConfigMake( ...)' result_pyprint_1= ConsRepr( cs( s( '1'), nil)).repr_wrapped() result_pyprint_1_2= ConsRepr( cs( s( '1'), cs( s( '2'), nil))).repr_wrapped() if InterpreterStructures.alteVariante: result_pyprint_ql_1= ConsRepr( cs( cs( ar_codeList, cs( codeListConfigMake, cs( s( '1'), nil))), nil)).repr_wrapped() result_pyprint_ql_1_2= ConsRepr( cs( cs( ar_codeList, cs( codeListConfigMake, cs( s( '1'), cs( s( '2'), nil)))), nil)).repr_wrapped() else: result_pyprint_ql_1= ConsRepr( cs( cs( ar_codeList, cs( codeListConfigMake, cs( ar_codeListParameters, cs( s( '1'), nil)))), nil)).repr_wrapped() result_pyprint_ql_1_2= ConsRepr( cs( cs( ar_codeList, cs( codeListConfigMake, cs( ar_codeListParameters, cs( s( '1'), cs( s( '2'), nil))))), nil)).repr_wrapped() subtest( '(pyprint (q1 1))', [(result_pyprint_1,)]) subtest( '(pyprint (ql 1))', [(result_pyprint_ql_1,)]) subtest( '(pyprint (q1 1) (q1 2))', [(result_pyprint_1_2,)]) # geloest, ging bislang nicht subtest( '(pyprint (ql 1 2))', [(result_pyprint_ql_1_2,)]) # geloest, ging bislang nicht subtest( '(pyprint (eval1 (q1 (q1 1))))', [(result_pyprint_1,)]) # 0fa6e6b10e2643d981504f9fa67adc82 uNames.next( usRename( ConsSimple, 'cs')) uNames.next( usRename( Symbol, 's')) if InterpreterStructures.alteVariante: subtest( '(pyprint (ql q1 1))', [( ConsRepr( cs( cs( ar_codeList, cs( codeListConfigMake, cs( s( 'q1'), cs( s( '1'), nil)))), nil)).repr_wrapped( None, []), )]) subtest( '(pyprint (q1 (q1 1)))', [( ConsRepr( cs( cs( ar_codeList, cs( codeListConfigMake, cs( s( 'q1'), cs( s( '1'), nil)))), nil)).repr_wrapped( None, [ CpctReprCodeListConfigMake]), )]) else: subtest( '(pyprint (ql q1 1))', [( ConsRepr( cs( cs( ar_codeList, cs( codeListConfigMake, cs( ar_codeListParameters, cs( s( 'q1'), cs( s( '1'), nil))))), nil)).repr_wrapped( None, []), )]) subtest( '(pyprint (q1 (q1 1)))', [( ConsRepr( cs( cs( ar_codeList, cs( codeListConfigMake, cs( ar_codeListParameters, cs( s( 'q1'), cs( s( '1'), nil))))), nil)).repr_wrapped( None, [ CpctReprCodeListConfigMake]), )]) uNames.undo() uNames.undo() cmpStatements( '(pyprint (ql q1 1))', '(pyprint (q1 (q1 1)))') subtest( '(pyprint (eval1 (ql q1 1)))', [(result_pyprint_1,)]) subtest( '(pyprint (eval (q1 q1) (q1 1)))', [(result_pyprint_1,)]) subtest( '(pyprint (eval1 (eval1 (ql q1 (q1 1)))))', [(result_pyprint_1,)]) # subtest( '(pyprint (eval (eval (q1 q1) (q1 (ql q1 1)))))', [(result_pyprint_1,)]) # baustelle: fehler cmpStatements( '(pyprint (q1 (ql q1 1)))', '(pyprint (eval (q1 q1) (q1 (ql q1 1))))', loop1) cmpStatements( '(pyprint (q1 (ql q1 1)))', '(pyprint (q1 (ql q1 1)))', loop1) uNames.next( usRename( ConsSimple, 'cs')) uNames.next( usRename( Symbol, 's')) if InterpreterStructures.alteVariante: test( [("cs( cs( s( 'ar_codeList'), cs( 'codeListConfigMake( ...)', cs( s( 'ql'), cs( s( 'q1'), cs( s( '1'), s( 'nil')))))), s( 'nil'))",)], interpret( '(pyprint (q1 (ql q1 1)))')) else: test( [("cs( cs( s( 'ar_codeList'), cs( 'codeListConfigMake( ...)', cs( s( 'ar_codeListParameters'), cs( s( 'ql'), cs( s( 'q1'), cs( s( '1'), s( 'nil'))))))), s( 'nil'))",)], interpret( '(pyprint (q1 (ql q1 1)))')) uNames.undo() uNames.undo() cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (q1 (q1 1))))') # 0fa6e6b10e2643d981504f9fa67adc82, 64005373aae94f3a9314d303d5f4016e cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (eval (q1 q1) (q1 (q1 1)))))') # 64005373aae94f3a9314d303d5f4016e cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (eval (q1 eval) (q1 (q1 q1)) (q1 (q1 (q1 1))))))') # 64005373aae94f3a9314d303d5f4016e cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (eval1 (q1 (q1 (q1 1))))))') # 64005373aae94f3a9314d303d5f4016e cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (eval1 (eval1 (q1 (q1 (q1 (q1 1))))))))') # 64005373aae94f3a9314d303d5f4016e cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (ql q1 1)))') # 64005373aae94f3a9314d303d5f4016e cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (eval1 (ql q1 (q1 1)))))') # 64005373aae94f3a9314d303d5f4016e cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (eval1 (ql ql q1 1))))') # 64005373aae94f3a9314d303d5f4016e cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (eval1 (eval (q1 ql) (q1 ql) (q1 q1) (q1 1)))))') # 64005373aae94f3a9314d303d5f4016e cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (eval1 (eval (q1 eval) (q1 (q1 ql)) (q1 (q1 ql)) (q1 (q1 q1)) (q1 (q1 1))))))') # 64005373aae94f3a9314d303d5f4016e cmpStatements( '(pyprint (q1 1))', '(eval1 (q1 (pyprint (q1 1))))') # das fehlte noch cmpStatements( '(pyprint (q1 1))', '(set2 (q1 a) (q1 1)) (pyprint a)') # NativeFunctionSet2 cmpStatements( '(pyprint (q1 1))', '(set2 (q1 b) (set2 (q1 a) (q1 1))) (pyprint b)') cmpStatements( '(pyprint (q1 1))', '(set2 (q1 a) (q1 1)) (env-push-new0) (pyprint a)') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 a) (q1 1)) (env-push-new0) (set2 (q1 a) (q1 2)) (pyprint a)') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 a) (q1 1)) (env-push-new0) (set2 (q1 a) (q1 2)) (pyprint a) (env-pop0)') cmpStatements( '(pyprint (q1 1))', '(set2 (q1 a) (q1 1)) (env-push-new0) (set2 (q1 a) (q1 2)) (env-pop0) (pyprint a)') cmpStatements( '(pyprint (q1 1)) (pyprint (q1 2))', '(pyprint (q1 1)) (pyprint (q1 2))') cmpStatements( '(pyprint (q1 1)) (pyprint (q1 1)) (pyprint (q1 2)) (pyprint (q1 1))', '(set2 (q1 a) (q1 1)) (pyprint a) (env-push-new0) (pyprint a) (set2 (q1 a) (q1 2)) (pyprint a) (env-pop0) (pyprint a)') cmpStatements( '(pyprint (q1 1))', '(eval1 (q1 (pyprint (q1 1))))') cmpStatements( '(pyprint (q1 1))', '(eval1 (q1 (prog (pyprint (q1 1)))))') cmpStatements( '(pyprint (q1 1)) (pyprint (q1 2))', '(eval1 (q1 (prog (pyprint (q1 1)) (pyprint (q1 2)))))') cmpStatements( '(pyprint (prog))', '(pyprint (prog (ql liefert nil)))') cmpStatements( '(pyprint (prog))', '(pyprint (prog (ql liefert nil)))') cmpStatements( '(set2 (q1 1) (q1 1)) (set2 (q1 2) (q1 2)) (pyprintconses (conses 1 2) )', '(set2 (q1 1) (q1 1)) (set2 (q1 2) (q1 2)) (pyprintconses (cons 1 (cons 2 nil)))') cmpStatements( '(pyprint (q1 1)) (pyprint (q1 2))', '(eval1 (ql prog (pyprint (q1 1)) (pyprint (q1 2))))') cmpStatements( '(pyprint (q1 1)) (pyprint (q1 2))', '(prog (pyprint (q1 1)) (pyprint (q1 2)))') #interessanterweise funktioniert das cmpStatements( '(pyprint (q1 1)) (pyprint (q1 2))', '(eval1 (qswap2 (pyprint (q1 2)) (pyprint (q1 1))))') cmpStatements( '(pyprint (q1 1)) (pyprint (q1 2)) (pyprintconses (conses (conses (q1 1)) (conses (q1 2))))' , '(pyprintconses (eval1 (qswap2 (pyprint (q1 2)) (pyprint (q1 1)))))') cmpStatements( '(pyprint (q1 1) (q1 2)) (pyprintconses (conses (q1 1) (q1 2)))' , '(pyprintconses (pyprint (q1 1) (q1 2)))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3))', '(pyprint (q1 1) (q1 2) (q1 3))') ### noo begin cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3))', '(pyprint (q1 1) noo (q1 2) (q1 3))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3))', '(eval1 (q1 (pyprint (q1 1) noo (q1 2) (q1 3))))') cmpStatements( '(pyprint (q1 1) nil (q1 2) (q1 3))', '(pyprint (q1 1) (eval1 nil) (q1 2) (q1 3))') cmpStatements( '(pyprint (q1 1) (q1 noo) (q1 2) (q1 3))', '(pyprint (q1 1) (q1 noo) (q1 2) (q1 3))') cmpStatements( '(pyprintconses (q1 1) (q1 2) (q1 3))', '(pyprintconses (q1 1) (eval1 (q1 noo)) (q1 2) (q1 3))') cmpStatements( '(pyprintconses (q1 1) (q1 2) (q1 3))', '(pyprintconses (q1 1) (eval1 (q1 (eval1 (q1 noo)))) (q1 2) (q1 3))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3))', '(pyprint (q1 1) ((macro p (q1 noo))) (q1 2) (q1 3))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3))', '(pyprint (q1 1) noo noo (q1 2) noo (q1 3))') cmpStatements( '(pyprint)', '(pyprint)') cmpStatements( '(pyprintconses)', '(pyprintconses)') cmpStatements( '(pyprint (q1 1) (q1 noo) (q1 2) (q1 3))', '(pyprint (q1 1) (q2 nil noo) (q1 2) (q1 3))') cmpStatements( '(pyprint (q1 2))', '(pyprint noo (q1 2))') cmpStatements( '(pyprint noo)', '(pyprint noo noo noo)') # bugs heben sich auf cmpStatements( '(pyprint (q1 1))', '(pyprint (q1 1) noo)') # beabbbda7ec24dd0ab93e9314546cad0 cmpStatements( '(pyprint)', '(pyprint noo)') # beabbbda7ec24dd0ab93e9314546cad0 cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3))', '(pyprint (q1 1) (unconses (conses (q1 2) (q1 3))))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3))', '(pyprint (q1 1) (unconses (conses (q1 2))) (unconses (conses (q1 3))))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3))', '(pyprint (q1 1) (unconses (conses (q1 2))) noo (unconses (conses (q1 3))))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3))', '(pyprint (q1 1) (unconses (conses noo (q1 2))) (unconses (conses (q1 3))))') ### noo end cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3) (q1 4))', '(pyprint (q1 1) (unconses (conses (q1 2) (q1 3) (q1 4))))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3) (q1 4))', '(pyprint (q1 1) (unconses (conses (q1 2) (q1 3) (q1 4))))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3) (q1 4))', '(pyprint (unconses (conses (unconses (conses (q1 1) (q1 2))) (q1 3) (q1 4))))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3) (q1 4))', '(pyprint (unconses (conses (q1 1) (unconses (conses (q1 2) (q1 3))) (q1 4))))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3) (q1 4))', '(pyprint (unconses (conses (q1 1) (q1 2) (unconses (conses (q1 3) (q1 4))))))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3) (q1 4))', '(pyprint (unconses (conses (unconses (conses (q1 1) (q1 2))) (unconses (conses (q1 3) (q1 4))))))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3) (q1 4))', '(pyprint (unconses (conses (unconses (conses (unconses (conses (q1 1) (q1 2) (q1 3) (q1 4))))))))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3) (q1 4))', '(pyprint (unconses (conses (unconses (eval1 (qswap2 (q1 2) (q1 1)))) (unconses (conses (q1 3) (q1 4))))))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3) (q1 4))', '(pyprint (unconses (conses (unconses (eval1 (qswap2 (q1 2) (q1 1)))) (unconses (eval1 (qswap2 (q1 4) (q1 3)))))))') cmpStatements( '(pyprint (ql conses 1 2 3 4))', '(pyprint (q1 (conses 1 2 3 4)))') cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3) (q1 4))', '(pyprint (unconses (qconses 1 2 3 4)))') # cmpStatements( '(pyprint (q1 1) (q1 2) (q1 3))', '(pyprint (q1 1) (unconses (q1 3)))') # wegen 36268f550bcf4fb88d25868f8ea663bf hack nicht realisierbar, comment soll drin bleiben cmpStatements( '(pyprint (unconses (qconses 1 2 3 4)))', '(eval1 (q1 (pyprint (unconses (qconses 1 2 3 4)))))') cmpStatements( '(pyprint (unconses (qconses 1 2 3 4)))', '(eval (q1 pyprint) (q1 (unconses (qconses 1 2 3 4))))') cmpStatements( '(pyprint (unconses (qconses 1 2 3 4)))', '(eval (unconses (qconses pyprint (q1 1) (q1 2) (q1 3) (q1 4))))') cmpStatements( '(pyprint (unconses (qconses 1 2 3 4)))', '(eval (unconses (qconses pyprint (unconses (qconses 1 2 3 4)))))') cmpStatements( '(pyprint (q1 2))', '(pyprint (fif true (q1 2) (q1 3)))') cmpStatements( '(pyprint true)', '(pyprint true)') cmpStatements( '(pyprint true)', '(set2 (q1 t) true) (pyprint t)') cmpStatements( '(pyprint (q1 3))', '(pyprint (fif nil (q1 2) (q1 3)))') cmpStatements( '(pyprint (q1 2))', '(eval1 (fif true (q1 (pyprint (q1 2))) (q1 (pyprint (q1 3)))))') cmpStatements( '(pyprint (q1 3))', '(eval1 (fif nil (q1 (pyprint (q1 2))) (q1 (pyprint (q1 3)))))') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 t) true) (set2 (q1 f) nil) (eval1 (fif t (q1 (pyprint (q1 2))) (q1 (pyprint (q1 3)))))') cmpStatements( '(pyprint (q1 3))', '(set2 (q1 t) true) (set2 (q1 f) nil) (eval1 (fif f (q1 (pyprint (q1 2))) (q1 (pyprint (q1 3)))))') cmpStatements( '(pyprint (q1 2))', '(eval1 (fif true (unconses (qconses (pyprint (q1 2)) (pyprint (q1 3))))))') cmpStatements( '(pyprint (q1 3))', '(eval1 (fif nil (unconses (qconses (pyprint (q1 2)) (pyprint (q1 3))))))') cmpStatements( '(pyprint nil)', '(pyprint (conses))') cmpStatements( '(pyprint (q1 a) (q1 b))', '(pyprint (q1 a) (unconses (conses)) (q1 b))') # neuheit zu unconses - das ging vor der eliminierung von # cmpStatements( '(pyprint (q1 a) (q1 b))', '(pyprint (q1 a) (unconses) (q1 b))') # baustelle: das geht noch nicht, ist aber auch nicht soo eilig cmpStatements( '(pyprint (q1 a) (q1 b))', '(pyprint (q1 a) ((macro p (q1 (unconses (conses))))) (q1 b))') # cmpStatements( '(pyprint (q1 a) (q1 b))', '(pyprint (q1 a) ((macro2 p (unconses (conses)))) (q1 b))') # das geht noch nicht, vermutlich, da macro2 ar_retValue liefert statt ar_retList cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (q1 (q1 1))))') cmpStatements( '(pyprint (q1 1))', '(set2 (q1 t) (q1 1)) (pyprint (eval1 (q1 t)))') cmpStatements( '(pyprint true)', '(set2 (q1 t) true) (pyprint (eval1 (q1 t)))') cmpStatements( '(pyprint (q1 2))', '(pyprint (fif (eval1 (q1 true)) (q1 2) (q1 3)))') cmpStatements( '(pyprint (q1 3))', '(pyprint (fif (eval1 (q1 nil)) (q1 2) (q1 3)))') cmpStatements( '(pyprint (q1 2))', '(eval1 (fif (eval1 (q1 true)) (q1 (pyprint (q1 2))) (q1 (pyprint (q1 3)))))') cmpStatements( '(pyprint (q1 3))', '(eval1 (fif (eval1 (q1 nil)) (q1 (pyprint (q1 2))) (q1 (pyprint (q1 3)))))') cmpStatements( '(pyprint true)', '(pyprint true)') cmpStatements( '(pyprint true)', '(pyprint (eval1 true))') cmpStatements( '(pyprint true)', '(pyprint (eval1 (eval1 true)))') cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (set2 (q1 b) (q1 c)) (set2 (q1 c) (q1 a)) (pyprint (q1 a))') cmpStatements( '(pyprint (q1 b))', '(set2 (q1 a) (q1 b)) (set2 (q1 b) (q1 c)) (set2 (q1 c) (q1 a)) (pyprint a)') cmpStatements( '(pyprint (q1 c))', '(set2 (q1 a) (q1 b)) (set2 (q1 b) (q1 c)) (set2 (q1 c) (q1 a)) (pyprint (eval1 a))') cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (set2 (q1 b) (q1 c)) (set2 (q1 c) (q1 a)) (pyprint (eval1 (eval1 a)))') cmpStatements( '(pyprint (q1 b))', '(set2 (q1 a) (q1 (pyprint (q1 b)))) (eval1 a)') cmpStatements( ' ', ' ', loopEmptyString) # 59cc177458e34abcb943fd4351d93149 cmpStatements( '', '', loopEmptyString) # 59cc177458e34abcb943fd4351d93149 cmpStatements( '', ' ', loopEmptyString) # 59cc177458e34abcb943fd4351d93149 cmpStatements( '(pyprint (q1 2))', '(eval1 (q1 (pyprint (q1 2))))') cmpStatements( '(pyprint (q1 2))', '(eval1 (thru1 (q1 (pyprint (q1 2)))))') cmpStatements( '(pyprint (q1 (fif true (q1 (pyprint (q1 2))) (q1 (pyprint (q1 3))))))', '(pyprint (ifpre true (pyprint (q1 2)) (pyprint (q1 3))))') cmpStatements( '(pyprint (q1 (fif (eval1 (q1 true)) (q1 (pyprint (q1 2))) (q1 (pyprint (q1 3))))))', '(pyprint (ifpre (eval1 (q1 true)) (pyprint (q1 2)) (pyprint (q1 3))))') cmpStatements( '(pyprint (q1 2))', '(eval1 (eval1 (ifpre (eval1 (q1 true)) (pyprint (q1 2)) (pyprint (q1 3)))))') cmpStatements( '(pyprint (q1 2))', '(eval1 (eval1 (q1 (fif (eval1 (q1 true)) (q1 (pyprint (q1 2))) (q1 (pyprint (q1 3)))))))') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 f) pyprint) (f (q1 2))') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 f) pyprint) ((eval1 (q1 f)) (q1 2))') cmpStatements( '(pyprint (q1 2))', '(if (eval1 (q1 true)) (pyprint (q1 2)) (pyprint (q1 3)))') cmpStatements( '(pyprint (q1 3))', '(if (eval1 (q1 nil)) (pyprint (q1 2)) (pyprint (q1 3)))') cmpStatements( '(pyprint (q1 2))', '(if (eval1 (q1 true)) (if (eval1 (q1 true)) (pyprint (q1 2)) (pyprint (q1 4))) (if (eval1 (q1 true)) (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 2))', '(if (eval1 (q1 true)) (if (eval1 (q1 true)) (pyprint (q1 2)) (pyprint (q1 4))) (if (eval1 (q1 nil)) (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 4))', '(if (eval1 (q1 true)) (if (eval1 (q1 nil)) (pyprint (q1 2)) (pyprint (q1 4))) (if (eval1 (q1 true)) (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 4))', '(if (eval1 (q1 true)) (if (eval1 (q1 nil)) (pyprint (q1 2)) (pyprint (q1 4))) (if (eval1 (q1 nil)) (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 3))', '(if (eval1 (q1 nil)) (if (eval1 (q1 true)) (pyprint (q1 2)) (pyprint (q1 4))) (if (eval1 (q1 true)) (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 5))', '(if (eval1 (q1 nil)) (if (eval1 (q1 true)) (pyprint (q1 2)) (pyprint (q1 4))) (if (eval1 (q1 nil)) (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 3))', '(if (eval1 (q1 nil)) (if (eval1 (q1 nil)) (pyprint (q1 2)) (pyprint (q1 4))) (if (eval1 (q1 true)) (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 5))', '(if (eval1 (q1 nil)) (if (eval1 (q1 nil)) (pyprint (q1 2)) (pyprint (q1 4))) (if (eval1 (q1 nil)) (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 2))', '(if true (if true (pyprint (q1 2)) (pyprint (q1 4))) (if true (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 2))', '(if true (if true (pyprint (q1 2)) (pyprint (q1 4))) (if nil (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 4))', '(if true (if nil (pyprint (q1 2)) (pyprint (q1 4))) (if true (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 4))', '(if true (if nil (pyprint (q1 2)) (pyprint (q1 4))) (if nil (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 3))', '(if nil (if true (pyprint (q1 2)) (pyprint (q1 4))) (if true (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 5))', '(if nil (if true (pyprint (q1 2)) (pyprint (q1 4))) (if nil (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 3))', '(if nil (if nil (pyprint (q1 2)) (pyprint (q1 4))) (if true (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 5))', '(if nil (if nil (pyprint (q1 2)) (pyprint (q1 4))) (if nil (pyprint (q1 3)) (pyprint (q1 5))))') cmpStatements( '(pyprint (q1 2))', '(pyprint (car (cons (q1 2) (q1 3))))') cmpStatements( '(pyprint (q1 3))', '(pyprint (cdr (cons (q1 2) (q1 3))))') #cmpStatements( '(pyprint (q1 1)) (pyprint (q1 1)) (pyprint (q1 2)) (pyprint (q1 1))', # '(set2 (q1 a) (q1 1)) (pyprint a) (env-push-new0) (pyprint a) (set2 (q1 a) (q1 2)) (pyprint a) (env-pop0) (pyprint a)') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 a) (q1 1)) (prog (env-push-new0) (set2 (q1 a) (q1 2)) (pyprint a))') # a86d44b091204dfda45448c187bfd720: cmpStatements( '(pyprint (q1 1))', '(set2 (q1 a) (q1 1)) (prog (env-push-new0) (set2 (q1 a) (q1 2))) (pyprint a)') cmpStatements( '(pyprint (q1 1))', '(set2 (q1 a) (q1 1)) (prog (env-push-new0) (set2 (q1 a) (q1 2)) (prog (env-push-new0) (set2 (q1 a) (q1 3)))) (pyprint a)') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 a) (q1 1)) (prog (env-push-new0) (set2 (q1 a) (q1 2)) (prog (env-push-new0) (set2 (q1 a) (q1 3))) (pyprint a))') cmpStatements( '(pyprint (q1 3))', '(set2 (q1 a) (q1 1)) (prog (env-push-new0) (set2 (q1 a) (q1 2)) (prog (env-push-new0) (set2 (q1 a) (q1 3)) (pyprint a)))') # fazit: schliessen der prog klammer entspricht sinngemaess einem (env-pop0) :a86d44b091204dfda45448c187bfd720 cmpStatements( '(pyprint (q1 a))', '(pyprint (prog2 nil (q1 a)))') #cmpStatements( '(pyprint (q1 b))', # '(set2 (q1 a) (q1 b)) (set2 (q1 i) (q1 u)) (uqset1 (q1 o)) (pyprint (q1 o a))') # noo hack a1306aa2c580467ca5b6440fc664d354, wieder entfernt cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (set2 (q1 i) (q1 u)) (uqset1 (q1 o)) (pyprint (q1 a))') cmpStatements( '(pyprint (q1 b))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (pyprint (q2 o a))') cmpStatements( '(pyprint (q1 b))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (pyprint (q1 (o a)))') cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (eval1 (q1 (pyprint (q1 a))))') cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (eval1 (q2 o (q1 (pyprint (q1 a)))))') cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (eval1 (q1 (o (q1 (pyprint (q1 a))))))') cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (eval1 (q1 (prog (uqset1 (q1 o)) (pyprint (q2 o (q1 a))))))') # korrekt cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (eval1 (q1 (prog (uqset1 (q1 o)) (pyprint (q1 (o (q1 a)))))))') # korrekt cmpStatements( '(pyprint (q1 (q1 a)))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (eval1 (q1 (pyprint (q2 o (q1 (q1 a))))))') # korrekt ddfdc08cdef344b7bcd44d4e093d12ab cmpStatements( '(pyprint (q1 (q1 a)))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (eval1 (q1 (pyprint (q1 (o (q1 (q1 a)))))))') # korrekt ddfdc08cdef344b7bcd44d4e093d12ab cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (eval1 (q1 (pyprint (q2 o (q1 a)))))') # korrekt ddfdc08cdef344b7bcd44d4e093d12ab cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (eval1 (q1 (pyprint (q1 (o (q1 a))))))') # korrekt ddfdc08cdef344b7bcd44d4e093d12ab cmpStatements( '(pyprint (q1 b))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (pyprint (q2 o a))') cmpStatements( '(pyprint (q1 b))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (pyprint (q1 (o a)))') cmpStatements( '(pyprint (q1 b))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (pyprint (eval1 (q1 (q2 o a))))') # korrekt ddfdc08cdef344b7bcd44d4e093d12ab cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (q2 o (pyprint (q2 o (q1 a))))') # korrekt cmpStatements( '(pyprint (pyprint (q1 a)))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (pyprint (q2 o (pyprint (q2 o (q1 a)))))') # korrekt cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (pyprint (q2 o (q1 a)))') # korrekt cmpStatements( '(pyprint (q1 a))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o)) (pyprint (eval1 (q1 (q1 a))))') # korrekt cmpStatements( '(pyprint (q1 b))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o1)) (env-push-new0) (set2 (q1 a) (q1 c)) (uqset1 (q1 o2)) (pyprint (eval1 (q1 (q2 o1 a))))') cmpStatements( '(pyprint (q1 c))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o1)) (env-push-new0) (set2 (q1 a) (q1 c)) (uqset1 (q1 o2)) (pyprint (eval1 (q1 (q2 o2 a))))') cmpStatements( '(pyprint (q1 b))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o1)) (env-push-new0) (set2 (q1 a) (q1 c)) (uqset1 (q1 o2)) (pyprint (q2 o1 a))') cmpStatements( '(pyprint (q1 c))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o1)) (env-push-new0) (set2 (q1 a) (q1 c)) (uqset1 (q1 o2)) (pyprint (q2 o2 a))') cmpStatements( '(pyprint (q1 c))', '(set2 (q1 a) (q1 b)) (uqset1 (q1 o1)) (env-push-new0) (set2 (q1 a) (q1 c)) (uqset1 (q1 o2)) (pyprint (q1 (o2 a)))') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 a) (q1 (if true (pyprint (q1 2)) (pyprint (q1 3))))) (eval1 a)') # vorlage fuer macros / funktionen # cmpStatements( '(pyprint (q1 2))', '(macro p (pyprint (q1 2)))') # falsch cmpStatements( '(pyprint (q1 2))', '(pyprint (progn nil nil nil (q1 2)))') cmpStatements( '(pyprint (q1 2))', '(pyprint (progn-1 nil nil nil (q1 2) nil))') cmpStatements( '(pyprint nil)', '(pyprint (progn))') cmpStatements( '(pyprint nil)', '(pyprint (progn-1))') cmpStatements( '(pyprint (q1 2))', '(eval (unconses (qconses pyprint (q1 2))))') cmpStatements( '(pyprint (q1 2))', '(eval1 (ql pyprint (q1 2)))') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 f) (function p (pyprint (car p)))) (eval1 (f (q1 2)))') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 q) (quotation p (pyprint (car p)))) (eval1 (q 2))') ##### cmpStatements( '(pyprint (q1 2))', '(set2 (q1 m) (macro p (q1 (pyprint (q1 2))))) (m)') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 m) (macro p (ql pyprint (q1 2)))) (m)') # neu cmpStatements( '(pyprint (q1 2)) (pyprint (q1 3))', '((macro p (progn (pyprint (q1 2)) (q1 (pyprint (q1 3))))))') # neu cmpStatements( '(pyprint (q1 2))', '((macro2 p (pyprint (q1 2))))') cmpStatements( '(pyprint (q1 2))', '((macro p (q1 (pyprint (q1 2)))))') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 m) (macro p (q1 (pyprint (q1 2))))) (m nil)') cmpStatements( '(pyprint (q1 2))', '((macro p (q1 (pyprint (q1 2)))))') cmpStatements( '(pyprint (q1 2))', '((macro p (prog (pyprint (q1 2)))))') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 m) (macro p (progn (uqset1 (q1 o)) (q1 (pyprint (q2 o (car p))))))) (m 2)') cmpStatements( '(pyprint (q1 3))', '(set2 (q1 m) (macro p (progn (uqset1 (q1 o)) (q1 (pyprint (q2 o (car p))))))) (m 3)') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 a) (q1 2)) (set2 (q1 m) (macro p (progn (uqset1 (q1 o)) (q1 (pyprint (prog2 o (car p))))))) (m a)') cmpStatements( '(pyprint (q1 2))', '(set2 (q1 a) (q1 2)) (set2 (q1 m) (macro p (progn (uqset1 (q1 o)) (q1 (pyprint (o (car p))))))) (m a)') # neues uqset1 handling erlaubt vereinfachungen 96c8d565e4f946c38838d30756ce5c0d cmpStatements( '(pyprint (q1 2))', '(set2 (q1 a) (q1 2)) (uqset1 (q1 o)) (set2 (q1 m) (macro p (progn (uqset1 (q1 o2)) (q1 (pyprint (q2 o2 (car (cdr p)))))))) (m o a)') # baustelle: geht zwar, ist aber nicht zufriedenstellend, da aenderung im macro notwendig, wird mit 96c8d565e4f946c38838d30756ce5c0d geloest cmpStatements( '(pyprint (q1 2))', '(set2 (q1 a) (q1 2)) (uqset1 (q1 o)) (set2 (q1 m) (macro p (progn (uqset1 (q1 o2)) (q1 (pyprint (q1 (o2 (car p)))))))) (m (o a))') # 96c8d565e4f946c38838d30756ce5c0d problem geloest cmpStatements( '(pyprint (q1 2))', '(set2 (q1 a) (q1 2)) (uqset1 (q1 o)) (set2 (q1 m) (macro2 p (pyprint (car p)))) (eval (q1 m) a)') # schon besser, o eigentlich hier nicht benoetigt cmpStatements( '(pyprint (q1 2))', '(set2 (q1 a) (q1 2)) (uqset1 (q1 o)) (set2 (q1 m) (macro p (progn (uqset1 (q1 o2)) (q1 (pyprint (q2 o2 (car p))))))) (eval (q1 m) a)') # schon besser, o eigentlich hier nicht benoetigt cmpStatements( '(pyprint (q1 2))', '(set2 (q1 a) (q1 2)) (uqset1 (q1 o)) (set2 (q1 m) (macro p (progn (uqset1 (q1 o2)) (q1 (pyprint (q2 o a)))))) (m)') # schon besser, o eigentlich hier nicht benoetigt #cmpStatements( '(pyprintconses (q1 2))', '(set2 (q1 a) (q1 2)) (uqset1 (q1 o)) (set2 (q1 m) (macro p (pyprintconses (car p)))) (m (progn o a))') # baustelle : (q2 o X) => (q1 (progn o X)) geht nicht immer 8c3a5910f8784e98b20aa35d0aacfc4b #cmpStatements( '(pyprintconses (q1 2))', '(set2 (q1 a) (q1 2)) (uqset1 (q1 o)) (set2 (q1 m) (macro p (pyprintconses (eval1 (car p))))) (m (progn o a))') # baustelle : (q2 o X) => (q1 (progn o X)) geht nicht immer 8c3a5910f8784e98b20aa35d0aacfc4b #cmpStatements( '(pyprintconses (q1 2))', '(set2 (q1 a) (q1 2)) (uqset1 (q1 o)) (set2 (q1 m) (macro p (pyprintconses (car p)))) (m (o a))') # baustelle: diese Notation koennte die loesung sein, wenn (o a) zu dem Inhalt von a wird # WEITERBEI cmpStatements( '(pyprint (q1 2))', '((macro2 p ((car p) (car (cdr p)))) pyprint (q1 2))') # vorbereitung zur endlosloop cmpStatements( '(pyprint (q1 2))', '((macro p (progn (uqset1 (q1 o)) (q2 o (prog ((car p) (car (cdr p))))))) pyprint (q1 2))') # vorbereitung zur endlosloop cmpStatements( '(pyprint (q1 2))', '((macro p (progn (uqset1 (q1 o)) (q1 ((q2 o (car p)) (q2 o (car (cdr p))))))) pyprint (q1 2))') # vorbereitung zur endlosloop #cmpStatements( '(pyprint (q1 2))', '(pyprint (q1 2)) ((macro2 p ((car p) (car p))) (macro p ((car p) (car p))))') # endlosloop # emdet wie folgt: # File "/home/fschwidom/dev-git/tags/1/tagdb/mainCode.py", line 265, in has_key # return self.pl_symbols_prev.has_key( key) # ... # File "/home/fschwidom/dev-git/tags/1/tagdb/mainCode.py", line 263, in has_key # if None == self.pl_symbols_prev: cmpStatements( '(pyprint (q1 2))', '(set2 (q1 if2) (macro p (prog2 (uqset1 (q1 o)) (fif (eval1 (car p)) (q2 o (car (cdr p))) (q2 o (car (cdr (cdr p)))))))) (if2 true (pyprint (q1 2)) (pyprint (q1 3)))') # cmpStatements( '(pyprint (q1 3))', '(set2 (q1 if2) (macro p (prog2 (uqset1 (q1 o)) (fif (eval1 (car p)) (q2 o (car (cdr p))) (q2 o (car (cdr (cdr p)))))))) (if2 nil (pyprint (q1 2)) (pyprint (q1 3)))') # # problem hierbei: da das Symbol true in NativeFunctionFif / fif per id verglichen wird # id( true) == id( ret.car()) # ist hier (eval1 (car p)) notwendig cmpStatements( '(pyprint (q1 2))', '(set2 (q1 if2) (macro p (prog2 (uqset1 (q1 o)) (fif (eval1 (car p)) (q2 o (car (cdr p))) (q2 o (car (cdr (cdr p)))))))) (if2 (eval1 (q1 true)) (pyprint (q1 2)) (pyprint (q1 3)))') # cmpStatements( '(pyprint (q1 2))', '(set2 (q1 if2) (macro p (progn (uqset1 (q1 o)) (fif (eval1 (car p)) (q1 (progn o (car (cdr p)))) (q1 (progn o (car (cdr (cdr p))))))))) (if2 true (pyprint (q1 2)) (pyprint (q1 3)))') # (q2 o X) => (q1 (progn o X)) cmpStatements( '(pyprint (q1 3))', '(set2 (q1 if2) (macro p (progn (uqset1 (q1 o)) (fif (eval1 (car p)) (q1 (progn o (car (cdr p)))) (q1 (progn o (car (cdr (cdr p))))))))) (if2 nil (pyprint (q1 2)) (pyprint (q1 3)))') # (q2 o X) => (q1 (progn o X)) # cmpStatements( '(pyprint (q1 2))', '(pyprint (q1 2)) (nil)') # typ nicht erwartet: nil # betrachtung der environmentgueltigkeiten: cmpStatements( '(pyprint (q1 3))', '(set2 (q1 m) (macro p (q1 (set2 (q1 a) (q1 3))))) (m) (pyprint a)') # das geht zb mit macro2 nicht (noch nicht) cmpStatements( '(pyprint nil) (pyprint (q1 3)) (pyprint true)', '(set2 (q1 m) (macro p (q1 (set2 (q1 a) (q1 3))))) (pyprint (env-exists1 (q1 a))) (m) (pyprint a) (pyprint (env-exists1 (q1 a)))') cmpStatements( '(pyprint nil (q1 3) (q1 3) true)', '(set2 (q1 m) (macro p (q1 (set2 (q1 a) (q1 3))))) (pyprint (env-exists1 (q1 a)) (m) a (env-exists1 (q1 a)))') # und das kann noch keine sprache (a entsteht durch (m) # geht auch in Lisp: (defmacro m () '(setf a 'q)) (list (m) a) cmpStatements( '(pyprint nil (q1 4) (q1 3) true)', '(set2 (q1 m) (macro p (q1 (progn (set2 (q1 a) (q1 3)) (q1 4))))) (pyprint (env-exists1 (q1 a)) (m) a (env-exists1 (q1 a)))') # noo ist auch hier wieder brauchbar (als rueckgabewert von m) cmpStatements( '(pyprintconses (q1 1))', '(pyprintconses (consesRest (q1 1)))') cmpStatements( '(pyprintconses (cons (q1 1) (q1 2)))', '(pyprintconses (consesRest (q1 1) (q1 2)))') cmpStatements( '(pyprintconses (cons (q1 1) (cons (q1 2) (q1 3))))', '(pyprintconses (consesRest (q1 1) (q1 2) (q1 3)))') cmpStatements( '(pyprint (consesRest (q1 1) (q1 2)))', '(pyprint (conses (unconses (consesRest (q1 1) (q1 2)))))') cmpStatements( '(pyprint (consesRest (q1 1) (q1 2)))', '(pyprint (consesRest (unconses (conses (q1 1) (q1 2)))))') cmpStatements( '(pyprint (consesRest (q1 1)))', '(pyprint (conses (unconses (consesRest (q1 1)))))') # 80d1ab47171e42ba9bac8c8409b87bee cmpStatements( '(pyprint (consesRest (q1 1)))', '(pyprint (consesRest (unconses (conses (q1 1)))))') # 80d1ab47171e42ba9bac8c8409b87bee cmpStatements( '(pyprint (q1 1))', '(pyprint (qn1 1 1))') cmpStatements( '(pyprint (q1 1))', '(pyprint (qn1 0 (q1 1)))') cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (qn1 1 (q1 1))))') cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (eval1 (qn1 2 (q1 1)))))') cmpStatements( '(pyprint (q1 1))', '(pyprint (eval1 (eval1 (eval1 (qn1 3 (q1 1))))))') cmpStatements( '(pyprint set2)', '(set2 (q1 s) (stack-get0)) (pyprint (car (cdr (cdr (cdr (car (car (cdr (cdr (cdr s))))))))))') cmpStatements( '(pyprint (q1 s))', '(set2 (q1 s) (stack-get0)) (pyprint (car (cdr (cdr (cdr (cdr (car (car (cdr (cdr (cdr s)))))))))))') cmpStatements( '(pyprint (q1 ar_stack))', '(set2 (q1 s) (stack-get0)) (pyprint (car (car (cdr (cdr (cdr (cdr (cdr (car (car (cdr (cdr (cdr s)))))))))))))') cmpStatements( '(set2 (q1 s) (stack-get0)) (pyprintStack s)', '(set2 (q1 s) (stack-get0)) (set2 (q1 a) (q1 1)) (pyprintStack s)') #cmpStatements( '(set2 (q1 s) (stack-get0)) (pyprintconses s)', '(set2 (q1 s) (stack-get0)) (set2 (q1 a) (q1 1)) (pyprintconses s)') # zum Vergleich: diese Ausgabe ist nicht gleich (derzeit gibt es keine cmpStatementsFail - Funktion) # fuere weitere Stack Tests waere gut: # eine Copy - Funktion # eine Darstellung der ExecuteObject-e # weitere Stack Zugriffsfunktionen # que #uNames.undo() cmpStatements( '(pyprint (nameOfSymbol (q1 sys:set2)))', '(pyprint set2)') sExp= "consesMake( stackMake( codeListCurrentEvalTokenList, codeListParent2EvalToken, consesMakeRest( consesMakeRest( Symbol( 'ar_codeList'), 'codeListConfigMake( ...)', Symbol( 'ar_codeListParameters'), 'sys:set2', ConsSimple( Symbol( 's'), 'sclp2et_-1')), consesMakeRest( Symbol( 'ar_codeList'), 'codeListConfigMake( ...)', Symbol( 'ar_codeListParameters'), ConsSimple( Symbol( 'progn-root'), 'sclp2et_0')), Symbol( 'nil'))))" test( [(sExp,),], interpret( "(set2 (q1 s) (stack-get0)) (pyprintStack s)")) test( [(sExp,), (sExp,)], interpret( "(set2 (q1 s) (stack-get0)) (pyprintStack s) (pyprintStack s)")) del sExp sExp= "consesMake( stackMake( codeListCurrentEvalTokenList, codeListParent2EvalToken, consesMakeRest( consesMakeRest( Symbol( 'ar_codeList'), 'codeListConfigMake( ...)', Symbol( 'ar_codeListParameters'), 'sys:set2', ConsSimple( Symbol( 's'), 'sclp2et_-1')), consesMakeRest( Symbol( 'ar_codeList'), 'codeListConfigMake( ...)', Symbol( 'ar_codeListParameters'), Symbol( 'progn-root'), ConsSimple( Symbol( '1'), 'sclp2et_0')), Symbol( 'nil'))))" test( [(sExp,),], interpret( "(progn (q1 1)) (set2 (q1 s) (stack-get0)) (pyprintStack s)")) test( [(sExp,), (sExp,)], interpret( "(progn (q1 1)) (set2 (q1 s) (stack-get0)) (pyprintStack s) (pyprintStack s)")) del sExp sExp= "consesMake( stackMake( codeListCurrentEvalTokenList, codeListParent2EvalToken, consesMakeRest( consesMakeRest( Symbol( 'ar_codeList'), 'codeListConfigMake( ...)', Symbol( 'ar_codeListParameters'), 'sys:set2', ConsSimple( Symbol( 's'), 'sclp2et_-1')), codeList)))" test( [(sExp,),], interpret( "(progn (q1 1)) (set2 (q1 s) (stack-get0)) (pyprintStack2 s)")) test( [(sExp,), (sExp,)], interpret( "(progn (q1 1)) (set2 (q1 s) (stack-get0)) (pyprintStack2 s) (pyprintStack2 s)")) test( [(sExp,), (sExp,)], interpret( " (set2 (q1 s) (stack-get0)) (pyprintStack2 s) (pyprintStack2 s)")) test( [(sExp,), (sExp,)], interpret( " (set2 (q1 s) (stack-get0)) (pyprintStack2 (stack-clone1 s)) (pyprintStack2 (stack-clone1 s))")) del sExp sExp= "consesMake( stackShort( consesMakeRest( consesMakeRest( 'sys:set2', ConsSimple( Symbol( 's'), 'sclp2et_-1')), codeList)))" test( [(sExp,),], interpret( "(progn (q1 1)) (set2 (q1 s) (stack-get0)) (pyprintStackShort s)")) test( [(sExp,), (sExp,)], interpret( "(progn (q1 1)) (set2 (q1 s) (stack-get0)) (pyprintStackShort s) (pyprintStackShort s)")) test( [(sExp,), (sExp,)], interpret( " (set2 (q1 s) (stack-get0)) (pyprintStackShort s) (pyprintStackShort s)")) del sExp # baustelle0: pyprintStack noch nicht fertig (x0, x1) cmpStatements( '(pyprint (q1 1))', '(set2 (q1 m1) (macro2 p (progn (pyprint (q1 1))))) (m1)') def f1( mvar, code): return 'nil (set2 (q1 '+ mvar+ ') (macro p (prog nil '+ code+ ' nil))) nil ( '+ mvar +') nil' def f2( mvar, code): return 'nil (set2 (q1 '+ mvar+ ') (macro p (q1 (prog nil '+ code+ ' nil)))) nil ( '+ mvar +') nil' cmpStatements( '(pyprint (q1 1))', f1( 'm1', '(pyprint (q1 1))')) cmpStatements( '(pyprint (q1 1))', f2( 'm1', '(pyprint (q1 1))')) cmpStatements( '(pyprint (q1 1))', f1( 'm1', f1( 'm2', '(pyprint (q1 1))'))) cmpStatements( '(pyprint (q1 1))', f1( 'm1', f2( 'm2', '(pyprint (q1 1))'))) cmpStatements( '(pyprint (q1 1))', f2( 'm1', f1( 'm2', '(pyprint (q1 1))'))) cmpStatements( '(pyprint (q1 1))', f2( 'm1', f2( 'm2', '(pyprint (q1 1))'))) cmpStatements( '(pyprint (q1 1))', f1( 'm1', f1( 'm2', f1( 'm3', '(pyprint (q1 1))')))) cmpStatements( '(pyprint (q1 1))', f1( 'm1', f1( 'm2', f2( 'm3', '(pyprint (q1 1))')))) cmpStatements( '(pyprint (q1 1))', f1( 'm1', f2( 'm2', f1( 'm3', '(pyprint (q1 1))')))) cmpStatements( '(pyprint (q1 1))', f1( 'm1', f2( 'm2', f2( 'm3', '(pyprint (q1 1))')))) cmpStatements( '(pyprint (q1 1))', f2( 'm1', f1( 'm2', f1( 'm3', '(pyprint (q1 1))')))) cmpStatements( '(pyprint (q1 1))', f2( 'm1', f1( 'm2', f2( 'm3', '(pyprint (q1 1))')))) cmpStatements( '(pyprint (q1 1))', f2( 'm1', f2( 'm2', f1( 'm3', '(pyprint (q1 1))')))) cmpStatements( '(pyprint (q1 1))', f2( 'm1', f2( 'm2', f2( 'm3', '(pyprint (q1 1))')))) def f1a( mvar, code): return 'nil (set2 (q1 '+ mvar+ ') (macro p (prog nil '+ code+ ' nil))) nil' def f2a( mvar, code): return 'nil (set2 (q1 '+ mvar+ ') (macro p (q1 (prog nil '+ code+ ' nil)))) nil' cmpStatements( '(pyprint (q1 1))', f1a( 'm1', '(pyprint (q1 1))')+ ' '+ f1( 'm2', '(m1)')) cmpStatements( '(pyprint (q1 1))', f1a( 'm1', '(pyprint (q1 1))')+ ' '+ f2( 'm2', '(m1)')) cmpStatements( '(pyprint (q1 1))', f2a( 'm1', '(pyprint (q1 1))')+ ' '+ f1( 'm2', '(m1)')) cmpStatements( '(pyprint (q1 1))', f2a( 'm1', '(pyprint (q1 1))')+ ' '+ f2( 'm2', '(m1)')) del f1, f2, f1a, f2a #cmpStatements( '(pyprint (q1 2)) (pyprint (q1 3))', '((macro p (progn (pyprint (q1 2)) (q1 (pyprint (q1 3))))))') # neu # Exceptions: cmpStatements( '(pyprint (q1 1))', '(set2 (q1 st) (stack-clone1 (stack-get0))) (pyprint (q1 1))') cmpStatements( '(pyprint (q1 1)) (pyprint (q1 2))', '(set2 (q1 st) (stack-clone1 (stack-get0))) (stack-apply2 st (q1 2)) (pyprint (q1 1)) (pyprint st)') cmpStatements( '(pyprint (q1 1)) (pyprint (q1 2))', """ (set2 (q1 st) (stack-clone1 (stack-get0))) (set2 (q1 m) (macro p (q1 (progn (stack-apply2 st (q1 2)))))) (m) (pyprint (q1 1)) (pyprint st) """) cmpStatements( '(pyprint (q1 1)) (pyprint (q1 2))', """ (set2 (q1 st) (stack-clone1 (stack-get0))) (set2 (q1 m) (macro2 p (progn (stack-apply2 st (q1 2))))) (m) (pyprint (q1 1)) (pyprint st) """) # baustelle0: (pyprint (q1 3)) darf nicht ausgegeben werden cmpStatements( '(pyprint (q1 1)) (pyprint (q1 2))', """ (set2 (q1 st) (stack-clone1 (stack-get0))) (set2 (q1 m) (macro2 p (progn (stack-apply2 st (q1 2)) (pyprint (q1 3))))) (m) (pyprint (q1 1)) (pyprint st) """) te.checkComplainAndAdjustExpected( 2* subtestCount[0] + 3* cmpStatementsCount[0] + 2* interpretCount[0])
def testTools2(): te.checkComplainAndAdjustExpected( 0) fu= Undo() try: fu.getIdx() te.test( True) except: te.test( False) try: fu.undo() te.test( False) except: te.test( True) try: te.redo() te.test( False) except: te.test( True) undoAble= [0] def f( i): undoAbleInF= undoAble[ 0] class fret( UndoStep): def undo( self): undoAble[ 0]= undoAbleInF def redo( self): undoAble[0]= i return fret() fu.next( f( 1)) idx1= fu.getIdx() test( 1, undoAble[ 0]) fu.undo() test( 0, undoAble[ 0]) fu.redo() test( 1, undoAble[ 0]) fu.next( f( 2)) test( 2, undoAble[ 0]) fu.next( f( 3)) test( 3, undoAble[ 0]) fu.next( f( 4)) test( 4, undoAble[ 0]) idx4= fu.getIdx() try: fu.redo() te.test( False) except: te.test( True) test( 4, undoAble[ 0]) fu.undo() test( 3, undoAble[ 0]) fu.redo() test( 4, undoAble[ 0]) fu.undo( idx1) test( 1, undoAble[ 0]) try: fu.undo() te.test( True) except: te.test( False) try: fu.undo() te.test( False) except: te.test( True) test( 0, undoAble[ 0]) fu.redo() test( 1, undoAble[ 0]) fu.redo() test( 2, undoAble[ 0]) fu.undo() test( 1, undoAble[ 0]) fu.redo( idx4) test( 4, undoAble[ 0]) try: fu.redo() te.test( False) except: te.test( True) fu.undo() test( 3, undoAble[ 0]) fu.undo() test( 2, undoAble[ 0]) fu.undo() test( 1, undoAble[ 0]) try: fu.undo() te.test( True) except: te.test( False) try: fu.undo() te.test( False) except: te.test( True) test( 0, undoAble[ 0]) try: fu.undo() te.test( False) except: te.test( True) te.checkComplainAndAdjustExpected( 29)
def testConsAbstraction3(): te.checkComplainAndAdjustExpected( 0) CACH= makeConsAbstractCarAutoHistory( ConsSimple, ConsSimple) CACH.__name__= 'CACH' cach1= CACH( 1, 2) test( 'CACH( 1, 2)', ConsTrait( cach1).repr_wrapped()) cach1HistoryAr= cach1.consWrapped.car() testCrCr( cs( consHistory, cs( 1, nil)), cach1HistoryAr) testCrCr( cs( cach1HistoryAr, 2), cach1.consWrapped, { id( cach1HistoryAr) : 'cach1HistoryAr'}) test( 1, cach1.car()) test( 2, cach1.cdr()) cach1.car( 3) cach1.cdr( 4) testCrCr( cs( consHistory, cs( 3, cs( 1, nil))), cach1HistoryAr) testCrCr( cs( cach1HistoryAr, 4), cach1.consWrapped, { id( cach1HistoryAr) : 'cach1HistoryAr'}) test( 3, cach1.car()) test( 4, cach1.cdr()) cach1.cdr( CACH( 5, 6)) cach1HistoryDrAr= cach1.cdr().consWrapped.car() test( 'CACH( 3, CACH( 5, 6))', ConsTrait( cach1).repr_wrapped()) testCrCr( cs( consHistory, cs( 5, nil)), cach1HistoryDrAr) testCrCr( cs( cach1HistoryAr, cs( cach1HistoryDrAr, 6)), cach1.consWrapped, { id( cach1HistoryAr) : 'cach1HistoryAr', id( cach1HistoryDrAr) : 'cach1HistoryDrAr'}) cach1HistoryArListOld= cach1.consWrapped.car().cdr() cach1.car( CACH( 7, 8)) test( 'CACH( CACH( 7, 8), CACH( 5, 6))', ConsTrait( cach1).repr_wrapped()) cach1HistoryArAr= cach1.car().consWrapped.car() testCrCr( cs( consHistory, cs( 7, nil)), cach1HistoryArAr) testCrCr( cs( consHistory, cs( cs( cach1HistoryArAr, 8), cach1HistoryArListOld)), cach1HistoryAr, { id( cach1HistoryArListOld): 'cach1HistoryArListOld', id( cach1HistoryArAr): 'cach1HistoryArAr'}) test( "ConsSimple( cach1HistoryAr, ConsSimple( cach1HistoryDrAr, 6))", ConsRepr( cach1.consWrapped).repr_wrapped( { id( cach1HistoryAr) : 'cach1HistoryAr', id( cach1HistoryDrAr) : 'cach1HistoryDrAr'})) test( 7, cach1.car().car()) cach2= CACH( CACH( 7, 8), CACH( 5, 6)) test( 'CACH( CACH( 7, 8), CACH( 5, 6))', ConsTrait( cach2).repr_wrapped()) cach2HistoryArAr= cach2.car().consWrapped.car() cach2HistoryDrAr= cach2.cdr().consWrapped.car() testCrCr( cs( consHistory, cs( 7, nil)), cach2HistoryArAr) testCrCr( cs( consHistory, cs( 5, nil)), cach2HistoryDrAr) testCrCr( cs( cs( consHistory, cs( cs( cach2HistoryArAr, 8), nil)), cs( cach2HistoryDrAr, 6)), cach2.consWrapped, { id( cach2HistoryArAr): 'cach2HistoryArAr', id( cach2HistoryDrAr): 'cach2HistoryDrAr'}) test( 7, cach2.car().car()) te.checkComplainAndAdjustExpected( 22)
def testTools1(): te.checkComplainAndAdjustExpected( 0) fu= FunctionalUndo() try: fu.getIdx() te.test( False) except: te.test( True) try: fu.undo() te.test( False) except: te.test( True) try: te.redo() te.test( False) except: te.test( True) undoAble= [0] def f( i): def fret(): undoAble[0]= i return fret fu.next( f( 1)) idx1= fu.getIdx() test( 1, undoAble[ 0]) fu.next( f( 2)) test( 2, undoAble[ 0]) fu.next( f( 3)) test( 3, undoAble[ 0]) fu.next( f( 4)) test( 4, undoAble[ 0]) idx4= fu.getIdx() try: fu.redo() te.test( False) except: te.test( True) test( 4, undoAble[ 0]) fu.undo() test( 3, undoAble[ 0]) fu.redo() test( 4, undoAble[ 0]) fu.undo( idx1) test( 1, undoAble[ 0]) try: fu.undo() te.test( False) except: te.test( True) fu.redo() test( 2, undoAble[ 0]) fu.undo() test( 1, undoAble[ 0]) fu.redo( idx4) test( 4, undoAble[ 0]) try: fu.redo() te.test( False) except: te.test( True) fu.undo() test( 3, undoAble[ 0]) fu.undo() test( 2, undoAble[ 0]) fu.undo() test( 1, undoAble[ 0]) try: fu.undo() te.test( False) except: te.test( True) te.checkComplainAndAdjustExpected( 21)
def testConsTrait3(): def testCrCr( ex, ou, htEnvLocals= None): if None==htEnvLocals: htEnvLocals= dict() test( ConsRepr( ex ).repr_wrapped( htEnvLocals), ConsRepr( ou ).repr_wrapped( htEnvLocals)) s= Symbol cs= ConsSimple te.checkComplainAndAdjustExpected( 0) uNames.next( usRename( ConsSimple, 'cs')) uNames.next( usRename( Symbol, 's')) as1= assocMake() test( "cs( s( 'ar_assoc'), s( 'nil'))", ConsRepr( as1).repr_wrapped()) testCrCr( cs( ar_assoc, nil), as1) test( 0, listLen( as1)) asGot= assocGet( as1, (lambda elem: False)) testCrCr( cs( ar_assoc, nil), asGot) asGot= assocGet( as1, (lambda elem: True)) testCrCr( cs( ar_assoc, nil), asGot) del asGot assocAdd( as1, cs( '1', nil)) testCrCr( cs( ar_assoc, cs( cs( ar_assocElem, cs( '1', nil)), nil)), as1) test( 1, listLen( as1)) assocAdd( as1, cs( '2', nil)) testCrCr( cs( ar_assoc, cs( cs( ar_assocElem, cs( '1', nil)), cs( cs( ar_assocElem, cs( '2', nil)), nil))), as1) test( "listGeneral( listGeneral( '1'), listGeneral( '2'))", ConsRepr( as1).repr_wrapped( None, [ CpctReprListGeneral])) test( "assocInternGeneral( assocElemGeneral( '1'), assocElemGeneral( '2'))", ConsRepr( as1).repr_wrapped( None, [ CpctReprAssocInternGeneral, CpctReprAssocElemGeneral])) test( "consesMake( s( 'ar_assoc'), consesMake( s( 'ar_assocElem'), '1'), consesMake( s( 'ar_assocElem'), '2'))", ConsRepr( as1).repr_wrapped( None, [ CpctReprConses])) test( "assocGeneral( consesMake( '1'), consesMake( '2'))", ConsRepr( as1).repr_wrapped( None, [ CpctReprAssocGeneral, CpctReprConses])) # klar: konflikt, geloest per f5fbafd44f9a4a3c9f65860301b2c1c5 test( 2, listLen( as1)) testCrCr( cs( ar_assocElem, cs( '1', nil)), listNth0( as1, 0)) testCrCr( cs( ar_assocElem, cs( '2', nil)), listNth0( as1, 1)) test( not_found, listNth0( as1, -1)) test( not_found, listNth0( as1, 2)) as2= assocGet( as1, (lambda elem: '1'==elem.car())) testCrCr( cs( ar_assoc, cs( cs( ar_assocElem, cs( '1', nil)), nil)), as2) as3= assocGet( as1, (lambda elem: '2'==elem.car())) testCrCr( cs( ar_assoc, cs( cs( ar_assocElem, cs( '2', nil)), nil)), as3) as4= assocDel( as1, (lambda elem: '1'==elem.car())) testCrCr( cs( ar_assoc, cs( cs( ar_assocElem, cs( '1', nil)), nil)), as4) testCrCr( cs( ar_assoc, cs( cs( ar_assocElem, cs( '2', nil)), nil)), as1) test( 1, listLen( as1)) as5= assocDel( as1, (lambda elem: '2'==elem.car())) testCrCr( cs( ar_assoc, cs( cs( ar_assocElem, cs( '2', nil)), nil)), as5) testCrCr( cs( ar_assoc, nil), as1) test( 0, listLen( as1)) uNames.undo() uNames.undo() te.checkComplainAndAdjustExpected( 25)
def testConses1(): te.checkComplainAndAdjustExpected( 0) c1= ConsSimple( 1, 1) c1.cdr( c1) c2= ConsSimple( 1, 1) c2.cdr( c2) c3= ConsSimple( 1, 1) c3.cdr( c1) c4= ConsSimple( 1, 1) c4.cdr( c3) c5= ConsSimple( 1, 1) c5.cdr( c2) test( True , ConsTrait( c1)==ConsTrait( c2) ) test( False , ConsTrait( c1)==ConsTrait( c3) ) test( False , ConsTrait( c3)==ConsTrait( c1) ) test( True , ConsTrait( c3)==ConsTrait( c3) ) test( False , ConsTrait( c4)==ConsTrait( c3) ) test( True , ConsTrait( c5)==ConsTrait( c3) ) test( False , ConsTrait( c5)==ConsTrait( c4) ) c6_1= ConsSimple( 1, 1) c6_2= ConsSimple( 1, 1) c6_1.cdr( c6_2) c6_2.cdr( c6_1) test( True , ConsTrait( c6_1)==ConsTrait( c6_1) ) test( True , ConsTrait( c6_1)==ConsTrait( c6_2) ) test( True , ConsTrait( c6_2)==ConsTrait( c6_1) ) c7_1= ConsSimple( 1, 1) c7_2= ConsSimple( 1, 1) c7_3= ConsSimple( 1, 1) c7_1.cdr( c7_2) c7_2.cdr( c7_3) c7_3.cdr( c7_1) test( True , ConsTrait( c7_1)==ConsTrait( c7_1) ) ct7_1= ConsTrait( c7_1) ct7_2= ct7_1.cdr() test( True , ct7_2.consWrapped==c7_2 ) test( False , ct7_1==ct7_2 ) test( True , ConsTrait( c7_1)==ConsTrait( c7_2) ) d= dict() test( False , ConsTrait( c7_1, d)==makeConsTrait( c7_2, d) ) del d c8_1= ConsSimple( 1, 1) c8_2= ConsSimple( 1, 1) c8_3= ConsSimple( 1, 1) c8_4= ConsSimple( 1, 1) c8_1.cdr( c8_2) c8_2.cdr( c8_3) c8_3.cdr( c8_4) c8_4.cdr( c8_1) test( True , ConsTrait( c8_1)==ConsTrait( c8_1) ) test( True , ConsTrait( c8_1)==makeConsTrait( c8_2) ) d= dict() test( False , ConsTrait( c8_1, d)==makeConsTrait( c8_2, d) ) del d test( True , ConsTrait( c8_1)==ConsTrait( c8_3) ) test( True , ConsTrait( c8_2)==ConsTrait( c8_4) ) c8_2_clonedDeep= ConsTrait( c8_2).cloneDeep() test( True , ConsTrait( c8_1)==ConsTrait( c8_2_clonedDeep) ) test( True, hash( ConsTrait( c8_1)) == hash( ConsTrait( c8_2_clonedDeep))) # ok, es werden also die symmetrien beachtet, das soll mir recht sein test( True, hash( ConsTrait( c1)) == hash( ConsTrait( c2))) test( False, hash( ConsTrait( c1)) == hash( ConsTrait( c3))) test( True, hash( ConsTrait( c7_1)) == hash( ConsTrait( c7_2))) test( True, hash( ConsTrait( c7_1)) == hash( ConsTrait( c7_3))) test( True, hash( ConsTrait( c8_1)) == hash( ConsTrait( c8_2))) test( True, hash( ConsTrait( c8_1)) == hash( ConsTrait( c8_3))) test( True, hash( ConsTrait( c8_1)) == hash( ConsTrait( c8_4))) te.checkComplainAndAdjustExpected( 29)
def testRepl1(): def testCrCr( ex, ou, d= None): #htEnvLocals= { id( env_locals1) : "env_locals1"} htEnvLocals= {} if not None == d: htEnvLocals.update( d) test( ConsRepr( ex ).repr_wrapped( htEnvLocals), ConsRepr( ou ).repr_wrapped( htEnvLocals)) ( ios, i)= makeOverridenInterpreter() env_locals1= i.getEnvLocals() ios.__init__() ios.setInputString( '(pyprint (q1 1))') test( nil, i.readbuf.cdr()) test( nil, i.macroBuf) te.test( not i.currentEvalTokenIsInExecutePosition()) i.replStep() test( 'pyprint (q1 1))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) te.test( not i.currentEvalTokenIsInExecutePosition()) i.replStep() test( ' (q1 1))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) te.test( i.currentEvalTokenIsInExecutePosition()) i.replStep() test( 'q1 1))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) te.test( not i.currentEvalTokenIsInExecutePosition()) i.replStep() test( ' 1))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) te.test( i.currentEvalTokenIsInExecutePosition()) i.replStep() test( '))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) te.test( not i.currentEvalTokenIsInExecutePosition()) i.replStep() test( ')', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) te.test( not i.currentEvalTokenIsInExecutePosition()) test( [], ios.ess_ess_pront) i.replStep() test( nil, i.readbuf.cdr()) test( nil, i.macroBuf) te.test( not i.currentEvalTokenIsInExecutePosition()) #test( [('1',)], ios.ess_ess_pront) test( [( ConsRepr( cs( s( '1'), nil)).repr_wrapped(),)], ios.ess_ess_pront) ios.__init__() ios.setInputString( '(pyprint (eval1 (ql q1 1)))') test( nil, i.readbuf.cdr()) test( nil, i.macroBuf) i.replStep() test( 'pyprint (eval1 (ql q1 1)))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) i.replStep() test( ' (eval1 (ql q1 1)))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) i.replStep() test( 'eval1 (ql q1 1)))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) i.replStep() test( ' (ql q1 1)))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) i.replStep() test( 'ql q1 1)))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) i.replStep() test( ' q1 1)))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) i.replStep() test( ' 1)))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) i.replStep() test( ')))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) i.replStep() test( '))', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) i.replStep() macroBufCdr= i.macroBuf.cdr() test( ')', consesConcatSymbols( i.readbuf.cdr())) testCrCr( cs( cs( True, s( '(')), macroBufCdr), i.macroBuf) te.test( not i.quotationModeIsActivated()) i.replStep() macroBufCdr= macroBufCdr.cdr() test( ')', consesConcatSymbols( i.readbuf.cdr())) testCrCr( cs( cs( False, s( 'q1')), macroBufCdr), i.macroBuf) te.test( not i.quotationModeIsActivated()) #print ConsRepr( i.macroBuf).repr_wrapped( None, [ CpctReprCodeListConfigMake, CpctReprConses]) #exit() i.replStep() macroBufCdr= macroBufCdr.cdr() test( ')', consesConcatSymbols( i.readbuf.cdr())) testCrCr( cs( cs( False, s( '1')), macroBufCdr), i.macroBuf) te.test( i.quotationModeIsActivated()) i.replStep() macroBufCdr= macroBufCdr.cdr() test( ')', consesConcatSymbols( i.readbuf.cdr())) testCrCr( cs( cs( False, s( ')')), macroBufCdr), i.macroBuf) test( nil, macroBufCdr) te.test( i.quotationModeIsActivated()) i.replStep() test( ')', consesConcatSymbols( i.readbuf.cdr())) test( nil, i.macroBuf) te.test( not i.quotationModeIsActivated()) test( [], ios.ess_ess_pront) i.replStep() test( nil, i.readbuf.cdr()) test( nil, i.macroBuf) te.test( not i.quotationModeIsActivated()) #test( [('1',)], ios.ess_ess_pront) test( [( ConsRepr( cs( s( '1'), nil)).repr_wrapped(),)], ios.ess_ess_pront) #ios.setInputString( '(pyprint (eval (q1 1)))') # ist semantisch falsch (enspricht: (eval '1)), Test auf korrekte Fehlerausgabe waere hier sinvoll # das war das falsche, liefert raise IsNotInstance #ios.setInputString( '(pyprint (eval (ql q1 (q1 1))))') ios.setEOF() try: i.repl() te.test( False) except EOFError: te.test( True) te.checkComplainAndAdjustExpected( 68)
def testInterpreterGeneral1( ConsClass): def testCrCr( ex, ou, d= None): htEnvLocals= { id( env_locals1) : "env_locals1"} if not None == d: htEnvLocals.update( d) test( ConsRepr( ex ).repr_wrapped( htEnvLocals, [ CpctReprCodeListConfigMake]), ConsRepr( ou ).repr_wrapped( htEnvLocals, [ CpctReprCodeListConfigMake])) def codeListFake( rest): if InterpreterStructures.alteVariante: return cs( ar_codeList, cs( codeListConfigMakeRepr, rest)) else: return cs( ar_codeList, cs( codeListConfigMakeRepr, cs( ar_codeListParameters, rest))) def codeListFakeRoot( rest): if InterpreterStructures.alteVariante: return cs( ar_codeList, cs( codeListConfigMakeRepr, rest)) else: return cs( ar_codeList, cs( codeListConfigMakeRepr, cs( ar_codeListParameters, cs( s( 'progn-root'), rest)))) te.checkComplainAndAdjustExpected( 0) i= Interpreter() env_locals1= i.getEnvLocals() codeListConfigMakeRepr= 'codeListConfigMake( ...)' uNames.next( usRename( ConsAbstractCarAutoHistoryCSCS, 'ConsSimple')) testCrCr( codeListFakeRoot( nil), i.codeList) test( nil , i.codeListParent2EvalToken ) if InterpreterStructures.alteVariante: testCrCr( cs( cs( ar_codeList, i.codeListCurrentEvalTokenList.cdr()), nil), i.codeCurrentLeafList, { id( i.codeListCurrentEvalTokenList.cdr()): 'codeListCurrentEvalTokenList.cdr()'}) else: testCrCr( cs( cs( ar_codeList, cs( codeListConfigMakeRepr, i.codeListCurrentEvalTokenList)), nil), i.codeCurrentLeafList, { id( i.codeListCurrentEvalTokenList.cdr()): 'codeListCurrentEvalTokenList.cdr()'}) uNames.undo() codeLeaf= i.codeLeafBackTree.car() testCrCr( cs( codeLeaf, nil), i.codeLeafBackTree, { id( codeLeaf): 'codeLeaf'}) te.checkComplainAndAdjustExpected( 4) if False: pass elif id( ConsClass) == id( ConsAbstractCarAutoHistoryCSCS): # b4dfedc64bf1440b82f109a25c7f8421 #ConsAbstractCarAutoHistoryCSCS.__name__= 'cs' #ConsSimple.__name__= 'cs' uNames.next( usRename( ConsAbstractCarAutoHistoryCSCS, 'cs')) uNames.next( usRename( ConsSimple, 'cs')) i.evalToken( s( 'aa')) ht_selfid2Name= { id( env_locals1): 'env_locals1'} testCrCr( cs( ar_codeList, cs( env_locals1, cs( s( 'aa'), nil))), i.codeList) testCrCr( cs( s( 'aa'), nil), i.codeListCurrentEvalTokenList.cdr()) currentLeaf= i.codeCurrentLeafList.car() testCrCr( cs( ar_codeList, cs( env_locals1, i.codeListCurrentEvalTokenList.cdr())), currentLeaf) testCrCr( cs( currentLeaf, nil), i.codeCurrentLeafList) codeLeaf= i.codeLeafBackTree.car() testCrCr( cs( codeLeaf, nil), i.codeLeafBackTree) test( 'aa', i.codeList.cdr().cdr().car()) test( id( consHistory), id( i.codeList.cdr().consWrapped.car().car())) testCrCr( cs( consHistory, cs( s( 'aa'), nil)), i.codeList.cdr().cdr().consWrapped.car()) i.evalToken( s( '('), True) testCrCr( cs( env_locals1, nil), i.codeListCurrentEvalTokenList.cdr()) currentLeaf= i.codeCurrentLeafList.car() testCrCr( cs( ar_codeList, i.codeListCurrentEvalTokenList.cdr()), currentLeaf) testCrCr( cs( currentLeaf, cs( cs( ar_codeList, cs( env_locals1, cs( currentLeaf, nil))), nil)), i.codeCurrentLeafList) codeLeaf= i.codeLeafBackTree.car() testCrCr( cs( codeLeaf, nil), i.codeLeafBackTree) i.evalToken( s( 'bb')) testCrCr( cs( s( 'bb'), nil), i.codeListCurrentEvalTokenList.cdr()) currentLeaf= i.codeCurrentLeafList.car() testCrCr( cs( ar_codeList, cs( env_locals1, i.codeListCurrentEvalTokenList.cdr())), currentLeaf) testCrCr( cs( currentLeaf, cs( cs( ar_codeList, cs( env_locals1, cs( currentLeaf, nil))), nil)), i.codeCurrentLeafList) codeLeaf= i.codeLeafBackTree.car() testCrCr( cs( codeLeaf, nil), i.codeLeafBackTree) i.evalToken( s( ')')) testCrCr( cs( cs( ar_codeList, cs( env_locals1, cs( s( 'bb'), nil))), nil), i.codeListCurrentEvalTokenList.cdr()) currentLeaf= i.codeCurrentLeafList.car() testCrCr( cs( ar_codeList, cs( env_locals1, i.codeListCurrentEvalTokenList.cdr())), currentLeaf) testCrCr( cs( currentLeaf, nil), i.codeCurrentLeafList) codeLeafBefore= codeLeaf codeLeaf= i.codeLeafBackTree.car() testCrCr( cs( codeLeaf, cs( codeLeafBefore, nil)), i.codeLeafBackTree) testCrCr( cs( ar_codeList, cs( env_locals1, cs( s( 'bb'), nil))), i.codeList.cdr().cdr().car()) testCrCr( cs( consHistory, cs( cs( cs( consHistory, cs( ar_codeList, nil)), cs( cs( consHistory, cs( env_locals1, nil)), cs( cs( consHistory, cs( s( 'bb'), nil)), nil))), cs( s( 'aa'), nil))), i.codeList.cdr().cdr().consWrapped.car()) i.evalToken( s( 'a'), True) # aa => a test( 'a', i.codeList.cdr().cdr().car()) testCrCr( cs( consHistory, cs( s( 'a'), cs( cs( cs( consHistory, cs( ar_codeList, nil)), cs( cs( consHistory, cs( env_locals1, nil)), cs( cs( consHistory, cs( s( 'bb'), nil)), nil))), cs( s( 'aa'), nil)))), i.codeList.cdr().cdr().consWrapped.car()) test( id( consHistory), id( i.codeList.cdr().consWrapped.car().car())) testCrCr( cs( cs( consHistory, cs( ar_codeList, nil)), cs( cs( consHistory, cs( env_locals1, nil)), cs( cs( consHistory, cs( s( 'a'), cs( cs( cs( consHistory, cs( ar_codeList, nil)), cs( cs( consHistory, cs( env_locals1, nil)), cs( cs( consHistory, cs( s( 'bb'), nil)), nil))), cs( s( 'aa'), nil)))), nil))), i.codeList.consWrapped) testCrCr( cs( ar_codeList, cs( env_locals1, cs( s( 'a'), nil))), i.codeList) uNames.undo() uNames.undo() te.checkComplainAndAdjustExpected( 27) elif id( ConsClass) == id( ConsSimple): # b4dfedc64bf1440b82f109a25c7f8421 i.evalToken( cs( ar_value, s( 'a'))) test( ar_codeListConfig, i.codeList.cdr().car().car()) #test( s( 'a'), i.codeList.cdr().cdr().car()) test( s( 'a'), codeListGetParameterValues( i.codeList).cdr().car()) te.checkComplainAndAdjustExpected( 2) else: assert( False) test( nil , i.codeListParent2EvalToken ) i.evalToken( cs( ar_value, s( '('))) elem= codeListFake( nil) tail= cs( elem, nil) uNames.next( usRename( ConsAbstractCarAutoHistoryCSCS, 'ConsSimple')) uNames.next( usRename( ConsSimple, 'cs')) uNames.next( usRename( Symbol, 's')) testCrCr( codeListFakeRoot( cs( s( 'a'), tail)), i.codeList) test( ConsTrait( cs( cs( s( 'a'), tail), nil)).repr_wrapped() , ConsRepr( i.codeListParent2EvalToken).repr_wrapped( None, [ CpctReprCodeListConfigMake])) i.evalToken( cs( ar_value, s( 'b'))) elem= codeListFake( cs( s( 'b'), nil)) tail= cs( elem, nil) testCrCr( codeListFakeRoot( cs( s( 'a'), tail)), i.codeList) testCrCr( cs( cs( s( 'a'), tail), nil), i.codeListParent2EvalToken) i.evalToken( cs( ar_value, s( 'c'))) elem= codeListFake( cs( s( 'b'), cs( s( 'c'), nil))) tail= cs( elem, nil) testCrCr( codeListFakeRoot( cs( s( 'a'), tail)), i.codeList) testCrCr( cs( cs( s( 'a'), tail), nil), i.codeListParent2EvalToken) i.evalToken( cs( ar_value, s( ')'))) testCrCr( codeListFakeRoot( cs( s( 'a'), cs( elem, nil))), i.codeList) test( nil , i.codeListParent2EvalToken ) i.evalToken( cs( ar_value, s( 'd'))) testCrCr( codeListFakeRoot( cs( s( 'a'), cs( elem, cs( s( 'd'), nil)))), i.codeList) test( nil , i.codeListParent2EvalToken ) uNames.undo() uNames.undo() uNames.undo() te.checkComplainAndAdjustExpected( 11)
def testSymbols1(): # 010407a6a37b49bfb9836e84236e5586 te.checkComplainAndAdjustExpected( 0) s1= Symbol( 's1') s2= Symbol( 's2') s3= Symbol( 's3') s4= Symbol( 's4') te.test( not typeSymbolChk( s4, Symbol( 's4'))) te.test( typeSymbolChk( s4, s4)) te.test( typeSymbolChk( s1, s1)) typeSymbol.symAdd( s2, [s1]) typeSymbol.symAdd( s3, [s1]) typeSymbol.symAdd( s4, [s2, s3]) te.test( typeSymbolChk( s4, s3)) te.test( typeSymbolChk( s4, s2)) te.test( typeSymbolChk( s4, s1)) te.test( typeSymbolChk( s3, s1)) te.test( typeSymbolChk( s2, s1)) typeSymbolNot.symAdd( s3, [s1]) te.test( typeSymbolChk( s4, s3)) te.test( typeSymbolChk( s4, s2)) te.test( typeSymbolChk( s4, s1)) te.test( not typeSymbolChk( s3, s1)) te.test( typeSymbolChk( s2, s1)) typeSymbolNot.symAdd( s2, [s1]) te.test( typeSymbolChk( s4, s3)) te.test( typeSymbolChk( s4, s2)) te.test( not typeSymbolChk( s4, s1)) te.test( not typeSymbolChk( s3, s1)) te.test( not typeSymbolChk( s2, s1)) typeSymbolNot.symAdd( s4, [s3,s2]) te.test( not typeSymbolChk( s4, s3)) te.test( not typeSymbolChk( s4, s2)) te.test( not typeSymbolChk( s4, s1)) te.test( not typeSymbolChk( s3, s1)) te.test( not typeSymbolChk( s2, s1)) typeSymbolNot.symDel( s3) te.test( not typeSymbolChk( s4, s3)) te.test( not typeSymbolChk( s4, s2)) te.test( not typeSymbolChk( s4, s1)) te.test( typeSymbolChk( s3, s1)) te.test( not typeSymbolChk( s2, s1)) typeSymbolNot.symDel( s2) te.test( not typeSymbolChk( s4, s3)) te.test( not typeSymbolChk( s4, s2)) te.test( not typeSymbolChk( s4, s1)) te.test( typeSymbolChk( s3, s1)) te.test( typeSymbolChk( s2, s1)) typeSymbolNot.symDel( s4) for i in ( s4, s3, s2): typeSymbol.symDel( i) te.checkComplainAndAdjustExpected( 33)
def testConsAbstraction1(): # Referenzbeispiel fuer Cons-Abstraktion te.checkComplainAndAdjustExpected( 0) CAS1= makeConsAbstractSwap( ConsSimple) CAS1.__name__= 'CAS1' CAS2= makeConsAbstractSwap( CAS1) CAS2.__name__= 'CAS2' CAS3= makeConsAbstractSwap( CAS2) CAS3.__name__= 'CAS3' CAS4= makeConsAbstractSwap( CAS3) CAS4.__name__= 'CAS4' cs4= CAS4( 1, CAS4( 2, CAS4( 3, nil))) #print ConsTrait( ConsSimple( 1, ConsSimple( 2, ConsSimple( 3, nil)))).repr_wrapped() testCrCr( CAS4( 1, CAS4( 2, CAS4( 3, nil))), cs4) testCrCr( CAS3( CAS3( CAS3( nil, 3), 2), 1), cs4.consWrapped) testCrCr( CAS2( 1, CAS2( 2, CAS2( 3, nil))), cs4.consWrapped.consWrapped) testCrCr( CAS1( CAS1( CAS1( nil, 3), 2), 1), cs4.consWrapped.consWrapped.consWrapped) testCrCr( cs( 1, cs( 2, cs( 3, nil))), cs4.consWrapped.consWrapped.consWrapped.consWrapped) cs4.cdr( CAS4( 4, nil)) test( "CAS4( 1, CAS4( 4, Symbol( 'nil')))", ConsTrait( cs4).repr_wrapped()) testCrCr( CAS4( 1, CAS4( 4, nil)), cs4) testCrCr( cs( 1, cs( 4, nil)), cs4.consWrapped.consWrapped.consWrapped.consWrapped) cs4_2= CAS4.cf.packDeep( ConsSimple( 5, 6)) test( "CAS4( 5, 6)", ConsTrait( cs4_2).repr_wrapped()) test( "CAS3( 6, 5)", ConsTrait( cs4_2.consWrapped).repr_wrapped()) test( "CAS2( 5, 6)", ConsTrait( cs4_2.consWrapped.consWrapped).repr_wrapped()) test( "CAS1( 6, 5)", ConsTrait( cs4_2.consWrapped.consWrapped.consWrapped).repr_wrapped()) test( "ConsSimple( 5, 6)", ConsTrait( cs4_2.consWrapped.consWrapped.consWrapped.consWrapped).repr_wrapped()) test( id( cs4_2.consWrapped), id( cs4_2.cf.unpack( cs4_2))) test( id( cs4_2.consWrapped), id( cs4_2.cf.unpackDeep( cs4_2, CAS3))) test( id( cs4_2.consWrapped.consWrapped), id( cs4_2.cf.unpackDeep( cs4_2, CAS2))) test( id( cs4_2.consWrapped.consWrapped.consWrapped), id( cs4_2.cf.unpackDeep( cs4_2, CAS1))) test( id( cs4_2.consWrapped.consWrapped.consWrapped.consWrapped), id( cs4_2.cf.unpackDeep( cs4_2, ConsSimple))) cs4.cdr().cdr( cs4_2) test( "CAS4( 1, CAS4( 4, CAS4( 5, 6)))", ConsTrait( cs4).repr_wrapped()) test( "ConsSimple( 1, ConsSimple( 4, ConsSimple( 5, 6)))", ConsTrait( cs4.consWrapped.consWrapped.consWrapped.consWrapped).repr_wrapped()) test( ConsTrait( cs4), ConsTrait( cs4.consWrapped.consWrapped.consWrapped.consWrapped)) cs4_cloned= ConsTrait( cs4).cloneDeep() test( "ConsSimple( 1, ConsSimple( 4, ConsSimple( 5, 6)))", ConsTrait( cs4_cloned).repr_wrapped()) test( ConsTrait( cs4), ConsTrait( cs4_cloned)) test( id( cs4.cdr()), id( cs4.cdr())) cs5= ConsSimple( nil, nil) cs5.cdr( cs5) cs6= CAS1.cf.packDeep( cs5) cs7= CAS4.cf.packDeep( cs5) test( id( cs5), id( cs5.cdr())) test( id( cs6), id( cs6.car())) test( id( cs7), id( cs7.cdr())) test( id( cs6), id( CAS1.cf.pack( cs5))) test( id( cs6), id( CAS1.cf.packDeep( cs5))) test( id( cs7), id( CAS4.cf.packDeep( cs5))) test( id( CAS1.cf.packDeep( cs5)), id( CAS1.cf.packDeep( cs5))) test( id( CAS2.cf.pack( cs6)), id( CAS2.cf.pack( cs6))) test( id( CAS2.cf.packDeep( cs6)), id( CAS2.cf.packDeep( cs6))) test( id( CAS2.cf.packDeep( cs5)), id( CAS2.cf.packDeep( cs5))) # baustelle_geloest: nachteil der jetzigen loesung war, dass durch die dynamik immer neue Objekte in den oberen leveln entstehen # Vorteil - der obere Aufbau ist immer ein korrektes Abbild des Unterbaus # Vorteil - die ids sind jetzt eindeutig, wegen nicht mehr immer neuer Objekte und das bedeutet fuer die registrierung in Hash-Tables keine Zuverlaessigkeit # Vorteil - zyklische Datenstrukturen sollten jetzt auch keine unendlichen Views abbilden cs8= CAS4( nil, nil) cs8.cdr( cs8) cs9= cs8.consWrapped.consWrapped.consWrapped.consWrapped test( id( cs9), id( cs9.cdr())) # sogar das geht, prima te.checkComplainAndAdjustExpected( 35)