Skip to content

Commit a4adc5b

Browse files
match detail added
1 parent 484f5f7 commit a4adc5b

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

testcases/tests/codeutils-test.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,41 @@ async function testCodeUtils() {
4949

5050
console.log('\n5. Testing match detail retrieval...');
5151
try {
52-
const matchDetailResult = await codebolt.codeutils.matchDetail('test-matcher');
53-
console.log('✅ Match detail result:', matchDetailResult);
52+
const matchDetailResult = await codebolt.codeutils.matchDetail('xmllint');
53+
console.log('✅ Match detail result:', matchDetailResult.payload);
5454
console.log(' - Type:', matchDetailResult?.type);
5555
console.log(' - Details available:', !!matchDetailResult?.details);
5656
} catch (error) {
5757
console.log('⚠️ Match detail retrieval failed:', error.message);
5858
}
59-
6059
console.log('\n6. Testing perform match operation...');
6160
try {
6261
const matcherDefinition = {
63-
name: 'test-matcher',
64-
pattern: 'function.*\\(',
65-
language: 'javascript'
62+
owner: "eslint-compact",
63+
pattern: [{
64+
regexp: "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
65+
file: 1,
66+
line: 2,
67+
column: 3,
68+
severity: 4,
69+
message: 5,
70+
code: 6
71+
}]
6672
};
67-
const problemPatterns = [
68-
{ pattern: 'logger\\.info', severity: 'warning' },
69-
{ pattern: 'var\\s+', severity: 'error' }
70-
];
71-
const problems = [
72-
{ line: 1, message: 'Use const instead of var' },
73-
{ line: 5, message: 'Remove console.log' }
73+
74+
const testProblems = [
75+
{ line: "src/file1.js: line 10, col 5, Error - Unexpected console statement (no-console)", source: "test" },
76+
{ line: "src/file2.js: line 25, col 8, Warning - 'var' used instead of 'let' or 'const' (no-var)", source: "test" },
77+
{ line: "This should not match", source: "test" }, // Invalid line
78+
{}, // Empty object
79+
{ line: "src/file3.js: line 5, col 15, Info - Missing JSDoc comment (require-jsdoc)", source: "test" }
7480
];
81+
7582

7683
const performMatchResult = await codebolt.codeutils.performMatch(
7784
matcherDefinition,
78-
problemPatterns,
79-
problems
85+
matcherDefinition.pattern,
86+
testProblems
8087
);
8188
console.log('✅ Perform match result:', performMatchResult);
8289
console.log(' - Type:', performMatchResult?.type);

0 commit comments

Comments
 (0)