def setUp(self): p0 = ir.TemplateNode( defs=[ ir.DefNode( '__main__()', ir.TextNode('Parent 0'))]) p1 = ir.TemplateNode( defs=[ ir.DefNode( '__main__()', ir.TextNode('Parent 1'))]) child = ir.TemplateNode( defs=[ ir.DefNode( '__main__()', ir.IfNode( 'p==0', ir.ExtendNode('parent0.txt')), ir.ElseNode( ir.ExtendNode('parent1.txt')))]) loader = kajiki.loader.MockLoader({ 'parent0.txt': kajiki.template.from_ir(p0), 'parent1.txt': kajiki.template.from_ir(p1), 'child.txt': kajiki.template.from_ir(child)}) self.loader = loader self.tpl = loader.import_('child.txt')
def setUp(self): lib = ir.TemplateNode( defs=[ir.DefNode( 'evenness(n)', ir.IfNode( 'n % 2 == 0', ir.TextNode('even')), ir.ElseNode( ir.TextNode('odd'))), ir.DefNode( 'half_evenness(n)', ir.TextNode(' half of '), ir.ExprNode('n'), ir.TextNode(' is '), ir.ExprNode('evenness(n/2)'))]) tpl = ir.TemplateNode( defs=[ir.DefNode( '__main__()', ir.ImportNode( 'lib.txt', 'simple_function'), ir.ForNode( 'i in range(4)', ir.ExprNode('i'), ir.TextNode(' is '), ir.ExprNode('simple_function.evenness(i)'), ir.ExprNode('simple_function.half_evenness(i)'), ir.TextNode('\n')))]) loader = kajiki.loader.MockLoader({ 'lib.txt': kajiki.template.from_ir(lib), 'tpl.txt': kajiki.template.from_ir(tpl)}) self.tpl = loader.import_('tpl.txt')
def setUp(self): self.tpl = ir.TemplateNode( defs=[ir.DefNode( '__main__()', ir.ForNode( 'i in range(2)', ir.ExprNode('i'), ir.TextNode(' is '), ir.SwitchNode( 'i % 2', ir.CaseNode( '0', ir.TextNode('even\n')), ir.ElseNode( ir.TextNode('odd\n')))))])
def setUp(self): self.tpl = ir.TemplateNode(defs=[ ir.DefNode( "__main__()", ir.ForNode( "i in range(2)", ir.ExprNode("i"), ir.TextNode(" is "), ir.SwitchNode( "i % 2", ir.CaseNode("0", ir.TextNode("even\n")), ir.ElseNode(ir.TextNode("odd\n")), ), ), ) ])
def setUp(self): self.tpl = ir.TemplateNode( defs=[ir.DefNode( 'evenness(n)', ir.IfNode( 'n % 2 == 0', ir.TextNode('even')), ir.ElseNode( ir.TextNode('odd'))), ir.DefNode( '__main__()', ir.ForNode( 'i in range(2)', ir.ExprNode('i'), ir.TextNode(' is '), ir.ExprNode('evenness(i)'), ir.TextNode('\n')))])
def setUp(self): self.tpl = ir.TemplateNode(defs=[ ir.DefNode( "evenness(n)", ir.IfNode("n % 2 == 0", ir.TextNode("even")), ir.ElseNode(ir.TextNode("odd")), ), ir.DefNode( "__main__()", ir.ForNode( "i in range(2)", ir.ExprNode("i"), ir.TextNode(" is "), ir.ExprNode("evenness(i)"), ir.TextNode("\n"), ), ), ])
def setUp(self): p0 = ir.TemplateNode( defs=[ir.DefNode("__main__()", ir.TextNode("Parent 0"))]) p1 = ir.TemplateNode( defs=[ir.DefNode("__main__()", ir.TextNode("Parent 1"))]) child = ir.TemplateNode(defs=[ ir.DefNode( "__main__()", ir.IfNode("p==0", ir.ExtendNode("parent0.txt")), ir.ElseNode(ir.ExtendNode("parent1.txt")), ) ]) loader = kajiki.loader.MockLoader({ "parent0.txt": kajiki.template.from_ir(p0), "parent1.txt": kajiki.template.from_ir(p1), "child.txt": kajiki.template.from_ir(child), }) self.loader = loader self.tpl = loader.import_("child.txt")
def setUp(self): lib = ir.TemplateNode(defs=[ ir.DefNode( "evenness(n)", ir.IfNode("n % 2 == 0", ir.TextNode("even")), ir.ElseNode(ir.TextNode("odd")), ), ir.DefNode( "half_evenness(n)", ir.TextNode(" half of "), ir.ExprNode("n"), ir.TextNode(" is "), ir.ExprNode("evenness(n/2)"), ), ]) tpl = ir.TemplateNode(defs=[ ir.DefNode( "__main__()", ir.ImportNode("lib.txt", "simple_function"), ir.ForNode( "i in range(4)", ir.ExprNode("i"), ir.TextNode(" is "), ir.ExprNode("simple_function.evenness(i)"), ir.ExprNode("simple_function.half_evenness(i)"), ir.TextNode("\n"), ), ) ]) loader = kajiki.loader.MockLoader({ "lib.txt": kajiki.template.from_ir(lib), "tpl.txt": kajiki.template.from_ir(tpl), }) self.tpl = loader.import_("tpl.txt")