Sha256: 87067afd3937b6898ef6d3d564d576d2239673616b31d9283001d5eb6808a29b

Contents?: true

Size: 629 Bytes

Versions: 4

Compression:

Stored size: 629 Bytes

Contents

# Run independently and with Ruby 1.9

def get_randomizer
  r = Random.new(42)
  1000.times{r.rand}
  r
end

def get_info(r)
  Hash[
    [:state, :left, :seed].map{|info| [info, r.send(info)]}
  ]
end

MRIs = get_randomizer
dump = Marshal.dump(MRIs)
Object.send :remove_const, :Random # Kill original definition

require_relative "../lib/backports/1.9.2"

ours = get_randomizer

puts "Info ok" if get_info(MRIs) == get_info(ours)
if dump == (our_dump = Marshal.dump(get_randomizer))
  puts "dump identical" 
else
  puts "Oups"
end
if get_info(MRIs) == get_info(Marshal.load(dump))
  puts "load identical" 
else
  puts "Oups"
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
backports-1.17.0 test/random_marshal_test.rb
backports-1.16.7 test/random_marshal_test.rb
backports-1.16.6 test/random_marshal_test.rb
backports-1.16.5 test/random_marshal_test.rb