pretty printer: update TestPrintFile
This commit is contained in:
parent
0abe99274b
commit
335bedc34d
@ -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()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user