summaryrefslogtreecommitdiff
path: root/spec/ruby
diff options
context:
space:
mode:
authorJean Boussier <byroot@ruby-lang.org>2023-02-10 10:31:30 +0100
committerJean Boussier <jean.boussier@gmail.com>2023-02-13 17:08:21 +0100
commit7ddcee5928d8a98337077d5a5ee61136ec84a993 (patch)
tree638966b4af636eabcc137153b1a2be9ad433675e /spec/ruby
parentbc6e587e86a4a4a46af3b1c2fbe1ff3b399735a6 (diff)
Marshal.load: also freeze extended objects
[Bug #19427] The `proc` wouldn't be called either, that fixes both.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7284
Diffstat (limited to 'spec/ruby')
-rw-r--r--spec/ruby/core/marshal/shared/load.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/ruby/core/marshal/shared/load.rb b/spec/ruby/core/marshal/shared/load.rb
index 98fae44296..8fdfedd746 100644
--- a/spec/ruby/core/marshal/shared/load.rb
+++ b/spec/ruby/core/marshal/shared/load.rb
@@ -69,6 +69,18 @@ describe :marshal_load, shared: true do
Object.should_not.frozen?
end
+ ruby_bug "#19427", ""..."3.3" do
+ it "does freeze extended objects" do
+ object = Marshal.load("\x04\be:\x0FEnumerableo:\vObject\x00", freeze: true)
+ object.should.frozen?
+ end
+
+ it "does freeze extended objects with instance variables" do
+ object = Marshal.load("\x04\be:\x0FEnumerableo:\vObject\x06:\n@ivarT", freeze: true)
+ object.should.frozen?
+ end
+ end
+
describe "when called with a proc" do
it "call the proc with frozen objects" do
arr = []
@@ -132,6 +144,14 @@ describe :marshal_load, shared: true do
end
end
+ ruby_bug "#19427", ""..."3.3" do
+ it "call the proc with extended objects" do
+ objs = []
+ obj = Marshal.load("\x04\be:\x0FEnumerableo:\vObject\x00", Proc.new { |o| objs << o; o })
+ objs.should == [obj]
+ end
+ end
+
it "returns the value of the proc" do
Marshal.send(@method, Marshal.dump([1,2]), proc { [3,4] }).should == [3,4]
end