@@ -17,41 +17,50 @@ func TestConvertToAST_declaration_stmt_constant(t *testing.T) {
17
17
}{
18
18
{
19
19
input : "const int I;" ,
20
- expected : & ast.ConstDecl {
20
+ expected : & ast.GenDecl {
21
+ Token : ast .Token (ast .CONST ),
21
22
NodeAttributes : ast .NewNodeAttributesBuilder ().WithRangePositions (1 , 3 , 1 , 15 ).Build (),
22
- Names : []* ast.Ident {ast .NewIdentifierBuilder ().WithName ("I" ).WithStartEnd (1 , 13 , 1 , 14 ).BuildPtr ()},
23
- Type : option .Some (ast .NewTypeInfoBuilder ().
24
- WithName ("int" ).
25
- IsBuiltin ().
26
- WithStartEnd (1 , 9 , 1 , 12 ).
27
- WithNameStartEnd (1 , 9 , 1 , 12 ).
28
- Build ()),
23
+ Spec : & ast.ValueSpec {
24
+ Names : []* ast.Ident {ast .NewIdentifierBuilder ().WithName ("I" ).WithStartEnd (1 , 13 , 1 , 14 ).BuildPtr ()},
25
+ Type : ast .NewTypeInfoBuilder ().
26
+ WithName ("int" ).
27
+ IsBuiltin ().
28
+ WithStartEnd (1 , 9 , 1 , 12 ).
29
+ WithNameStartEnd (1 , 9 , 1 , 12 ).
30
+ Build (),
31
+ },
29
32
},
30
33
},
31
34
{
32
35
input : "const int I = 1;" , // With initialization
33
- expected : & ast.ConstDecl {
36
+ expected : & ast.GenDecl {
37
+ Token : ast .Token (ast .CONST ),
34
38
NodeAttributes : ast .NewNodeAttributesBuilder ().WithRangePositions (1 , 3 , 1 , 19 ).Build (),
35
- Names : []* ast.Ident {ast .NewIdentifierBuilder ().WithName ("I" ).WithStartEnd (1 , 13 , 1 , 14 ).BuildPtr ()},
36
- Type : option .Some (ast .NewTypeInfoBuilder ().
37
- WithName ("int" ).
38
- IsBuiltin ().
39
- WithStartEnd (1 , 9 , 1 , 12 ).
40
- WithNameStartEnd (1 , 9 , 1 , 12 ).
41
- Build ()),
42
- Initializer : & ast.BasicLit {
43
- NodeAttributes : ast .NewNodeAttributesBuilder ().WithRangePositions (1 , 17 , 1 , 18 ).Build (),
44
- Kind : ast .INT ,
45
- Value : "1" ,
39
+ Spec : & ast.ValueSpec {
40
+ Names : []* ast.Ident {ast .NewIdentifierBuilder ().WithName ("I" ).WithStartEnd (1 , 13 , 1 , 14 ).BuildPtr ()},
41
+ Type : ast .NewTypeInfoBuilder ().
42
+ WithName ("int" ).
43
+ IsBuiltin ().
44
+ WithStartEnd (1 , 9 , 1 , 12 ).
45
+ WithNameStartEnd (1 , 9 , 1 , 12 ).
46
+ Build (),
47
+ Value : & ast.BasicLit {
48
+ NodeAttributes : ast .NewNodeAttributesBuilder ().WithRangePositions (1 , 17 , 1 , 18 ).Build (),
49
+ Kind : ast .INT ,
50
+ Value : "1" ,
51
+ },
46
52
},
47
53
},
48
54
},
49
55
{
50
56
input : "const I;" , // Without type
51
- expected : & ast.ConstDecl {
57
+ expected : & ast.GenDecl {
58
+ Token : ast .Token (ast .CONST ),
52
59
NodeAttributes : ast .NewNodeAttributesBuilder ().WithRangePositions (1 , 3 , 1 , 11 ).Build (),
53
- Names : []* ast.Ident {ast .NewIdentifierBuilder ().WithName ("I" ).WithStartEnd (1 , 9 , 1 , 10 ).BuildPtr ()},
54
- Type : option .None [ast.TypeInfo ](),
60
+ Spec : & ast.ValueSpec {
61
+ Names : []* ast.Ident {ast .NewIdentifierBuilder ().WithName ("I" ).WithStartEnd (1 , 9 , 1 , 10 ).BuildPtr ()},
62
+ Type : nil ,
63
+ },
55
64
},
56
65
},
57
66
}
@@ -66,7 +75,7 @@ func TestConvertToAST_declaration_stmt_constant(t *testing.T) {
66
75
67
76
tree := ConvertToAST (GetCST (source ), source , "file.c3" )
68
77
69
- varDecl := tree .Modules [0 ].Declarations [0 ].(* ast.ConstDecl )
78
+ varDecl := tree .Modules [0 ].Declarations [0 ].(* ast.GenDecl )
70
79
assert .Equal (t , tt .expected , varDecl )
71
80
})
72
81
}
0 commit comments