File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
src/main/ruby/truffleruby/core Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,20 @@ def !~(obj)
14
14
( obj !~ :foo ) . should == false
15
15
end
16
16
17
+ ruby_version_is "" ..."3.2" do
18
+ it "returns true if self does not respond to #=~" do
19
+ suppress_warning do
20
+ ( Object . new !~ :foo ) . should == true
21
+ end
22
+ end
23
+ end
24
+
25
+ ruby_version_is "3.2" do
26
+ it "raises NoMethodError if self does not respond to #=~" do
27
+ -> { Object . new !~ :foo } . should raise_error ( NoMethodError )
28
+ end
29
+ end
30
+
17
31
it 'can be overridden in subclasses' do
18
32
obj = KernelSpecs ::NotMatch . new
19
33
( obj !~ :bar ) . should == :foo
Original file line number Diff line number Diff line change @@ -182,7 +182,7 @@ def `(str) #`
182
182
module_function :` # `
183
183
184
184
def !~( other )
185
- r = self . respond_to? ( :=~ ) ? ! ( self =~ other ) : true
185
+ r = self =~ other ? false : true
186
186
Primitive . regexp_last_match_set ( Primitive . caller_special_variables , $~)
187
187
r
188
188
end
You can’t perform that action at this time.
0 commit comments