summaryrefslogtreecommitdiff
path: root/spec/ruby/core
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core')
-rw-r--r--spec/ruby/core/marshal/dump_spec.rb4
-rw-r--r--spec/ruby/core/marshal/shared/load.rb2
-rw-r--r--spec/ruby/core/regexp/initialize_spec.rb12
-rw-r--r--spec/ruby/core/string/match_spec.rb2
4 files changed, 14 insertions, 6 deletions
diff --git a/spec/ruby/core/marshal/dump_spec.rb b/spec/ruby/core/marshal/dump_spec.rb
index fc78ca4ff9..ea021991a8 100644
--- a/spec/ruby/core/marshal/dump_spec.rb
+++ b/spec/ruby/core/marshal/dump_spec.rb
@@ -235,13 +235,13 @@ describe "Marshal.dump" do
end
it "dumps a Regexp with instance variables" do
- o = //
+ o = Regexp.new("")
o.instance_variable_set(:@ivar, :ivar)
Marshal.dump(o).should == "\x04\bI/\x00\x00\a:\x06EF:\n@ivar:\tivar"
end
it "dumps an extended Regexp" do
- Marshal.dump(//.extend(Meths)).should == "\x04\bIe:\nMeths/\x00\x00\x06:\x06EF"
+ Marshal.dump(Regexp.new("").extend(Meths)).should == "\x04\bIe:\nMeths/\x00\x00\x06:\x06EF"
end
it "dumps a Regexp subclass" do
diff --git a/spec/ruby/core/marshal/shared/load.rb b/spec/ruby/core/marshal/shared/load.rb
index 302d3d5bda..78fc9fb286 100644
--- a/spec/ruby/core/marshal/shared/load.rb
+++ b/spec/ruby/core/marshal/shared/load.rb
@@ -623,7 +623,7 @@ describe :marshal_load, shared: true do
describe "for a Regexp" do
it "loads an extended Regexp" do
- obj = /[a-z]/.extend(Meths, MethsMore)
+ obj = /[a-z]/.dup.extend(Meths, MethsMore)
new_obj = Marshal.send(@method, "\004\be:\nMethse:\016MethsMore/\n[a-z]\000")
new_obj.should == obj
diff --git a/spec/ruby/core/regexp/initialize_spec.rb b/spec/ruby/core/regexp/initialize_spec.rb
index 36fd5c7bf2..ae188fb9c2 100644
--- a/spec/ruby/core/regexp/initialize_spec.rb
+++ b/spec/ruby/core/regexp/initialize_spec.rb
@@ -5,8 +5,16 @@ describe "Regexp#initialize" do
Regexp.should have_private_method(:initialize)
end
- it "raises a SecurityError on a Regexp literal" do
- -> { //.send(:initialize, "") }.should raise_error(SecurityError)
+ ruby_version_is ""..."2.7" do
+ it "raises a SecurityError on a Regexp literal" do
+ -> { //.send(:initialize, "") }.should raise_error(SecurityError)
+ end
+ end
+
+ ruby_version_is "2.7" do
+ it "raises a FrozenError on a Regexp literal" do
+ -> { //.send(:initialize, "") }.should raise_error(FrozenError)
+ end
end
it "raises a TypeError on an initialized non-literal Regexp" do
diff --git a/spec/ruby/core/string/match_spec.rb b/spec/ruby/core/string/match_spec.rb
index 78b94baa44..5e988f34ca 100644
--- a/spec/ruby/core/string/match_spec.rb
+++ b/spec/ruby/core/string/match_spec.rb
@@ -137,7 +137,7 @@ describe "String#match" do
end
it "calls match on the regular expression" do
- regexp = /./
+ regexp = /./.dup
regexp.should_receive(:match).and_return(:foo)
'hello'.match(regexp).should == :foo
end