test/test_object.rb in oj-3.13.19 vs test/test_object.rb in oj-3.13.20
- old
+ new
@@ -459,10 +459,12 @@
obj = Oj.object_load(json)
assert_equal({ 'x' => true, 'y' => 58, 'z' => [1, 2, 3]}, obj)
end
def test_json_module_object
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
obj = One::Two::Three::Deep.new()
dump_and_load(obj, false)
end
def test_xml_time
@@ -629,15 +631,19 @@
assert_equal(t.utc?, loaded.utc?)
assert_equal(t.utc_offset, loaded.utc_offset)
end
def test_json_object
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
obj = Jeez.new(true, 58)
dump_and_load(obj, false)
end
def test_json_object_create_deep
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
obj = One::Two::Three::Deep.new()
dump_and_load(obj, false)
end
def test_json_object_bad
@@ -670,10 +676,12 @@
obj = One::Stuck2.new(false, 7)
dump_and_load(obj, false)
end
def test_json_anonymous_struct
+ skip 'TruffleRuby fails this spec with `TypeError: allocator undefined for Class`' if RUBY_ENGINE == 'truffleruby'
+
s = Struct.new(:x, :y)
obj = s.new(1, 2)
json = Oj.dump(obj, :indent => 2, :mode => :object)
#puts json
loaded = Oj.object_load(json);
@@ -692,10 +700,12 @@
h = Oj.object_load(json)
assert_equal({ 1 => true, 'nil' => nil, :sim => 4 }, h)
end
def test_json_object_object
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
obj = Jeez.new(true, 58)
json = Oj.dump(obj, mode: :object, indent: 2, ignore_under: true)
assert(%{{
"^o":"ObjectJuice::Jeez",
"x":true,
@@ -711,10 +721,12 @@
obj2 = Oj.load(json, :mode => :object)
assert_equal(obj, obj2)
end
def test_to_hash_object_object
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
obj = Jazz.new(true, 58)
json = Oj.dump(obj, :mode => :object, :indent => 2)
assert(%{{
"^o":"ObjectJuice::Jazz",
"x":true,
@@ -730,10 +742,12 @@
obj2 = Oj.load(json, :mode => :object)
assert_equal(obj, obj2)
end
def test_as_json_object_object
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
obj = Orange.new(true, 58)
json = Oj.dump(obj, :mode => :object, :indent => 2)
assert(%{{
"^o":"ObjectJuice::Orange",
"x":true,
@@ -749,10 +763,12 @@
obj2 = Oj.load(json, :mode => :object)
assert_equal(obj, obj2)
end
def test_object_object_no_cache
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
obj = Jam.new(true, 58)
json = Oj.dump(obj, :mode => :object, :indent => 2)
assert(%{{
"^o":"ObjectJuice::Jam",
"x":true,
@@ -777,10 +793,12 @@
}
|, json)
end
def test_exception
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
err = nil
begin
raise StandardError.new('A Message')
rescue Exception => e
err = e
@@ -807,10 +825,12 @@
@xyz = 123
end
end
def test_exception_subclass
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
err = nil
begin
raise SubX.new
rescue Exception => e
err = e
@@ -828,10 +848,12 @@
def test_range_object
Oj.default_options = { :mode => :object }
json = Oj.dump(1..7, :mode => :object, :indent => 0)
if 'rubinius' == $ruby
assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
+ elsif 'truffleruby' == $ruby
+ assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
else
assert_equal(%{{"^u":["Range",1,7,false]}}, json)
end
dump_and_load(1..7, false)
dump_and_load(1..1, false)
@@ -893,18 +915,22 @@
Oj.load(json, :mode => :object, :circular => true)
assert_equal(h['b'].__id__, h.__id__)
end
def test_circular_object
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
obj = Jeez.new(nil, 58)
obj.x = obj
json = Oj.dump(obj, :mode => :object, :indent => 2, :circular => true)
obj2 = Oj.object_load(json, :circular => true)
assert_equal(obj2.x.__id__, obj2.__id__)
end
def test_circular_object2
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
obj = Jam.new(nil, 58)
obj.x = obj
json = Oj.dump(obj, :mode => :object, :indent => 2, :circular => true)
assert(%{{
"^o":"ObjectJuice::Jam",
@@ -923,20 +949,24 @@
obj2 = Oj.load(json, :mode => :object, :circular => true)
assert_equal(obj2.x.__id__, obj2.__id__)
end
def test_circular
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
h = { 'a' => 7 }
obj = Jeez.new(h, 58)
obj.x['b'] = obj
json = Oj.dump(obj, :mode => :object, :indent => 2, :circular => true)
Oj.object_load(json, :circular => true)
assert_equal(obj.x.__id__, h.__id__)
assert_equal(h['b'].__id__, obj.__id__)
end
def test_circular2
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
h = { 'a' => 7 }
obj = Jam.new(h, 58)
obj.x['b'] = obj
json = Oj.dump(obj, :mode => :object, :indent => 2, :circular => true)
ha = Oj.load(json, :mode => :strict)
@@ -945,10 +975,12 @@
assert_equal(obj.x.__id__, h.__id__)
assert_equal(h['b'].__id__, obj.__id__)
end
def test_omit_nil
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
jam = Jam.new({'a' => 1, 'b' => nil }, nil)
json = Oj.dump(jam, :omit_nil => true, :mode => :object)
assert_equal(%|{"^o":"ObjectJuice::Jam","x":{"a":1}}|, json)
end
@@ -999,19 +1031,25 @@
h = Oj.load(json, :mode => :object)
assert_equal({'a' => 1}, h)
end
def test_auto_string
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
s = AutoStrung.new("Pete", true)
dump_and_load(s, false)
end
def test_auto_array
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
a = AutoArray.new([1, 'abc', nil], true)
dump_and_load(a, false)
end
def test_auto_hash
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
+
h = AutoHash.new(nil, true)
h['a'] = 1
h['b'] = 2
dump_and_load(h, false)
end