Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
littleGnAl committed Nov 22, 2023
1 parent d664fc9 commit e105bb9
Showing 1 changed file with 94 additions and 2 deletions.
96 changes: 94 additions & 2 deletions cxx-parser/__integration_test__/cxx_parser.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ describe('cxx_parser', () => {
{
"__TYPE":"Enumz",
"attributes":[],
"base_clazzs":[],
"comment":"",
"enum_constants": [
{
Expand Down Expand Up @@ -326,7 +325,6 @@ describe('cxx_parser', () => {
{
"__TYPE":"Enumz",
"attributes":[],
"base_clazzs":[],
"comment":"",
"enum_constants": [
{
Expand Down Expand Up @@ -419,6 +417,100 @@ describe('cxx_parser', () => {
// Use `JSON.parse` to parse the json string to avoid the format issue
expect(JSON.parse(json)).toEqual(JSON.parse(expectedJson));
});

it('normal typedef void* under typedef struct', () => {
let file1Path = path.join(tmpDir, 'file1.h');

fs.writeFileSync(
file1Path,
`
struct AAA {
int a;
};
typedef void* view_t;
`
);

let checkSum = generateChecksum([file1Path]);
let preProcessParseFilesDir = path.join(
cxxParserCacheDir,
`preProcess@${checkSum}`
);

// TODO(littlegnal): Should move the tmp/*.h to the build dir in the future
const expectedJson = `
[
{
"__TYPE":"CXXFile",
"file_path":"${preProcessParseFilesDir}/file1.h",
"nodes":[
{
"__TYPE":"Struct",
"attributes":[],
"base_clazzs":[],
"comment":"",
"constructors":[],
"file_path":"${preProcessParseFilesDir}/file1.h",
"member_variables":[
{
"__TYPE":"MemberVariable",
"access_specifier":"",
"is_mutable":false,
"name":"a",
"type":{
"__TYPE":"SimpleType",
"is_builtin_type":true,
"is_const":false,
"kind":100,
"name":"int",
"source":"int",
"template_arguments":[]
}
}
],
"methods":[],
"name":"AAA",
"namespaces":[],
"parent_name":"${preProcessParseFilesDir}/file1.h",
"source":""
},
{
"__TYPE": "TypeAlias",
"attributes": [],
"comment": "",
"file_path":"${preProcessParseFilesDir}/file1.h",
"name": "view_t",
"namespaces": [],
"parent_name":"${preProcessParseFilesDir}/file1.h",
"source": "",
"underlyingType": {
"__TYPE": "SimpleType",
"is_builtin_type": true,
"is_const": false,
"kind": 101,
"name": "void",
"source": "void*",
"template_arguments": []
}
}
]
}
]
`;

let json = dumpCXXAstJson(
new TerraContext(tmpDir),
[],
[file1Path],
[]
);

expect(fs.existsSync(preProcessParseFilesDir)).toBe(true);

// Use `JSON.parse` to parse the json string to avoid the format issue
expect(JSON.parse(json)).toEqual(JSON.parse(expectedJson));
});
});
});

Expand Down

0 comments on commit e105bb9

Please sign in to comment.