github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/ast/function_decl_test.go (about)

     1  package ast
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestFunctionDecl(t *testing.T) {
     8  	nodes := map[string]Node{
     9  		`0x7fb5a90e60d0 <line:231:1, col:22> col:7 clearerr 'void (FILE *)'`: &FunctionDecl{
    10  			Addr:         0x7fb5a90e60d0,
    11  			Pos:          NewPositionFromString("line:231:1, col:22"),
    12  			Prev:         "",
    13  			Position2:    "col:7",
    14  			Name:         "clearerr",
    15  			Type:         "void (FILE *)",
    16  			Type2:        "",
    17  			IsExtern:     false,
    18  			IsImplicit:   false,
    19  			IsUsed:       false,
    20  			IsReferenced: false,
    21  			IsStatic:     false,
    22  			IsInline:     false,
    23  			ChildNodes:   []Node{},
    24  		},
    25  		`0x7fb5a90e2a50 </usr/include/sys/stdio.h:39:1, /usr/include/AvailabilityInternal.h:21697:126> /usr/include/sys/stdio.h:39:5 renameat 'int (int, const char *, int, const char *)'`: &FunctionDecl{
    26  			Addr:         0x7fb5a90e2a50,
    27  			Pos:          NewPositionFromString("/usr/include/sys/stdio.h:39:1, /usr/include/AvailabilityInternal.h:21697:126"),
    28  			Prev:         "",
    29  			Position2:    "/usr/include/sys/stdio.h:39:5",
    30  			Name:         "renameat",
    31  			Type:         "int (int, const char *, int, const char *)",
    32  			Type2:        "",
    33  			IsExtern:     false,
    34  			IsImplicit:   false,
    35  			IsUsed:       false,
    36  			IsReferenced: false,
    37  			IsStatic:     false,
    38  			IsInline:     false,
    39  			ChildNodes:   []Node{},
    40  		},
    41  		`0x7fb5a90e9b70 </usr/include/stdio.h:244:6> col:6 implicit fprintf 'int (FILE *, const char *, ...)' extern`: &FunctionDecl{
    42  			Addr:         0x7fb5a90e9b70,
    43  			Pos:          NewPositionFromString("/usr/include/stdio.h:244:6"),
    44  			Prev:         "",
    45  			Position2:    "col:6",
    46  			Name:         "fprintf",
    47  			Type:         "int (FILE *, const char *, ...)",
    48  			Type2:        "",
    49  			IsExtern:     true,
    50  			IsImplicit:   true,
    51  			IsUsed:       false,
    52  			IsReferenced: false,
    53  			IsStatic:     false,
    54  			IsInline:     false,
    55  			ChildNodes:   []Node{},
    56  		},
    57  		`0x7fb5a90e9d40 prev 0x7fb5a90e9b70 <col:1, /usr/include/sys/cdefs.h:351:63> /usr/include/stdio.h:244:6 fprintf 'int (FILE *, const char *, ...)'`: &FunctionDecl{
    58  			Addr:         0x7fb5a90e9d40,
    59  			Pos:          NewPositionFromString("col:1, /usr/include/sys/cdefs.h:351:63"),
    60  			Prev:         "0x7fb5a90e9b70",
    61  			Position2:    "/usr/include/stdio.h:244:6",
    62  			Name:         "fprintf",
    63  			Type:         "int (FILE *, const char *, ...)",
    64  			Type2:        "",
    65  			IsExtern:     false,
    66  			IsImplicit:   false,
    67  			IsUsed:       false,
    68  			IsReferenced: false,
    69  			IsStatic:     false,
    70  			IsInline:     false,
    71  			ChildNodes:   []Node{},
    72  		},
    73  		`0x7fb5a90ec210 <line:259:6> col:6 implicit used printf 'int (const char *, ...)' extern`: &FunctionDecl{
    74  			Addr:         0x7fb5a90ec210,
    75  			Pos:          NewPositionFromString("line:259:6"),
    76  			Prev:         "",
    77  			Position2:    "col:6",
    78  			Name:         "printf",
    79  			Type:         "int (const char *, ...)",
    80  			Type2:        "",
    81  			IsExtern:     true,
    82  			IsImplicit:   true,
    83  			IsUsed:       true,
    84  			IsReferenced: false,
    85  			IsStatic:     false,
    86  			IsInline:     false,
    87  			ChildNodes:   []Node{},
    88  		},
    89  		`0x2ae30d8 </usr/include/math.h:65:3, /usr/include/x86_64-linux-gnu/sys/cdefs.h:57:54> <scratch space>:17:1 __acos 'double (double)' extern`: &FunctionDecl{
    90  			Addr:         0x2ae30d8,
    91  			Pos:          NewPositionFromString("/usr/include/math.h:65:3, /usr/include/x86_64-linux-gnu/sys/cdefs.h:57:54"),
    92  			Prev:         "",
    93  			Position2:    "<scratch space>:17:1",
    94  			Name:         "__acos",
    95  			Type:         "double (double)",
    96  			Type2:        "",
    97  			IsExtern:     true,
    98  			IsImplicit:   false,
    99  			IsUsed:       false,
   100  			IsReferenced: false,
   101  			IsStatic:     false,
   102  			IsInline:     false,
   103  			ChildNodes:   []Node{},
   104  		},
   105  		`0x7fc595071500 <line:26:1, line:69:1> line:26:5 referenced main 'int (int, char **)'`: &FunctionDecl{
   106  			Addr:         0x7fc595071500,
   107  			Pos:          NewPositionFromString("line:26:1, line:69:1"),
   108  			Prev:         "",
   109  			Position2:    "line:26:5",
   110  			Name:         "main",
   111  			Type:         "int (int, char **)",
   112  			Type2:        "",
   113  			IsExtern:     false,
   114  			IsImplicit:   false,
   115  			IsUsed:       false,
   116  			IsReferenced: true,
   117  			IsStatic:     false,
   118  			IsInline:     false,
   119  			ChildNodes:   []Node{},
   120  		},
   121  		`0x55973a008cb0 <line:93619:1, line:93630:1> line:93619:12 used exprIsConst 'int (Expr *, int, int)' static`: &FunctionDecl{
   122  			Addr:         0x55973a008cb0,
   123  			Pos:          NewPositionFromString("line:93619:1, line:93630:1"),
   124  			Prev:         "",
   125  			Position2:    "line:93619:12",
   126  			Name:         "exprIsConst",
   127  			Type:         "int (Expr *, int, int)",
   128  			Type2:        "",
   129  			IsExtern:     false,
   130  			IsImplicit:   false,
   131  			IsUsed:       true,
   132  			IsReferenced: false,
   133  			IsStatic:     true,
   134  			IsInline:     false,
   135  			ChildNodes:   []Node{},
   136  		},
   137  		`0x563ade547cb8 <safe_math.h:13:1, line:25:1> line:14:2 safe_unary_minus_func_int8_t_s 'int8_t (int8_t)':'int8_t (int8_t)' static`: &FunctionDecl{
   138  			Addr:         0x563ade547cb8,
   139  			Pos:          NewPositionFromString("safe_math.h:13:1, line:25:1"),
   140  			Prev:         "",
   141  			Position2:    "line:14:2",
   142  			Name:         "safe_unary_minus_func_int8_t_s",
   143  			Type:         "int8_t (int8_t)",
   144  			Type2:        "int8_t (int8_t)",
   145  			IsExtern:     false,
   146  			IsImplicit:   false,
   147  			IsUsed:       false,
   148  			IsReferenced: false,
   149  			IsStatic:     true,
   150  			IsInline:     false,
   151  			ChildNodes:   []Node{},
   152  		},
   153  		`0x556cac571be0 <tests/asm.c:9:1, line:13:1> line:9:26 sqlite3Hwtime1 'unsigned long (void)' inline`: &FunctionDecl{
   154  			Addr:         0x556cac571be0,
   155  			Pos:          NewPositionFromString("tests/asm.c:9:1, line:13:1"),
   156  			Prev:         "",
   157  			Position2:    "line:9:26",
   158  			Name:         "sqlite3Hwtime1",
   159  			Type:         "unsigned long (void)",
   160  			Type2:        "",
   161  			IsExtern:     false,
   162  			IsImplicit:   false,
   163  			IsUsed:       false,
   164  			IsReferenced: false,
   165  			IsStatic:     false,
   166  			IsInline:     true,
   167  			ChildNodes:   []Node{},
   168  		},
   169  		`0x21c3da0 <line:8201:1, line:8786:1> line:8201:25 used insertvertex 'enum insertvertexresult (struct mesh *, struct behavior *, vertex, struct otri *, struct osub *, int, int)'`: &FunctionDecl{
   170  			Addr:         0x21c3da0,
   171  			Pos:          NewPositionFromString("line:8201:1, line:8786:1"),
   172  			Prev:         "",
   173  			Position2:    "line:8201:25",
   174  			Name:         "insertvertex",
   175  			Type:         "enum insertvertexresult (struct mesh *, struct behavior *, vertex, struct otri *, struct osub *, int, int)",
   176  			Type2:        "",
   177  			IsExtern:     false,
   178  			IsImplicit:   false,
   179  			IsUsed:       true,
   180  			IsReferenced: false,
   181  			IsStatic:     false,
   182  			IsInline:     false,
   183  			ChildNodes:   []Node{},
   184  		},
   185  		`0x30bdba8 parent 0x304fbb0 <col:3, col:38> col:30 used getinfo 'enum countries ()'`: &FunctionDecl{
   186  			Addr:         0x30bdba8,
   187  			Pos:          NewPositionFromString("col:3, col:38"),
   188  			Prev:         "",
   189  			Parent:       "0x304fbb0",
   190  			Position2:    "col:30",
   191  			Name:         "getinfo",
   192  			Type:         "enum countries ()",
   193  			Type2:        "",
   194  			IsExtern:     false,
   195  			IsImplicit:   false,
   196  			IsUsed:       true,
   197  			IsReferenced: false,
   198  			IsStatic:     false,
   199  			IsInline:     false,
   200  			ChildNodes:   []Node{},
   201  		},
   202  		`0x353d3b8 parent 0x31e9ba0 prev 0x33b0810 <col:2, col:30> col:22 used dmatrix 'double **(long, long, long, long)'`: &FunctionDecl{
   203  			Addr:         0x353d3b8,
   204  			Pos:          NewPositionFromString("col:2, col:30"),
   205  			Prev:         "0x33b0810",
   206  			Parent:       "0x31e9ba0",
   207  			Position2:    "col:22",
   208  			Name:         "dmatrix",
   209  			Type:         "double **(long, long, long, long)",
   210  			Type2:        "",
   211  			IsExtern:     false,
   212  			IsImplicit:   false,
   213  			IsUsed:       true,
   214  			IsReferenced: false,
   215  			IsStatic:     false,
   216  			IsInline:     false,
   217  			ChildNodes:   []Node{},
   218  		},
   219  	}
   220  
   221  	runNodeTests(t, nodes)
   222  }