From 0ba66559d16da780c1ff35a7bcb7ffe600f87a53 Mon Sep 17 00:00:00 2001 From: Jared Luxenberg Date: Sat, 1 Mar 2008 16:20:18 -0500 Subject: [PATCH] Added specs for Marshal-ing a subclassed Hash object that takes a parameter in its initialization function. * Test that Marshal.dump gives correct output for such an object (this works already) * Test that Marshal.load is able to deal such an object (this does not work currently) --- spec/ruby/1.8/core/marshal/dump_spec.rb | 6 ++++++ .../ruby/1.8/core/marshal/fixtures/marshal_data.rb | 6 ++++++ spec/ruby/1.8/core/marshal/load_spec.rb | 10 ++++++++++ spec/ruby/1.8/core/process/setrlimit_spec.rb | 1 + 4 files changed, 23 insertions(+), 0 deletions(-) diff --git a/spec/ruby/1.8/core/marshal/dump_spec.rb b/spec/ruby/1.8/core/marshal/dump_spec.rb index d931ce7..b06266f 100644 --- a/spec/ruby/1.8/core/marshal/dump_spec.rb +++ b/spec/ruby/1.8/core/marshal/dump_spec.rb @@ -93,6 +93,12 @@ describe "Marshal.dump" do Marshal.dump(h).should == "#{mv+nv}e:\x0AMethsC:\x0DUserHash}\x06\"\x0Athreei\x08;\x00" end + it "dumps an extended_user_hash with a parameter to initialize" do + h = UserHashInitParams.new(:abc).extend(Meths) + h['three'] = 3 + Marshal.dump(h).should == "\004\bIe:\nMethsC:\027UserHashInitParams{\006\"\nthreei\b\006:\a@a:\babc" + end + it "dumps an array containing objects having _dump method" do o1 = UserDefined.new o2 = UserDefinedWithIvar.new diff --git a/spec/ruby/1.8/core/marshal/fixtures/marshal_data.rb b/spec/ruby/1.8/core/marshal/fixtures/marshal_data.rb index bd63eeb..d0a9e0b 100644 --- a/spec/ruby/1.8/core/marshal/fixtures/marshal_data.rb +++ b/spec/ruby/1.8/core/marshal/fixtures/marshal_data.rb @@ -107,6 +107,12 @@ end class UserHash < Hash end +class UserHashInitParams < Hash + def initialize(a) + @a = a + end +end + class UserObject end diff --git a/spec/ruby/1.8/core/marshal/load_spec.rb b/spec/ruby/1.8/core/marshal/load_spec.rb index 29fa0d8..72057be 100644 --- a/spec/ruby/1.8/core/marshal/load_spec.rb +++ b/spec/ruby/1.8/core/marshal/load_spec.rb @@ -17,6 +17,16 @@ describe "Marshal::load" do Marshal.load("\004\bI\"\ahi\006:\n@self@\000").should == obj end + it "loads an extended_user_hash with a parameter to initialize" do + obj = UserHashInitParams.new(:abc).extend(Meths) + + new_obj = Marshal.load "\004\bIe:\nMethsC:\027UserHashInitParams{\000\006:\a@a:\babc" + + new_obj.should == obj + new_obj_metaclass_ancestors = class << new_obj; ancestors; end + new_obj_metaclass_ancestors.first.should == UserHashInitParams + end + it "loads a user-marshaled extended object" do obj = UserMarshal.new.extend(Meths) diff --git a/spec/ruby/1.8/core/process/setrlimit_spec.rb b/spec/ruby/1.8/core/process/setrlimit_spec.rb index 7d94597..2a562c5 100644 --- a/spec/ruby/1.8/core/process/setrlimit_spec.rb +++ b/spec/ruby/1.8/core/process/setrlimit_spec.rb @@ -70,6 +70,7 @@ describe "Process.setrlimit and Process.getrlimit" do lim, max = Process.getrlimit(Process::RLIMIT_MEMLOCK) lim.kind_of?(Integer).should == true max.kind_of?(Integer).should == true + puts "RLIMIT_MEMLOCK: lim: #{lim} max: #{max}" Process.setrlimit(Process::RLIMIT_MEMLOCK, lim, max).should == nil end -- 1.5.2.5