fix dumper test fail related to map order
This commit is contained in:
parent
e19df2783d
commit
4e1382cf71
@ -29,12 +29,14 @@ func (d Dumper) EnterNode(w walker.Walkable) bool {
|
|||||||
fmt.Printf(" %v", *p)
|
fmt.Printf(" %v", *p)
|
||||||
}
|
}
|
||||||
if a := n.Attributes(); len(a) > 0 {
|
if a := n.Attributes(); len(a) > 0 {
|
||||||
fmt.Printf(" %v", a)
|
for key, attr := range a {
|
||||||
|
fmt.Printf("\n%v\"%v\": %v;", d.Indent+" ", key, attr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
if c := d.Comments[n]; len(c) > 0 {
|
if c := d.Comments[n]; len(c) > 0 {
|
||||||
fmt.Printf("%vComments:\n", d.Indent+" ")
|
fmt.Printf("%v\"Comments\":\n", d.Indent+" ")
|
||||||
for _, cc := range c {
|
for _, cc := range c {
|
||||||
fmt.Printf("%v%q\n", d.Indent+" ", cc)
|
fmt.Printf("%v%q\n", d.Indent+" ", cc)
|
||||||
}
|
}
|
||||||
|
@ -30,50 +30,63 @@ func ExampleDumper() {
|
|||||||
}
|
}
|
||||||
nodes.Walk(dumper)
|
nodes.Walk(dumper)
|
||||||
|
|
||||||
// Output:
|
// Unordered output:
|
||||||
//| *stmt.StmtList Pos{Line: 3-11 Pos: 10-143}
|
//| *stmt.StmtList Pos{Line: 3-11 Pos: 10-143}
|
||||||
//| "Stmts":
|
//| "Stmts":
|
||||||
//| *stmt.Namespace Pos{Line: 3-11 Pos: 10-143}
|
//| *stmt.Namespace Pos{Line: 3-11 Pos: 10-143}
|
||||||
//| "NamespaceName":
|
//| "NamespaceName":
|
||||||
//| *name.Name Pos{Line: 3-3 Pos: 20-22}
|
//| *name.Name Pos{Line: 3-3 Pos: 20-22}
|
||||||
//| "Parts":
|
//| "Parts":
|
||||||
//| *name.NamePart Pos{Line: 3-3 Pos: 20-22} map[Value:Foo]
|
//| *name.NamePart Pos{Line: 3-3 Pos: 20-22}
|
||||||
|
//| "Value": Foo;
|
||||||
//| "Stmts":
|
//| "Stmts":
|
||||||
//| *stmt.Class Pos{Line: 4-10 Pos: 29-139} map[PhpDocComment:]
|
//| *stmt.Class Pos{Line: 4-10 Pos: 29-139}
|
||||||
|
//| "PhpDocComment": ;
|
||||||
//| "ClassName":
|
//| "ClassName":
|
||||||
//| *node.Identifier Pos{Line: 4-4 Pos: 35-37} map[Value:Bar]
|
//| *node.Identifier Pos{Line: 4-4 Pos: 35-37}
|
||||||
|
//| "Value": Bar;
|
||||||
//| "Stmts":
|
//| "Stmts":
|
||||||
//| *stmt.ClassMethod Pos{Line: 5-9 Pos: 45-134} map[ReturnsRef:false PhpDocComment:]
|
//| *stmt.ClassMethod Pos{Line: 5-9 Pos: 45-134}
|
||||||
|
//| "ReturnsRef": false;
|
||||||
|
//| "PhpDocComment": ;
|
||||||
//| "MethodName":
|
//| "MethodName":
|
||||||
//| *node.Identifier Pos{Line: 5-5 Pos: 61-72} map[Value:FunctionName]
|
//| *node.Identifier Pos{Line: 5-5 Pos: 61-72}
|
||||||
|
//| "Value": FunctionName;
|
||||||
//| "Modifiers":
|
//| "Modifiers":
|
||||||
//| *node.Identifier Pos{Line: 5-5 Pos: 45-50} map[Value:public]
|
//| *node.Identifier Pos{Line: 5-5 Pos: 45-50}
|
||||||
|
//| "Value": public;
|
||||||
//| "Params":
|
//| "Params":
|
||||||
//| *node.Parameter Pos{Line: 5-5 Pos: 74-89} map[ByRef:false Variadic:false]
|
//| *node.Parameter Pos{Line: 5-5 Pos: 74-89}
|
||||||
|
//| "ByRef": false;
|
||||||
|
//| "Variadic": false;
|
||||||
//| "VariableType":
|
//| "VariableType":
|
||||||
//| *name.Name Pos{Line: 5-5 Pos: 74-77}
|
//| *name.Name Pos{Line: 5-5 Pos: 74-77}
|
||||||
//| "Parts":
|
//| "Parts":
|
||||||
//| *name.NamePart Pos{Line: 5-5 Pos: 74-77} map[Value:Type]
|
//| *name.NamePart Pos{Line: 5-5 Pos: 74-77}
|
||||||
|
//| "Value": Type;
|
||||||
//| "Variable":
|
//| "Variable":
|
||||||
//| *expr.Variable Pos{Line: 5-5 Pos: 79-82}
|
//| *expr.Variable Pos{Line: 5-5 Pos: 79-82}
|
||||||
//| "VarName":
|
//| "VarName":
|
||||||
//| *node.Identifier Pos{Line: 5-5 Pos: 79-82} map[Value:$var]
|
//| *node.Identifier Pos{Line: 5-5 Pos: 79-82}
|
||||||
|
//| "Value": $var;
|
||||||
//| "DefaultValue":
|
//| "DefaultValue":
|
||||||
//| *expr.ConstFetch Pos{Line: 5-5 Pos: 86-89}
|
//| *expr.ConstFetch Pos{Line: 5-5 Pos: 86-89}
|
||||||
//| "Constant":
|
//| "Constant":
|
||||||
//| *name.Name Pos{Line: 5-5 Pos: 86-89}
|
//| *name.Name Pos{Line: 5-5 Pos: 86-89}
|
||||||
//| "Parts":
|
//| "Parts":
|
||||||
//| *name.NamePart Pos{Line: 5-5 Pos: 86-89} map[Value:null]
|
//| *name.NamePart Pos{Line: 5-5 Pos: 86-89}
|
||||||
|
//| "Value": null;
|
||||||
//| "Stmts":
|
//| "Stmts":
|
||||||
//| *stmt.Expression Pos{Line: 8-8 Pos: 124-128}
|
//| *stmt.Expression Pos{Line: 8-8 Pos: 124-128}
|
||||||
//| Comments:
|
//| "Comments":
|
||||||
//| "// some comment\n"
|
//| "// some comment\n"
|
||||||
//| "Expr":
|
//| "Expr":
|
||||||
//| *expr.Variable Pos{Line: 8-8 Pos: 124-127}
|
//| *expr.Variable Pos{Line: 8-8 Pos: 124-127}
|
||||||
//| Comments:
|
//| "Comments":
|
||||||
//| "// some comment\n"
|
//| "// some comment\n"
|
||||||
//| "VarName":
|
//| "VarName":
|
||||||
//| *node.Identifier Pos{Line: 8-8 Pos: 124-127} map[Value:$var]
|
//| *node.Identifier Pos{Line: 8-8 Pos: 124-127}
|
||||||
//| Comments:
|
//| "Value": $var;
|
||||||
|
//| "Comments":
|
||||||
//| "// some comment\n"
|
//| "// some comment\n"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user