Skip to content

Remove test/stdlib assertions that do not depend on RBS signatures - #3216

Merged
ksss merged 1 commit into
ruby:masterfrom
ksss:fix-stdlib-non-type-tests
Oct 10, 2026
Merged

ksss merged 1 commit into
ruby:masterfrom
ksss:fix-stdlib-non-type-tests

Conversation

@ksss

@ksss ksss commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Tests under test/stdlib exist to detect mismatches between RBS signatures and the actual behavior. The criterion used here: does the test fail when the corresponding RBS definition is broken? If not, it only re-tests Ruby itself, which Ruby's own test suite already does.

This removes or rewrites such assertions so that test/stdlib no longer calls assert, assert_equal, assert_instance_of, assert_kind_of or assert_nil, in preparation for a RuboCop cop that forbids them there.

Changes

File Change Verified by breaking RBS
Kernel_test.rb Remove test_exit! (checks subprocess exit status only) Passed even with exit!: (Symbol) -> Integer
Kernel_test.rb Remove assert_equal nil, eval('__dir__'). The nil path cannot go through assert_send_type since the spy is always the caller frame —
Exception_test.rb Remove assert_instance_of; the following assert_send_type already checks the argument type —
OpenSSL_test.rb encrypt_decrypt never ran (no test_ prefix). Renamed to test_encrypt_decrypt (only coverage of Cipher#padding=) and dropped the round-trip assert_equal Fails with padding=: (String) -> Integer
Regexp_test.rb Remove test_TimeoutError, which only checked Ruby's superclass —
Refinement_test.rb Replace assert(true) calls with refute_send_type '() -> untyped'. Calling import_methods with modules through the spy crashes the VM (cref_replace_with_duplicated_cref_each_frame: unreachable), so only the no-arg case is checked Fails with import_methods: (*Module) -> self
global_variables_test.rb assert_global_type now also checks the value against the RBS global declaration (env.global_decls). Previously it only compared against the type given in the test Fails when $!/$\ types are changed or $1 is removed
global_variables_test.rb Fix assert_global_type 'nil', $\ → :$\. It passed the value (nil) instead of the symbol, so eval("") was checked and $\ was never tested —

Out of scope

assert_raises (e.g. assert_raises X do assert_send_type ... end in uri tests, replaceable with assert_send_type_error) and RBS-independent assert_type usages will be handled in follow-up PRs.

🤖 Generated with Claude Code

Tests under test/stdlib exist to detect mismatches between RBS signatures
and the actual behavior. Assertions that keep passing even when the
corresponding RBS definition is broken only re-test Ruby itself.

* Kernel: remove `test_exit!` (checks subprocess exit status only) and the
  `assert_equal nil, eval('__dir__')` line (the nil path cannot go through
  `assert_send_type` because the spy is always the caller frame).
* Exception: remove redundant `assert_instance_of`.
* OpenSSL: rename dead `encrypt_decrypt` to `test_encrypt_decrypt` so it
  runs (it is the only coverage of `Cipher#padding=`), dropping the
  plaintext round-trip `assert_equal`.
* Regexp: remove `test_TimeoutError`, which only checked Ruby's superclass.
* Refinement: check `import_methods` with `refute_send_type` instead of
  `assert(true)`. Calling it with modules through the spy crashes the VM.
* global_variables: make `assert_global_type` also check the value against
  the RBS global declaration, and fix `$\` test which passed the value
  instead of the symbol and so never tested `$\`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ksss
ksss added this pull request to the merge queue Oct 10, 2026
Merged via the queue into ruby:master with commit f371c94 Oct 10, 2026
25 checks passed
@ksss
ksss deleted the fix-stdlib-non-type-tests branch October 10, 2026 06:53
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.

1 participant