def unitTesting(codeGen): # Create the class suite first = True testing = [] for test in self._inlineTests: if not first: testing.append( Schema.BlankLine() ) testing.append( Schema.BlankLine() ) testing.append( test._createTestClass( codeGen ) ) first = False testing.append( Schema.BlankLine() ) testing.append( Schema.BlankLine() ) for test in self._inlineTests: testAst = codeGen.embeddedValue( test ) testing.append( Schema.ExprStmt( expr=Schema.Call( target=Schema.AttributeRef( target=testAst, name='_registerTestClass' ), args=[ Schema.Load( name=test._className ) ] ) ) ) selfAST = codeGen.embeddedValue( self ) moduleAST = codeGen.embeddedValue( codeGen.module ) globalsAST = Schema.Call( target=Schema.Load( name='globals' ), args=[] ) localsAST = Schema.Call( target=Schema.Load( name='locals' ), args=[] ) testing.append( Schema.ExprStmt( expr=Schema.Call( target=Schema.AttributeRef( target=selfAST, name='runTests' ), args=[] ) ) ) testing.append( Schema.ExprStmt( expr=Schema.Call( target=Schema.AttributeRef( target=selfAST, name='_registerScope' ), args=[ moduleAST, globalsAST, localsAST ] ) ) ) return Schema.PythonSuite( suite=testing )
def __apply_py_evalmodel__(self, codeGen, py_p): x = self.x.__py_evalmodel__(codeGen) y = self.y.__py_evalmodel__(codeGen) py_pres = codeGen.embeddedValue(Pres) py_pres_coerce = Py.AttributeRef(target=py_pres, name='coerce') py_p = Py.Call(target=py_pres_coerce, args=[py_p]) py_p = Py.Call(target=Py.AttributeRef(target=py_p, name='pad'), args=[x, y]) return py_p
def __apply_py_evalmodel__(self, codeGen, py_p): left = self.left.__py_evalmodel__(codeGen) right = self.right.__py_evalmodel__(codeGen) top = self.top.__py_evalmodel__(codeGen) bottom = self.bottom.__py_evalmodel__(codeGen) py_pres = codeGen.embeddedValue(Pres) py_pres_coerce = Py.AttributeRef(target=py_pres, name='coerce') py_p = Py.Call(target=py_pres_coerce, args=[py_p]) py_p = Py.Call(target=Py.AttributeRef(target=py_p, name='pad'), args=[left, right, top, bottom]) return py_p
def _createMethodAST(self, codeGen): valueStmts, resultVarName = self._createValueStmtsAndResultVarName( codeGen ) JythonExceptionAST = codeGen.embeddedValue( JythonException ) sysAST = codeGen.embeddedValue( sys ) getCurrentExceptionCallAST = Schema.Call( target=Schema.AttributeRef( target=JythonExceptionAST, name='getCurrentException' ), args=[] ) getExcInfoTypeAST = Schema.Subscript( target=Schema.Call( target=Schema.AttributeRef( target=sysAST, name='exc_info' ), args=[] ), index=Schema.IntLiteral( format='decimal', numType='int', value='0' ) ) selfAST = codeGen.embeddedValue( self ) testValueAST = Schema.AttributeRef( target=selfAST, name='_testValue' ) kindExceptionAST = Schema.StringLiteral( format='ascii', quotation='single', value='exception' ) kindValueAST = Schema.StringLiteral( format='ascii', quotation='single', value='value' ) exceptStmts = [ Schema.ExprStmt( expr=Schema.Call( target=testValueAST, args=[ kindExceptionAST, getCurrentExceptionCallAST, getExcInfoTypeAST ] ) ) ] elseStmts = [ Schema.ExprStmt( expr=Schema.Call( target=testValueAST, args=[ kindValueAST, Schema.Load( name=resultVarName ) ] ) ) ] methodBody = [ Schema.TryStmt( suite=valueStmts, exceptBlocks=[ Schema.ExceptBlock( suite=exceptStmts ) ], elseSuite=elseStmts ) ] methodAST = Schema.DefStmt( name=self._methodName, decorators=[], params=[ Schema.SimpleParam( name='self' ) ], suite=methodBody ) return methodAST
def __py_evalmodel__(self, codeGen): hasHAlign = not self.hAlignment.isConstant( ) or self.hAlignment.constantValue is not None hasVAlign = not self.vAlignment.isConstant( ) or self.vAlignment.constantValue is not None hAlign = self.hAlignment.__py_evalmodel__(codeGen) vAlign = self.vAlignment.__py_evalmodel__(codeGen) py_p = self.__component_py_evalmodel__(codeGen) padding = self.padding.value if padding is not None: py_p = padding.__apply_py_evalmodel__(codeGen, py_p) if hasHAlign or hasVAlign: py_pres = codeGen.embeddedValue(Pres) py_pres_coerce = Py.AttributeRef(target=py_pres, name='coerce') py_p = Py.Call(target=py_pres_coerce, args=[py_p]) if hasHAlign: py_p = Py.Call(target=Py.AttributeRef(target=py_p, name='alignH'), args=[hAlign]) if hasVAlign: py_p = Py.Call(target=Py.AttributeRef(target=py_p, name='alignV'), args=[vAlign]) return py_p
def __py_evalmodel__(self, codeGen): py_richSpanClass = codeGen.embeddedValue(RichSpan) richSpan = Py.Call(target=py_richSpanClass, args=[self._contents_py_evalmodel_(codeGen)]) py_styleSheet = codeGen.embeddedValue(self._styleSheet) return Py.Call(target=Py.AttributeRef(target=py_styleSheet, name='applyTo'), args=[richSpan])
def __apply_py_evalmodel__(self, codeGen, py_p): py_border = self.__makeBorder_py_evalmodel__(codeGen) return Py.Call(target=Py.AttributeRef(target=py_border, name='surround'), args=[py_p])