Sha256: c45c206aed4546736e8cbf24b91f71871af03e66df87316980550a10e4860259

Contents?: true

Size: 978 Bytes

Versions: 129

Compression:

Stored size: 978 Bytes

Contents

# encoding: UTF-8

require 'helper'

class DebJuice < Minitest::Test
  class Jam
    attr_accessor :x, :y

    def initialize(x, y)
      @x = x
      @y = y
    end

    def eql?(o)
      self.class == o.class && @x == o.x && @y == o.y
    end
    alias == eql?

  end# Jam

  # contributed by sauliusg to fix as_json
  class Orange < Jam
    def initialize(x, y)
      super
    end

    def as_json()
      { :json_class => self.class,
        :x => @x,
        :y => @y }
    end

    def self.json_create(h)
      self.new(h['x'], h['y'])
    end
  end

  def test_as_json_object_compat_hash_cached
    Oj.default_options = { :mode => :compat, :class_cache => true, :use_as_json => true }
    obj = Orange.new(true, 58)
    json = Oj.dump(obj, :indent => 2)
    assert(!json.nil?)
    dump_and_load(obj, true)
  end

  def dump_and_load(obj, trace=false)
    json = Oj.dump(obj, :indent => 2)
    loaded = Oj.load(json);
    assert_equal(obj, loaded)
    loaded
  end

end

Version data entries

129 entries across 129 versions & 3 rubygems

Version Path
oj-3.11.0 test/test_debian.rb
oj-3.10.18 test/test_debian.rb
oj-3.10.17 test/test_debian.rb
oj-3.10.16 test/test_debian.rb
oj-3.10.15 test/test_debian.rb
oj-3.10.14 test/test_debian.rb
oj-3.10.13 test/test_debian.rb
oj-3.10.12 test/test_debian.rb
oj-3.10.11 test/test_debian.rb
oj-3.10.10 test/test_debian.rb
oj-3.10.9 test/test_debian.rb
oj-3.10.8 test/test_debian.rb
oj-3.10.7 test/test_debian.rb
oj-3.10.6 test/test_debian.rb
oj-3.10.5 test/test_debian.rb
oj-3.10.3 test/test_debian.rb
oj-3.10.2 test/test_debian.rb
oj-3.10.1 test/test_debian.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/oj-3.10.0/test/test_debian.rb
oj-3.10.0 test/test_debian.rb