diff options
author | Benoit Daloze <[email protected]> | 2019-11-30 21:26:52 +0100 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2019-11-30 21:26:52 +0100 |
commit | 1243255c3a36433041012b6107a5ac48658a0895 (patch) | |
tree | 04440f84b48999ff08d4a2a16d066d0ad731400e /spec/ruby/language/regexp | |
parent | ab8345271eb87ff155d8bd5f22f53a4cf2902c26 (diff) |
Update to ruby/spec@4eec3dc
Diffstat (limited to 'spec/ruby/language/regexp')
-rw-r--r-- | spec/ruby/language/regexp/encoding_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/ruby/language/regexp/encoding_spec.rb b/spec/ruby/language/regexp/encoding_spec.rb index dce64a4753..b8559c6b27 100644 --- a/spec/ruby/language/regexp/encoding_spec.rb +++ b/spec/ruby/language/regexp/encoding_spec.rb @@ -42,6 +42,10 @@ describe "Regexps with encoding modifiers" do /./n.encoding.should == Encoding::US_ASCII end + it 'uses BINARY when is not initialized' do + Regexp.allocate.encoding.should == Encoding::BINARY + end + it 'uses BINARY as /n encoding if not all chars are 7-bit' do /\xFF/n.encoding.should == Encoding::BINARY end @@ -100,4 +104,16 @@ describe "Regexps with encoding modifiers" do it "selects last of multiple encoding specifiers" do /foo/ensuensuens.should == /foo/s end + + it "raises Encoding::CompatibilityError when trying match against different encodings" do + -> { /\A[[:space:]]*\z/.match(" ".encode("UTF-16LE")) }.should raise_error(Encoding::CompatibilityError) + end + + it "raises Encoding::CompatibilityError when trying match? against different encodings" do + -> { /\A[[:space:]]*\z/.match?(" ".encode("UTF-16LE")) }.should raise_error(Encoding::CompatibilityError) + end + + it "raises Encoding::CompatibilityError when trying =~ against different encodings" do + -> { /\A[[:space:]]*\z/ =~ " ".encode("UTF-16LE") }.should raise_error(Encoding::CompatibilityError) + end end |