Skip to content

Update tests: use %==% for strict equality and drop ::: for internal functions#9

Merged
yihui-bot merged 1 commit intomainfrom
copilot/update-tests-rules
Mar 31, 2026
Merged

Update tests: use %==% for strict equality and drop ::: for internal functions#9
yihui-bot merged 1 commit intomainfrom
copilot/update-tests-rules

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

Two test anti-patterns fixed: loose == comparisons (which don't catch type mismatches) replaced with %==% (identical()), and unnecessary gglite::: access removed since testit already exposes package internals to tests.

Test changes (tests/testit/test-gglite.R)

  • All == assertions → %==% (e.g. chart$layers[[1]]$type %==% 'point')
  • length(...) == nlength(...) %==% nL (integer literals to satisfy identical())
  • gglite:::build_config(), gglite:::g2_cdn(), gglite:::annotate_df() → direct calls
# Before
(length(chart$layers) == 2)
config = gglite:::build_config(chart)
(config$children[[1]]$type == 'interval')

# After
(length(chart$layers) %==% 2L)
config = build_config(chart)
(config$children[[1]]$type %==% 'interval')

Conventions update (.github/copilot-instructions.md)

Added two rules to the Testing Conventions section:

  • Use %==% instead of == for strict equality
  • Never use ::: in tests; testit exposes internal functions automatically

…rules to copilot instructions

Agent-Logs-Url: https://github.com/yihui/gglite/sessions/dc010c87-590a-4966-8494-5c4b7b6f041b

Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
@yihui-bot yihui-bot merged commit cc8225f into main Mar 31, 2026
5 checks passed
@yihui-bot yihui-bot deleted the copilot/update-tests-rules branch March 31, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants