Sha256: 1eb47c92fb283de90775ad21e56176008df58d49ce5929df168289c51e1ec9fc

Contents?: true

Size: 928 Bytes

Versions: 172

Compression:

Stored size: 928 Bytes

Contents

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

$: << File.dirname(__FILE__)

require 'helper'

class GCTest < Minitest::Test
  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

  def setup
    @default_options = Oj.default_options
  end

  def teardown
    Oj.default_options = @default_options
  end

  # 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

172 entries across 172 versions & 3 rubygems

Version Path
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/oj-3.13.2/test/test_gc.rb
oj-3.13.19 test/test_gc.rb
oj-3.13.18 test/test_gc.rb
oj-3.13.17 test/test_gc.rb
oj-3.13.16 test/test_gc.rb
oj-3.13.15 test/test_gc.rb
oj-3.13.14 test/test_gc.rb
oj-3.13.13 test/test_gc.rb
oj-3.13.12 test/test_gc.rb
oj-3.13.11 test/test_gc.rb
oj-3.13.10 test/test_gc.rb
oj-3.13.9 test/test_gc.rb
oj-3.13.8 test/test_gc.rb
oj-3.13.7 test/test_gc.rb
oj-3.13.6 test/test_gc.rb
oj-3.13.5 test/test_gc.rb
oj-3.13.4 test/test_gc.rb
oj-3.13.3 test/test_gc.rb
oj-3.13.2 test/test_gc.rb
oj-3.13.1 test/test_gc.rb