DocPrompting: Accept a vc vector built before the call
The test required the named vector of virtual corpora to be written into
the collocationAnalysis call itself and counted binding it to a variable
first as a failure, although the labels of the comparison columns come
out the same either way.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Change-Id: I85f5452f90cf996e65477e54eb3728a483837962
diff --git a/tests/testthat/test-readme-against-llm.R b/tests/testthat/test-readme-against-llm.R
index 3454709..35111a7 100644
--- a/tests/testthat/test-readme-against-llm.R
+++ b/tests/testthat/test-readme-against-llm.R
@@ -498,9 +498,11 @@
generated_code <- extract_r_code(call_llm_api(prompt, model, max_tokens = 500))
expect_true(grepl("collocationAnalysis", generated_code), "Generated code should include collocationAnalysis")
- # the labels of the comparison columns come from the names of the vc vector
+ # the labels of the comparison columns come from the names of the vc vector,
+ # which may just as well be built before the call rather than inside it
expect_true(
- grepl("vc\\s*=\\s*c\\(\\s*[A-Za-z.`\"']", generated_code),
+ grepl("vc\\s*=\\s*c\\(\\s*[A-Za-z.`\"']", generated_code) ||
+ grepl("c\\(\\s*[`\"']?[A-Za-z.][A-Za-z0-9._]*[`\"']?\\s*=[^=]", generated_code),
"Generated code should pass a named vector of virtual corpora"
)
# one row per collocate and vc, so the comparison needs to be reduced