Example #1
0
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)
Example #2
0
from InterpreterStructures import codeListGetParameters
from symbols import whitespace

from debugVariables import uNooProblem, nooProblem

class ExceptionQuit( Exception):

 def __init__( self, msg):
  Exception.__init__( self, msg)

class Essentials: # siehe 8c231655685648cc99e5b0bf3b0b8687

 def ess_print( self, *l):
  print reduce( (lambda x, y: x + ' '+ y), map( str, l), '')

ConsAbstractCarAutoHistoryCSCS= makeConsAbstractCarAutoHistory( ConsSimple, ConsSimple)

class Interpreter:

 def __init__( self):

  self.debug= False

  selfInterpreter= self

  self.readbuf= ConsSimple( nil, nil)
  self.macroBuf= nil
  self.env_globals= Environment()
  env_locals= self.env_globals.newChild()
  self.env_quotationMode_globals= Environment()
  env_quotationMode_locals= self.env_quotationMode_globals.newChild()
Example #3
0
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)