Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/stdlib/Exception_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def test_set_backtrace

if_ruby("3.4"..., skip: false) do
caller_locations[0].tap do |location|
assert_instance_of Thread::Backtrace::Location, location
assert_send_type(
"(Array[Thread::Backtrace::Location]) -> Array[Thread::Backtrace::Location]",
exception, :set_backtrace, [location]
Expand Down
36 changes: 0 additions & 36 deletions test/stdlib/Kernel_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,38 +107,6 @@ def test_exit
end
end

def test_exit!
# Sadly can't use `assert_send_type_error`, so we use exit status to check.
_, status = Process.wait2(Process.spawn(RUBY_EXECUTABLE, '--disable=all', '-e', 'exit!; exit(80)'))
assert_equal 1, status.exitstatus

_, status = Process.wait2(Process.spawn(RUBY_EXECUTABLE, '--disable=all', '-e', 'exit!(true); exit(80)'))
assert_equal 0, status.exitstatus

_, status = Process.wait2(Process.spawn(RUBY_EXECUTABLE, '--disable=all', '-e', 'exit!(false); exit(80)'))
assert_equal 1, status.exitstatus

_, status = Process.wait2(Process.spawn(RUBY_EXECUTABLE, '--disable=all', '-e', 'exit!(12); exit(80)'))
assert_equal 12, status.exitstatus

_, status = Process.wait2(Process.spawn(RUBY_EXECUTABLE, '--disable=all', '-e', <<~'RUBY'))
# hardcode a "blank slate" object in
class ToInt < BasicObject
instance_methods.each do |im|
next if im == :__id__
next if im == :__send__
undef_method im
end

def to_int = 12
end

exit!(ToInt.new)
exit(80)
RUBY
assert_equal 12, status.exitstatus
end

def test_at_exit
assert_send_type "() { () -> void } -> Proc",
Kernel, :at_exit do end
Expand Down Expand Up @@ -183,10 +151,6 @@ def test___method__
def test___dir__
assert_send_type '() -> String',
Kernel, :__dir__

# Make sure it can return `nil`; this can't go through `assert_send_type`,
# as it's only `nil` thru `eval`s
assert_equal nil, eval('__dir__')
end

def test_autoload
Expand Down
3 changes: 1 addition & 2 deletions test/stdlib/OpenSSL_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class OpenSSLCipherTest < Test::Unit::TestCase
library "openssl"
testing "::OpenSSL::Cipher"

def encrypt_decrypt
def test_encrypt_decrypt
key = ["2b7e151628aed2a6abf7158809cf4f3c"].pack("H*")
iv = ["000102030405060708090a0b0c0d0e0f"].pack("H*")
pt = ["6bc1bee22e409f96e93d7e117393172a" \
Expand All @@ -329,7 +329,6 @@ def encrypt_decrypt
assert_send_type "() -> String",
cipher, :final
cipher = new_decryptor("aes-128-cbc", key: key, iv: iv, padding: 0)
assert_equal pt, cipher.update(ct) << cipher.final
assert_send_type "(String) -> String",
cipher, :update, ct
assert_send_type "() -> String",
Expand Down
23 changes: 7 additions & 16 deletions test/stdlib/Refinement_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,16 @@ def test_target
end

def test_import_methods
assert_fn = method(:assert)
test = self

Module.new {
refine Integer do
# Due to a bug in Ruby, you can't call `import_methods` outside of `refine`

begin
import_methods
rescue
assert_fn.call(true)
else
assert_fn.call(false, "import_methods accepts at least one argument?")
end

import_methods Module.new
assert_fn.call(true)

import_methods Module.new, Module.new
assert_fn.call(true)
# Due to a bug in Ruby, you can't call `import_methods` outside of `refine`.
# Calling it with modules through `assert_send_type` also crashes the VM
# (`cref_replace_with_duplicated_cref_each_frame: unreachable`), so only the
# no-argument case is checked here.
test.refute_send_type '() -> untyped',
self, :import_methods
end
}
end
Expand Down
4 changes: 0 additions & 4 deletions test/stdlib/Regexp_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ class RegexpSingletonTest < Test::Unit::TestCase

testing 'singleton(::Regexp)'

def test_TimeoutError
assert Regexp::TimeoutError.superclass.equal?(RegexpError)
end

def test_EXTENDED
assert_const_type 'Integer',
'Regexp::EXTENDED'
Expand Down
19 changes: 4 additions & 15 deletions test/stdlib/global_variables_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,10 @@ def assert_global_type(type, global_name)
# I wish there was a `global_variable_get`; alas, `eval`.
global = block_given? ? yield : eval(global_name.to_s, nil, $0, $.)

typecheck = RBS::Test::TypeCheck.new(
builder: builder,
sample_size: 100,
unchecked_classes: []
)

value_type =
case type
when String
RBS::Parser.parse_type(type, variables: []) || raise
else
type
end
assert_type type, global

assert typecheck.value(global, value_type), "`#{global_name}` (#{global.inspect}) must be compatible with given type `#{value_type}`"
entry = env.global_decls.fetch(global_name.to_sym) { flunk "Cannot find RBS global declaration of `#{global_name}`" }
assert_type entry.decl.type, global
end

def test_gvar_exclaimation
Expand Down Expand Up @@ -295,7 +284,7 @@ def test_gvar_VERBOSE(gvar: :$VERBOSE)

def test_gvar_backwards_slash
# Don't test other `$\`s as they're deprecated
assert_global_type 'nil', $\
assert_global_type 'nil', :$\
end

def test_gvar_underscore
Expand Down
Loading