Skip to content

Commit

Permalink
Add spec for fallback with KCODE set
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink committed Mar 8, 2013
1 parent 62628a1 commit 5e5a1da
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/ruby/core/regexp/shared/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,23 @@ class RegexpSpecsSubclassTwo < Regexp; end
Regexp.send(@method, /Hi/s).kcode.should == 'sjis'
Regexp.send(@method, /Hi/n).kcode.should == 'none'
end

describe "with $KCODE set" do

before :each do
@kcode = $KCODE
$KCODE = 'u'
end

after :each do
$KCODE = @kcode
end

it "falls back to ASCII for an invalid UTF-8 regexp" do
(Regexp.send(@method, /^([\x00-\x7F]|[\xC2-\xDF][\x80-\xBF])*$/) =~ "hellø").should == 0
end

end
end

ruby_version_is "1.9" do
Expand Down

0 comments on commit 5e5a1da

Please sign in to comment.