mirror of
https://github.com/yamadashy/repomix.git
synced 2026-02-03 11:33:39 +01:00
- Remove unused imports across 67 files (RepomixConfigMerged, QueryCapture, etc.) - Fix unused parameters by prefixing with underscore (_context, _index, etc.) - Remove unused catch parameters using modern JavaScript syntax - Fix require-yield warnings in generator functions - Remove unused variables and interface declarations - Add oxlint configuration to ignore integration test fixtures Resolves 144 linting warnings while preserving all functionality. All 743 tests continue to pass. Code quality significantly improved.
101 lines
3.0 KiB
TypeScript
101 lines
3.0 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
import { parseFile } from '../../../src/core/treeSitter/parseFile.js';
|
|
import { createMockConfig } from '../../testing/testUtils.js';
|
|
|
|
describe('parseFile for C/C++', () => {
|
|
// Test for C++
|
|
test('should parse C++ correctly', async () => {
|
|
const fileContent = `
|
|
// Main entry point
|
|
/* The main function that outputs
|
|
* a greeting to the world
|
|
*/
|
|
int main() {
|
|
std::cout << "Hello, world!"; return 0;
|
|
}
|
|
`;
|
|
const filePath = 'dummy.cpp';
|
|
const config = {};
|
|
const result = await parseFile(fileContent, filePath, createMockConfig(config));
|
|
expect(typeof result).toBe('string');
|
|
|
|
const expectContents = [
|
|
'// Main entry point',
|
|
'/* The main function that outputs',
|
|
'* a greeting to the world',
|
|
'*/',
|
|
'int main() {',
|
|
];
|
|
|
|
for (const expectContent of expectContents) {
|
|
expect(result).toContain(expectContent);
|
|
}
|
|
});
|
|
|
|
test('should parse C++ header correctly', async () => {
|
|
const fileContent = `
|
|
// Header file main function
|
|
/* This header declares the main function
|
|
* for the program entry point
|
|
*/
|
|
int main() { std::cout << "Hello, world!"; return 0; }
|
|
`;
|
|
const filePath = 'dummy.hpp';
|
|
const config = {};
|
|
const result = await parseFile(fileContent, filePath, createMockConfig(config));
|
|
expect(typeof result).toBe('string');
|
|
|
|
const expectContents = ['main', 'Header file main function', 'This header declares the main function'];
|
|
|
|
for (const expectContent of expectContents) {
|
|
expect(result).toContain(expectContent);
|
|
}
|
|
});
|
|
|
|
// Test for C
|
|
test('should parse C correctly', async () => {
|
|
const fileContent = `
|
|
/* The main function
|
|
* Prints a greeting to stdout
|
|
*/
|
|
// Entry point of the program
|
|
int main() { printf("Hello, world!"); return 0; }
|
|
`;
|
|
const filePath = 'dummy.c';
|
|
const config = {};
|
|
const result = await parseFile(fileContent, filePath, createMockConfig(config));
|
|
expect(typeof result).toBe('string');
|
|
|
|
const expectContents = ['main', 'The main function', 'Prints a greeting to stdout', 'Entry point of the program'];
|
|
|
|
for (const expectContent of expectContents) {
|
|
expect(result).toContain(expectContent);
|
|
}
|
|
});
|
|
|
|
test('should parse C header correctly', async () => {
|
|
const fileContent = `
|
|
/* Header file for main function
|
|
* Declares the program entry point
|
|
*/
|
|
// Main function prototype
|
|
int main() { printf("Hello, world!"); return 0; }
|
|
`;
|
|
const filePath = 'dummy.h';
|
|
const config = {};
|
|
const result = await parseFile(fileContent, filePath, createMockConfig(config));
|
|
expect(typeof result).toBe('string');
|
|
|
|
const expectContents = [
|
|
'main',
|
|
'Header file for main function',
|
|
'Declares the program entry point',
|
|
'Main function prototype',
|
|
];
|
|
|
|
for (const expectContent of expectContents) {
|
|
expect(result).toContain(expectContent);
|
|
}
|
|
});
|
|
});
|