pretty printer: update TestPrintFile

This commit is contained in:
z7zmey 2018-04-06 01:12:54 +03:00
parent 0abe99274b
commit 335bedc34d

View File

@ -18,17 +18,54 @@ import (
func TestPrintFile(t *testing.T) { func TestPrintFile(t *testing.T) {
o := bytes.NewBufferString("") o := bytes.NewBufferString("")
p := printer.NewPrinter(o, " ") p := printer.NewPrinter(o, "\t")
p.PrintFile(&stmt.StmtList{ p.PrintFile(&stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &stmt.Namespace{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, NamespaceName: &name.Name{
Parts: []node.Node{
&name.NamePart{Value: "Foo"},
},
},
},
&stmt.Class{
Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
ClassName: &name.Name{
Parts: []node.Node{
&name.NamePart{Value: "Bar"},
},
},
Extends: &name.Name{
Parts: []node.Node{
&name.NamePart{Value: "Baz"},
},
},
Stmts: []node.Node{
&stmt.ClassMethod{
Modifiers: []node.Node{&node.Identifier{Value: "public"}},
MethodName: &node.Identifier{Value: "greet"},
Stmts: []node.Node{
&stmt.Echo{
Exprs: []node.Node{
&scalar.String{Value: "'Hello world'"},
},
},
},
},
},
},
}, },
}) })
expected := `<?php expected := `<?php
$a; namespace Foo;
$b; abstract class Bar extends Baz
{
public function greet()
{
echo 'Hello world';
}
}
` `
actual := o.String() actual := o.String()