From f234d51eaba861edea925eabb564a0bee41b96a0 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 28 Mar 2020 00:22:51 +0100 Subject: Update to ruby/spec@ec84479 --- spec/ruby/language/regexp/encoding_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'spec/ruby/language/regexp/encoding_spec.rb') diff --git a/spec/ruby/language/regexp/encoding_spec.rb b/spec/ruby/language/regexp/encoding_spec.rb index b8559c6b27..2db09fdda8 100644 --- a/spec/ruby/language/regexp/encoding_spec.rb +++ b/spec/ruby/language/regexp/encoding_spec.rb @@ -116,4 +116,16 @@ describe "Regexps with encoding modifiers" do it "raises Encoding::CompatibilityError when trying =~ against different encodings" do -> { /\A[[:space:]]*\z/ =~ " ".encode("UTF-16LE") }.should raise_error(Encoding::CompatibilityError) end + + it "computes the Regexp Encoding for each interpolated Regexp instance" do + make_regexp = -> str { /#{str}/ } + + r = make_regexp.call("été".force_encoding(Encoding::UTF_8)) + r.fixed_encoding?.should == true + r.encoding.should == Encoding::UTF_8 + + r = make_regexp.call("abc".force_encoding(Encoding::UTF_8)) + r.fixed_encoding?.should == false + r.encoding.should == Encoding::US_ASCII + end end -- cgit v1.2.3