Repository navigation
Remove test/stdlib assertions that do not depend on RBS signatures - #3216
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tests under
test/stdlibexist 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/stdlibno longer callsassert,assert_equal,assert_instance_of,assert_kind_oforassert_nil, in preparation for a RuboCop cop that forbids them there.Changes
Kernel_test.rbtest_exit!(checks subprocess exit status only)exit!: (Symbol) -> IntegerKernel_test.rbassert_equal nil, eval('__dir__'). The nil path cannot go throughassert_send_typesince the spy is always the caller frameException_test.rbassert_instance_of; the followingassert_send_typealready checks the argument typeOpenSSL_test.rbencrypt_decryptnever ran (notest_prefix). Renamed totest_encrypt_decrypt(only coverage ofCipher#padding=) and dropped the round-tripassert_equalpadding=: (String) -> IntegerRegexp_test.rbtest_TimeoutError, which only checked Ruby'ssuperclassRefinement_test.rbassert(true)calls withrefute_send_type '() -> untyped'. Callingimport_methodswith modules through the spy crashes the VM (cref_replace_with_duplicated_cref_each_frame: unreachable), so only the no-arg case is checkedimport_methods: (*Module) -> selfglobal_variables_test.rbassert_global_typenow also checks the value against the RBS global declaration (env.global_decls). Previously it only compared against the type given in the test$!/$\types are changed or$1is removedglobal_variables_test.rbassert_global_type 'nil', $\→:$\. It passed the value (nil) instead of the symbol, soeval("")was checked and$\was never testedOut of scope
assert_raises(e.g.assert_raises X do assert_send_type ... endin uri tests, replaceable withassert_send_type_error) and RBS-independentassert_typeusages will be handled in follow-up PRs.🤖 Generated with Claude Code