test(r): pin that a UTF-8 BOM at the start of an R file indexes and renames

The grammar skips the mark, so the first-line definition, its CALLS edge and the
rename all work and the mark is kept. Added as a rename fixture; no code change.
This commit is contained in:
Mick Cooney 2026-10-18 16:05:07 +01:00
parent 659ec8134d
commit 53bbf3cc1a
4 changed files with 22 additions and 1 deletions

View file

@ -0,0 +1,3 @@
secret <- function(x) x * 2
run <- function() secret(2)

View file

@ -0,0 +1,3 @@
helper <- function(x) x * 2
run <- function() helper(2)

View file

@ -0,0 +1,15 @@
{
"language": "r",
"description": "A UTF-8 byte order mark at the start of an R file does not break indexing or rename: the definition on the first line is found and renamed with its call, and the mark is kept.",
"categories": ["encoding", "positive"],
"target": { "name": "helper", "kind": "Function", "file": "a.R", "startLine": 0 },
"newName": "secret",
"expect": { "status": "success", "edits": 2 },
"edges": [
{
"type": "CALLS",
"from": { "name": "run", "kind": "Function", "file": "a.R", "startLine": 2 },
"to": { "name": "helper", "kind": "Function", "file": "a.R", "startLine": 0 }
}
]
}

View file

@ -5,7 +5,7 @@ import { defineRenameFixtureTests, renameCases } from '../helpers/rename-integra
// would define no test and stay green. Pin the number of R cases: adding one means raising it.
describe('R rename fixtures', () => {
it('are all discovered', () => {
expect(renameCases.filter((fixture) => fixture.language === 'r')).toHaveLength(58);
expect(renameCases.filter((fixture) => fixture.language === 'r')).toHaveLength(59);
});
});