Skip to content

Commit 335bedc

Browse files
committed
pretty printer: update TestPrintFile
1 parent 0abe992 commit 335bedc

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed

printer/printer_test.go

+42-5
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,54 @@ import (
1818
func TestPrintFile(t *testing.T) {
1919
o := bytes.NewBufferString("")
2020

21-
p := printer.NewPrinter(o, " ")
21+
p := printer.NewPrinter(o, "\t")
2222
p.PrintFile(&stmt.StmtList{
2323
Stmts: []node.Node{
24-
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
25-
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
24+
&stmt.Namespace{
25+
NamespaceName: &name.Name{
26+
Parts: []node.Node{
27+
&name.NamePart{Value: "Foo"},
28+
},
29+
},
30+
},
31+
&stmt.Class{
32+
Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
33+
ClassName: &name.Name{
34+
Parts: []node.Node{
35+
&name.NamePart{Value: "Bar"},
36+
},
37+
},
38+
Extends: &name.Name{
39+
Parts: []node.Node{
40+
&name.NamePart{Value: "Baz"},
41+
},
42+
},
43+
Stmts: []node.Node{
44+
&stmt.ClassMethod{
45+
Modifiers: []node.Node{&node.Identifier{Value: "public"}},
46+
MethodName: &node.Identifier{Value: "greet"},
47+
Stmts: []node.Node{
48+
&stmt.Echo{
49+
Exprs: []node.Node{
50+
&scalar.String{Value: "'Hello world'"},
51+
},
52+
},
53+
},
54+
},
55+
},
56+
},
2657
},
2758
})
2859

2960
expected := `<?php
30-
$a;
31-
$b;
61+
namespace Foo;
62+
abstract class Bar extends Baz
63+
{
64+
public function greet()
65+
{
66+
echo 'Hello world';
67+
}
68+
}
3269
`
3370
actual := o.String()
3471

0 commit comments

Comments
 (0)