Skip to content

Commit 132e4e1

Browse files
Jesse Caiclaude
andcommitted
Define the singleton method directly and drop the call loop
Review feedback: define obj.single with def obj.single instead of singleton_class.class_exec, and rely on mspec -R rather than an in-spec loop to exercise JIT-compiled paths. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 0e9b998 commit 132e4e1

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

core/module/ruby2_keywords_spec.rb

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,17 @@ def proc_call(*args)
134134

135135
it "does not copy or unmark the Hash when it is passed directly as a positional argument" do
136136
obj = Object.new
137-
obj.singleton_class.class_exec do
138-
def single(arg)
139-
arg
140-
end
137+
def obj.single(arg)
138+
arg
141139
end
142140

143141
h = { a: 1 }
144142
marked = mark(**h).last
145143
Hash.ruby2_keywords_hash?(marked).should == true
146144

147-
# Call repeatedly so implementations that compile methods lazily also
148-
# exercise their compiled path (regression: jruby/jruby#9517)
149-
100.times do
150-
after_usage = obj.single(marked)
151-
after_usage.should.equal?(marked)
152-
Hash.ruby2_keywords_hash?(after_usage).should == true
153-
end
145+
after_usage = obj.single(marked)
146+
after_usage.should.equal?(marked)
147+
Hash.ruby2_keywords_hash?(after_usage).should == true
154148
end
155149

156150
it "applies to the underlying method and applies across aliasing" do

0 commit comments

Comments
 (0)