create CaseList node
This commit is contained in:
@@ -1428,7 +1428,7 @@ func (p *Printer) printStmtAltSwitch(n node.Node) {
|
||||
p.Print(nn.Cond)
|
||||
io.WriteString(p.w, ") :\n")
|
||||
|
||||
s := nn.Cases
|
||||
s := nn.CaseList.Cases
|
||||
p.printNodes(s)
|
||||
|
||||
io.WriteString(p.w, "\n")
|
||||
@@ -2009,7 +2009,7 @@ func (p *Printer) printStmtSwitch(n node.Node) {
|
||||
io.WriteString(p.w, ")")
|
||||
|
||||
io.WriteString(p.w, " {\n")
|
||||
p.printNodes(nn.Cases)
|
||||
p.printNodes(nn.CaseList.Cases)
|
||||
io.WriteString(p.w, "\n")
|
||||
p.printIndent()
|
||||
io.WriteString(p.w, "}")
|
||||
|
||||
@@ -2284,17 +2284,19 @@ func TestPrintStmtAltSwitch(t *testing.T) {
|
||||
Stmts: []node.Node{
|
||||
&stmt.AltSwitch{
|
||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
|
||||
Cases: []node.Node{
|
||||
&stmt.Case{
|
||||
Cond: &scalar.String{Value: "'a'"},
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
|
||||
CaseList: &stmt.CaseList{
|
||||
Cases: []node.Node{
|
||||
&stmt.Case{
|
||||
Cond: &scalar.String{Value: "'a'"},
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
&stmt.Case{
|
||||
Cond: &scalar.String{Value: "'b'"},
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
|
||||
&stmt.Case{
|
||||
Cond: &scalar.String{Value: "'b'"},
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -3649,17 +3651,19 @@ func TestPrintStmtSwitch(t *testing.T) {
|
||||
Stmts: []node.Node{
|
||||
&stmt.Switch{
|
||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
|
||||
Cases: []node.Node{
|
||||
&stmt.Case{
|
||||
Cond: &scalar.String{Value: "'a'"},
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
|
||||
CaseList: &stmt.CaseList{
|
||||
Cases: []node.Node{
|
||||
&stmt.Case{
|
||||
Cond: &scalar.String{Value: "'a'"},
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
&stmt.Case{
|
||||
Cond: &scalar.String{Value: "'b'"},
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
|
||||
&stmt.Case{
|
||||
Cond: &scalar.String{Value: "'b'"},
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user