Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Thread#thread_variable_get to match Ruby 3.4 behaviour #2433

Merged
merged 1 commit into from
Dec 29, 2024
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
10 changes: 3 additions & 7 deletions spec/core/thread/thread_variable_get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,13 @@

ruby_version_is '3.4' do
it "raises a TypeError if the key is neither Symbol nor String when no thread variables are set" do
NATFIXME 'it raises a TypeError if the key is neither Symbol nor String when no thread variables are set', exception: SpecFailedException do
-> { @t.thread_variable_get(123) }.should raise_error(TypeError, /123 is not a symbol/)
end
-> { @t.thread_variable_get(123) }.should raise_error(TypeError, /123 is not a symbol/)
end

it "raises a TypeError if the key is neither Symbol nor String without calling #to_sym" do
key = mock('key')
NATFIXME 'it raises a TypeError if the key is neither Symbol nor String without calling #to_sym', exception: SpecFailedException do
key.should_not_receive(:to_sym)
-> { @t.thread_variable_get(key) }.should raise_error(TypeError, /#{Regexp.escape(key.inspect)} is not a symbol/)
end
key.should_not_receive(:to_sym)
-> { @t.thread_variable_get(key) }.should raise_error(TypeError, /#{Regexp.escape(key.inspect)} is not a symbol/)
end
end
end
2 changes: 1 addition & 1 deletion src/thread_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,9 @@ bool ThreadObject::has_thread_variable(Env *env, Value key) const {
}

Value ThreadObject::thread_variable_get(Env *env, Value key) {
key = validate_key(env, key);
if (!m_thread_variables)
return NilObject::the();
key = validate_key(env, key);
return m_thread_variables->ref(env, key);
}

Expand Down
Loading