Sha256: 0508a6d74c21696b6bdcf4722781652f8b4c36099b059a5d90ca99fc09832c08

Contents?: true

Size: 1.06 KB

Versions: 18

Compression:

Stored size: 1.06 KB

Contents

#!/usr/bin/env ruby
# encoding: UTF-8

# Ubuntu does not accept arguments to ruby when called using env. To get
# warnings to show up the -w options is required. That can be set in the RUBYOPT
# environment variable.
# export RUBYOPT=-w

$VERBOSE = true

$: << File.join(File.dirname(__FILE__), "../lib")
$: << File.join(File.dirname(__FILE__), "../ext")

require 'test/unit'
require 'oj'

class Goo
  attr_accessor :x, :child

  def initialize(x, child)
    @x = x
    @child = child
  end
  
  def to_hash()
    { 'json_class' => "#{self.class}", 'x' => x, 'child' => child }
  end

  def self.json_create(h)
    GC.start
    self.new(h['x'], h['child'])
  end
end # Goo

class GCTest < ::Test::Unit::TestCase

  # if no crash then the GC marking is working
  def test_parse_compat_gc
    g = Goo.new(0, nil)
    100.times { |i| g = Goo.new(i, g) }
    json = Oj.dump(g, :mode => :compat)
    Oj.compat_load(json)
  end

  def test_parse_object_gc
    g = Goo.new(0, nil)
    100.times { |i| g = Goo.new(i, g) }
    json = Oj.dump(g, :mode => :object)
    Oj.object_load(json)
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
oj-2.9.4 test/test_gc.rb
oj-2.9.3 test/test_gc.rb
oj-2.9.2 test/test_gc.rb
oj-2.9.1 test/test_gc.rb
oj-2.9.0 test/test_gc.rb
oj-2.8.1 test/test_gc.rb
oj-2.8.0 test/test_gc.rb
oj-2.7.3 test/test_gc.rb
oj-2.7.2 test/test_gc.rb
oj-2.7.1 test/test_gc.rb
oj-2.7.0 test/test_gc.rb
oj-2.6.1 test/test_gc.rb
oj-2.6.0 test/test_gc.rb
oj-2.5.5 test/test_gc.rb
oj-2.2.3 test/test_gc.rb
oj-2.2.2 test/test_gc.rb
oj-2.2.1 test/test_gc.rb
oj-2.2.0 test/test_gc.rb