nswrap/ast/decl_ref_expr_test.go

98 lines
2.6 KiB
Go
Raw Normal View History

2019-04-09 11:52:21 -04:00
package ast
import (
"testing"
)
func TestDeclRefExpr(t *testing.T) {
2019-06-04 00:14:04 -04:00
nodes := map[string]testNode{
`0x7fc972064460 <col:8> 'FILE *' lvalue ParmVar 0x7fc9720642d0 '_p' 'FILE *'`: testNode{&DeclRefExpr{
2019-04-09 11:52:21 -04:00
Addr: 0x7fc972064460,
Pos: NewPositionFromString("col:8"),
Type: "FILE *",
Type1: "",
Lvalue: true,
For: "ParmVar",
Address2: "0x7fc9720642d0",
Name: "_p",
Type2: "FILE *",
Type3: "",
ChildNodes: []Node{},
},
0x7fc972064460,
NewPositionFromString("col:8"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
`0x7fc97206a958 <col:11> 'int (int, FILE *)' Function 0x7fc972064198 '__swbuf' 'int (int, FILE *)'`: testNode{&DeclRefExpr{
2019-04-09 11:52:21 -04:00
Addr: 0x7fc97206a958,
Pos: NewPositionFromString("col:11"),
Type: "int (int, FILE *)",
Type1: "",
Lvalue: false,
For: "Function",
Address2: "0x7fc972064198",
Name: "__swbuf",
Type2: "int (int, FILE *)",
Type3: "",
ChildNodes: []Node{},
},
0x7fc97206a958,
NewPositionFromString("col:11"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
`0x7fa36680f170 <col:19> 'struct programming':'struct programming' lvalue Var 0x7fa36680dc20 'variable' 'struct programming':'struct programming'`: testNode{&DeclRefExpr{
2019-04-09 11:52:21 -04:00
Addr: 0x7fa36680f170,
Pos: NewPositionFromString("col:19"),
Type: "struct programming",
Type1: "struct programming",
Lvalue: true,
For: "Var",
Address2: "0x7fa36680dc20",
Name: "variable",
Type2: "struct programming",
Type3: "struct programming",
ChildNodes: []Node{},
},
0x7fa36680f170,
NewPositionFromString("col:19"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
`0x35cb438 <col:13> 'int' EnumConstant 0x35ca300 'Jan' 'int'`: testNode{&DeclRefExpr{
2019-04-09 11:52:21 -04:00
Addr: 0x35cb438,
Pos: NewPositionFromString("col:13"),
Type: "int",
Type1: "",
Lvalue: false,
For: "EnumConstant",
Address2: "0x35ca300",
Name: "Jan",
Type2: "int",
Type3: "",
ChildNodes: []Node{},
},
0x35cb438,
NewPositionFromString("col:13"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
`0x1ff8770 <col:33> 'T_ENUM':'T_ENUM' lvalue Var 0x1ff8600 'cc' 'T_ENUM':'T_ENUM'`: testNode{&DeclRefExpr{
2019-04-09 11:52:21 -04:00
Addr: 0x1ff8770,
Pos: NewPositionFromString("col:33"),
Type: "T_ENUM",
Type1: "T_ENUM",
Lvalue: true,
For: "Var",
Address2: "0x1ff8600",
Name: "cc",
Type2: "T_ENUM",
Type3: "T_ENUM",
ChildNodes: []Node{},
},
0x1ff8770,
NewPositionFromString("col:33"),
[]Node{},
2019-06-04 00:14:04 -04:00
},
2019-04-09 11:52:21 -04:00
}
runNodeTests(t, nodes)
}