fix(sample_source_call): respect local argument (#9) - #13
VincentGuyader wants to merge 3 commits into
Conversation
sample_source_call() was always returning the French-locale list
('Local','France','Europe','International'), leaking 'France' as a
source when users passed local='en_US'. Switch the list on the locale
the same way the other sample_* helpers do, so en_US now yields
'Local','US','Europe','International'.
Aligns sample_source_call() with the rest of the file's locale handling and turns silent fallthrough on unknown locales (e.g. local = 'de_DE') into an explicit error instead of yielding the en_US list.
ReviewThe core fix is correct: I checked out the branch and confirmed Most of the remarks below are about the new test file, which I think currently gives less protection than it looks like it does. Blocking items first. Tests1. It matches base R's DESCRIPTION has no 2.
3. Every new assertion checks the absence of 4.
5. Lines 31–32 only inspect Implementation6. With 7.
8. On the branch: recode_sample_yes(c("Yes","No"), "de_DE") # NULL, silently -> all-NA column
sample_yes(3, "de_DE") # Error: object 'vec' not foundand 9. It does partial matching and accepts sample_source_call(5, local = "fr") # levels: Local France Europe International — no error
sample_source_call(5, local = NULL) # en_US levels — no errorSo "any unsupported locale errors out instead of silently falling through to en_US" isn't quite true: Outside the fix10. Lines 27–40 define it with 11. DESCRIPTION is at 12. Commit 0c11133 bumps |
Summary
sample_source_call()was always returning the French-locale list (Local,France,Europe,International) regardless of thelocal =argument, leakingFranceinto datasets generated withlocal = "en_US". Branched on the locale soen_USnow yieldsLocal,US,Europe,International.local =is now declared withmatch.arg(), matching the rest of the file's contract: any unsupported locale (e.g."de_DE") errors out instead of silently falling through toen_US.Test plan
tests/testthat/test-locale.R: 6 PASS, including an explicit assertion thatFrancedoes not appear in theen_USfactor levels and a regression on the unknown-locale rejection.Closes #9