示例#1
0
    def assertValidStringifyAndParse(self, foraValue, checkActualValues = False):
        resultStr = FORA.makeSymbol("ParsableRepresentation")(foraValue)
        try:
            result2 = FORA.makeSymbol("ParsableRepresentation")(FORA.eval(resultStr))
        except:
            self.assertTrue(False,
                "Wasn't able to parse:\n**************\n%s\n*************\n\n%s"
                 % (resultStr, traceback.format_exc())
                )

        if checkActualValues:
            self.assertTrue(
                    FORA.eval(resultStr) == FORA.eval(result2),
                    "Printing and parsing %s resulted in %s, which is not the same."
                    % (resultStr,result2)
                    )
示例#2
0
def generateTestExpressions():
    def isOk(s):
        return '"""' not in s and "'''" not in s

    testFunctions = ForaValuePrintingTest.generateTestFunctions()
    reprSymbol = Fora.makeSymbol("ParsableRepresentation")
    tr = [reprSymbol(testFun) for testFun in testFunctions]

    return [x for x in tr if isOk(x)]
示例#3
0
def generateTestExpressions():
    def isOk(s):
        return '"""' not in s and "'''" not in s

    testFunctions = ForaValuePrintingTest.generateTestFunctions()
    reprSymbol = Fora.makeSymbol("ParsableRepresentation")
    tr = [reprSymbol(testFun) for testFun in testFunctions]

    return [x for x in tr if isOk(x)]
示例#4
0
 def assertValidParse(self, foraExpressionText, checkActualValues = False):
     result1 = FORA.eval(foraExpressionText)
     resultStr = FORA.makeSymbol("ParsableRepresentation")(result1)
     try:
         result2 = FORA.eval(resultStr)
     except:
         self.assertTrue(False,
             "Wasn't able to parse:\n**************\n%s\n*************\n\n%s"
              % (result1, traceback.format_exc())
             )
     if checkActualValues:
         self.assertTrue(
                 result1 == result2,
                 "Printing and parsing %s resulted in %s, which is not the same"
                 % (result1, result2)
                 )