Skip to content

Commit e6fb452

Browse files
committed
Add specs for comparing non-ASCII compatible empty strings
1 parent d53c545 commit e6fb452

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

spec/ruby/core/string/comparison_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
(xff_1 <=> xff_2).should == -1
7676
(xff_2 <=> xff_1).should == 1
7777
end
78+
79+
it "returns 0 when comparing 2 empty strings but one is not ASCII-compatible" do
80+
("" <=> "".force_encoding('iso-2022-jp')).should == 0
81+
end
7882
end
7983

8084
# Note: This is inconsistent with Array#<=> which calls #to_ary instead of

spec/ruby/core/string/shared/eql.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@
3131
a.send(@method, b).should be_true
3232
b.send(@method, a).should be_true
3333
end
34+
35+
it "returns true when comparing 2 empty strings but one is not ASCII-compatible" do
36+
"".send(@method, "".force_encoding('iso-2022-jp')).should == true
37+
end
3438
end

0 commit comments

Comments
 (0)