Exemplo n.º 1
0
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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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)
Exemplo n.º 8
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)
Exemplo n.º 9
0
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)
Exemplo n.º 10
0
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)