test(r): pin a cross-file rename, the paste0 gap and the number of R rename cases

The documented claim that a rename succeeds across files had only same-file successes behind
it, and the undetected paste0() lookup was unpinned. Add a qualified pkg::name() cross-file
rename and a run-time-built lookup name, and count the R cases so that an emptied fixture
directory cannot leave the suite green with no test.
This commit is contained in:
Mick Cooney 2026-10-17 18:49:15 +01:00
parent 209653b861
commit e8701aa956
13 changed files with 52 additions and 1 deletions

View file

@ -0,0 +1,3 @@
Package: pk
Version: 0.1.0
Title: Fixture

View file

@ -0,0 +1 @@
export(g)

View file

@ -0,0 +1 @@
secret <- function() 1

View file

@ -0,0 +1 @@
g <- function() pk::secret()

View file

@ -0,0 +1,3 @@
Package: pk
Version: 0.1.0
Title: Fixture

View file

@ -0,0 +1 @@
export(g)

View file

@ -0,0 +1 @@
hidden <- function() 1

View file

@ -0,0 +1 @@
g <- function() pk::hidden()

View file

@ -0,0 +1,15 @@
{
"language": "r",
"description": "Rename a private package function that another file of the package calls as pkg::name(); the qualified call is a proven binding, so the rename crosses files.",
"categories": ["call-graph", "cross-file", "qualified-call", "namespace"],
"target": { "name": "hidden", "kind": "Function", "file": "R/f.R", "startLine": 0 },
"newName": "secret",
"expect": { "status": "success", "edits": 2 },
"edges": [
{
"type": "CALLS",
"from": { "name": "g", "kind": "Function", "file": "R/g.R", "startLine": 0 },
"to": { "name": "hidden", "kind": "Function", "file": "R/f.R", "startLine": 0 }
}
]
}

View file

@ -0,0 +1,3 @@
job <- function() 1
run <- function() do.call(paste0("wor", "ker"), list())

View file

@ -0,0 +1,3 @@
worker <- function() 1
run <- function() do.call(paste0("wor", "ker"), list())

View file

@ -0,0 +1,9 @@
{
"language": "r",
"description": "Rename a function that is looked up only by a name built at run time (paste0); the lookup is not detected, so the rename succeeds and the lookup string keeps the old name. Documented limit.",
"categories": ["string-dispatch", "documented-limit"],
"target": { "name": "worker", "kind": "Function", "file": "dyn.R", "startLine": 0 },
"newName": "job",
"expect": { "status": "success", "edits": 1 },
"edges": []
}

View file

@ -1,3 +1,12 @@
import { defineRenameFixtureTests } from '../helpers/rename-integration-cases.js';
import { describe, expect, it } from 'vitest';
import { defineRenameFixtureTests, renameCases } from '../helpers/rename-integration-cases.js';
// The fixture runner builds its test list from the directory, so an empty or renamed directory
// 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(49);
});
});
defineRenameFixtureTests('r');