test(r): narrow the regex and rename-safety results so typecheck:tests passes

This commit is contained in:
Mick Cooney 2026-10-17 20:10:26 +01:00
parent ba477524dc
commit 8bbc3bbd4b
3 changed files with 13 additions and 14 deletions

View file

@ -101,7 +101,7 @@ describe('the per-pattern state cap sits exactly at MAX_STATES', () => {
it('refuses a pattern one state over the cap, and says why', () => {
const result = compileLinearRegexDetailed('^a{16382}$');
expect(result.regex).toBeNull();
expect(result.regex === null ? result.reason : '').toMatch(/state cap/);
expect('reason' in result ? result.reason : '').toMatch(/state cap/);
});
});
@ -112,13 +112,13 @@ describe('the pattern length cap sits exactly at MAX_PATTERN_LENGTH', () => {
// Longer than the state cap would allow if it were expanded, so look at the reason only
// when it is refused: the length rule must not be the one that refuses it.
const result = compileLinearRegexDetailed(pattern);
expect(result.regex === null ? result.reason : '').not.toMatch(/longer than/);
expect('reason' in result ? result.reason : '').not.toMatch(/longer than/);
});
it('refuses a pattern one character longer', () => {
const result = compileLinearRegexDetailed(`^${'a'.repeat(MAX_PATTERN_LENGTH - 1)}$`);
expect(result.regex).toBeNull();
expect(result.regex === null ? result.reason : '').toMatch(/longer than 16384 characters/);
expect('reason' in result ? result.reason : '').toMatch(/longer than 16384 characters/);
});
});

View file

@ -135,6 +135,6 @@ describe('R rename: NAMESPACE export guard on a refined graph', () => {
]),
graph,
} as never);
expect(issue?.code).toBe('unsupported_occurrence');
expect(issue ? issue.code : 'ok').toBe('unsupported_occurrence');
});
});

View file

@ -134,16 +134,15 @@ describe('R rename: the S3 registration guard', () => {
label,
properties: { filePath: 'R/a.R', name: 'helper', isExported: true },
});
return (
rRenameProvider.checkSafety?.({
target: { type: 'Function', qualifiedName: 'helper', filePath: 'R/a.R' },
newName: 'helper2',
files: new Map([
['R/a.R', { tree: parser.parse('helper <- function(x) x'), parsed: { localDefs: [] } }],
]),
graph,
} as never)?.code ?? 'ok'
);
const issue = rRenameProvider.checkSafety?.({
target: { type: 'Function', qualifiedName: 'helper', filePath: 'R/a.R' },
newName: 'helper2',
files: new Map([
['R/a.R', { tree: parser.parse('helper <- function(x) x'), parsed: { localDefs: [] } }],
]),
graph,
} as never);
return issue ? issue.code : 'ok';
};
expect(inPackage('Function')).toBe('unsupported_occurrence');
expect(inPackage('Method')).toBe('ok');