Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions ext/psych/psych_to_ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ static VALUE path2class(VALUE self, VALUE path)
return rb_path_to_class(path);
}

static VALUE init_data(VALUE self, VALUE data, VALUE values)
{
rb_struct_initialize(data, values);
return data;
}

void Init_psych_to_ruby(void)
{
VALUE psych = rb_define_module("Psych");
Expand All @@ -43,7 +37,6 @@ void Init_psych_to_ruby(void)
VALUE visitor = rb_define_class_under(visitors, "Visitor", rb_cObject);
cPsychVisitorsToRuby = rb_define_class_under(visitors, "ToRuby", visitor);

rb_define_private_method(cPsychVisitorsToRuby, "init_data", init_data, 2);
rb_define_private_method(cPsychVisitorsToRuby, "build_exception", build_exception, 2);
rb_define_private_method(class_loader, "path2class", path2class, 1);
}
34 changes: 7 additions & 27 deletions lib/psych/visitors/to_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,32 +197,11 @@ def visit_Psych_Nodes_Mapping o
s
end

when /^!ruby\/data(-with-ivars)?(?::(.*))?$/
data = register(o, resolve_class($2).allocate) if $2
members = {}

if $1 # data-with-ivars
ivars = {}
o.children.each_slice(2) do |type, vars|
case accept(type)
when 'members'
revive_data_members(members, vars)
data ||= allocate_anon_data(o, members)
when 'ivars'
revive_hash(ivars, vars)
end
end
ivars.each do |ivar, v|
data.instance_variable_set ivar, v
end
else
revive_data_members(members, o)
end
data ||= allocate_anon_data(o, members)
values = data.members.map { |m| members[m] }
init_data(data, values)
data.freeze
data
when /^!ruby\/data?(?::(.*))?$/
data_class = resolve_class($1) if $1
members = revive_data_members(o)
data = (data_class || Data.define(*members.keys)).new(**members)
register(o, data) # replace temp with actual

when /^!ruby\/object:?(.*)?$/
name = $1 || 'Object'
Expand Down Expand Up @@ -372,7 +351,8 @@ def allocate_anon_data node, members
register(node, klass.allocate)
end

def revive_data_members hash, o
def revive_data_members o
hash = {}
o.children.each_slice(2) do |k,v|
name = accept(k)
value = accept(v)
Expand Down
41 changes: 8 additions & 33 deletions lib/psych/visitors/yaml_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,41 +163,16 @@ def visit_Object o
alias :visit_Delegator :visit_Object

def visit_Data o
ivars = o.instance_variables
if ivars.empty?
tag = ['!ruby/data', o.class.name].compact.join(':')
register o, @emitter.start_mapping(nil, tag, false, Nodes::Mapping::BLOCK)
o.members.each do |member|
@emitter.scalar member.to_s, nil, nil, true, false, Nodes::Scalar::ANY
accept o.send member
end
@emitter.end_mapping
raise TypeError, "can't dump Data with ivars: #{o}" unless o.instance_variables.empty?
raise TypeError, "can't dump anonymous Data: #{o}" unless o.class.name

else
tag = ['!ruby/data-with-ivars', o.class.name].compact.join(':')
node = @emitter.start_mapping(nil, tag, false, Psych::Nodes::Mapping::BLOCK)
register(o, node)

# Dump the members
accept 'members'
@emitter.start_mapping nil, nil, true, Nodes::Mapping::BLOCK
o.members.each do |member|
@emitter.scalar member.to_s, nil, nil, true, false, Nodes::Scalar::ANY
accept o.send member
end
@emitter.end_mapping

# Dump the ivars
accept 'ivars'
@emitter.start_mapping nil, nil, true, Nodes::Mapping::BLOCK
ivars.each do |ivar|
accept ivar.to_s
accept o.instance_variable_get ivar
end
@emitter.end_mapping

@emitter.end_mapping
tag = ['!ruby/data', o.class.name].compact.join(':')
register o, @emitter.start_mapping(nil, tag, false, Nodes::Mapping::BLOCK)
o.members.each do |member|
@emitter.scalar member.to_s, nil, nil, true, false, Nodes::Scalar::ANY
accept o.send member
end
@emitter.end_mapping
end unless RUBY_VERSION < "3.2"

def visit_Struct o
Expand Down
6 changes: 3 additions & 3 deletions test/psych/test_coder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@
end

def test_coder_style_map_any
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

foo = Psych.dump CustomEncode.new \

Check failure on line 225 in test/psych/test_coder.rb

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, jruby-head)

Error

RuntimeError: org.snakeyaml.engine.v2.exceptions.EmitterException: tag is not specified org/jruby/ext/psych/PsychEmitter.java:219:in 'scalar' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:32:in 'visit_Psych_Nodes_Scalar' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:43:in 'block in visit_Psych_Nodes_Mapping' org/jruby/RubyArray.java:2093:in 'each' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:43:in 'visit_Psych_Nodes_Mapping' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:27:in 'block in visit_Psych_Nodes_Document' org/jruby/RubyArray.java:2093:in 'each' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:27:in 'visit_Psych_Nodes_Document' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:21:in 'block in visit_Psych_Nodes_Stream' org/jruby/RubyArray.java:2093:in 'each' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:21:in 'visit_Psych_Nodes_Stream' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /home/runner/work/psych/psych/lib/psych/nodes/node.rb:62:in 'yaml' /home/runner/work/psych/psych/lib/psych.rb:523:in 'dump' /home/runner/work/psych/psych/test/psych/test_coder.rb:225:in 'test_coder_style_map_any' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch'

Check failure on line 225 in test/psych/test_coder.rb

View workflow job for this annotation

GitHub Actions / test (macos-latest, jruby-head)

Error

RuntimeError: org.snakeyaml.engine.v2.exceptions.EmitterException: tag is not specified org/jruby/ext/psych/PsychEmitter.java:219:in 'scalar' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:32:in 'visit_Psych_Nodes_Scalar' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:43:in 'block in visit_Psych_Nodes_Mapping' org/jruby/RubyArray.java:2093:in 'each' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:43:in 'visit_Psych_Nodes_Mapping' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:27:in 'block in visit_Psych_Nodes_Document' org/jruby/RubyArray.java:2093:in 'each' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:27:in 'visit_Psych_Nodes_Document' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:21:in 'block in visit_Psych_Nodes_Stream' org/jruby/RubyArray.java:2093:in 'each' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:21:in 'visit_Psych_Nodes_Stream' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /Users/runner/work/psych/psych/lib/psych/nodes/node.rb:62:in 'yaml' /Users/runner/work/psych/psych/lib/psych.rb:523:in 'dump' /Users/runner/work/psych/psych/test/psych/test_coder.rb:225:in 'test_coder_style_map_any' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch'
map: {a: 1, b: 2},
style: Psych::Nodes::Mapping::ANY,
tag: nil
Expand All @@ -230,9 +230,9 @@
end

def test_coder_style_map_block
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

foo = Psych.dump CustomEncode.new \

Check failure on line 235 in test/psych/test_coder.rb

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, jruby-head)

Error

RuntimeError: org.snakeyaml.engine.v2.exceptions.EmitterException: tag is not specified org/jruby/ext/psych/PsychEmitter.java:219:in 'scalar' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:32:in 'visit_Psych_Nodes_Scalar' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:43:in 'block in visit_Psych_Nodes_Mapping' org/jruby/RubyArray.java:2093:in 'each' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:43:in 'visit_Psych_Nodes_Mapping' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:27:in 'block in visit_Psych_Nodes_Document' org/jruby/RubyArray.java:2093:in 'each' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:27:in 'visit_Psych_Nodes_Document' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:21:in 'block in visit_Psych_Nodes_Stream' org/jruby/RubyArray.java:2093:in 'each' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:21:in 'visit_Psych_Nodes_Stream' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /home/runner/work/psych/psych/lib/psych/nodes/node.rb:62:in 'yaml' /home/runner/work/psych/psych/lib/psych.rb:523:in 'dump' /home/runner/work/psych/psych/test/psych/test_coder.rb:235:in 'test_coder_style_map_block' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch'

Check failure on line 235 in test/psych/test_coder.rb

View workflow job for this annotation

GitHub Actions / test (macos-latest, jruby-head)

Error

RuntimeError: org.snakeyaml.engine.v2.exceptions.EmitterException: tag is not specified org/jruby/ext/psych/PsychEmitter.java:219:in 'scalar' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:32:in 'visit_Psych_Nodes_Scalar' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:43:in 'block in visit_Psych_Nodes_Mapping' org/jruby/RubyArray.java:2093:in 'each' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:43:in 'visit_Psych_Nodes_Mapping' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:27:in 'block in visit_Psych_Nodes_Document' org/jruby/RubyArray.java:2093:in 'each' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:27:in 'visit_Psych_Nodes_Document' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:21:in 'block in visit_Psych_Nodes_Stream' org/jruby/RubyArray.java:2093:in 'each' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:21:in 'visit_Psych_Nodes_Stream' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /Users/runner/work/psych/psych/lib/psych/nodes/node.rb:62:in 'yaml' /Users/runner/work/psych/psych/lib/psych.rb:523:in 'dump' /Users/runner/work/psych/psych/test/psych/test_coder.rb:235:in 'test_coder_style_map_block' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch'
map: {a: 1, b: 2},
style: Psych::Nodes::Mapping::BLOCK,
tag: nil
Expand All @@ -240,9 +240,9 @@
end

def test_coder_style_map_flow
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

foo = Psych.dump CustomEncode.new \

Check failure on line 245 in test/psych/test_coder.rb

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, jruby-head)

Error

RuntimeError: org.snakeyaml.engine.v2.exceptions.EmitterException: tag is not specified org/jruby/ext/psych/PsychEmitter.java:219:in 'scalar' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:32:in 'visit_Psych_Nodes_Scalar' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:43:in 'block in visit_Psych_Nodes_Mapping' org/jruby/RubyArray.java:2093:in 'each' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:43:in 'visit_Psych_Nodes_Mapping' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:27:in 'block in visit_Psych_Nodes_Document' org/jruby/RubyArray.java:2093:in 'each' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:27:in 'visit_Psych_Nodes_Document' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:21:in 'block in visit_Psych_Nodes_Stream' org/jruby/RubyArray.java:2093:in 'each' /home/runner/work/psych/psych/lib/psych/visitors/emitter.rb:21:in 'visit_Psych_Nodes_Stream' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /home/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /home/runner/work/psych/psych/lib/psych/nodes/node.rb:62:in 'yaml' /home/runner/work/psych/psych/lib/psych.rb:523:in 'dump' /home/runner/work/psych/psych/test/psych/test_coder.rb:245:in 'test_coder_style_map_flow' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch'

Check failure on line 245 in test/psych/test_coder.rb

View workflow job for this annotation

GitHub Actions / test (macos-latest, jruby-head)

Error

RuntimeError: org.snakeyaml.engine.v2.exceptions.EmitterException: tag is not specified org/jruby/ext/psych/PsychEmitter.java:219:in 'scalar' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:32:in 'visit_Psych_Nodes_Scalar' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:43:in 'block in visit_Psych_Nodes_Mapping' org/jruby/RubyArray.java:2093:in 'each' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:43:in 'visit_Psych_Nodes_Mapping' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:27:in 'block in visit_Psych_Nodes_Document' org/jruby/RubyArray.java:2093:in 'each' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:27:in 'visit_Psych_Nodes_Document' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:21:in 'block in visit_Psych_Nodes_Stream' org/jruby/RubyArray.java:2093:in 'each' /Users/runner/work/psych/psych/lib/psych/visitors/emitter.rb:21:in 'visit_Psych_Nodes_Stream' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:30:in 'visit' /Users/runner/work/psych/psych/lib/psych/visitors/visitor.rb:6:in 'accept' /Users/runner/work/psych/psych/lib/psych/nodes/node.rb:62:in 'yaml' /Users/runner/work/psych/psych/lib/psych.rb:523:in 'dump' /Users/runner/work/psych/psych/test/psych/test_coder.rb:245:in 'test_coder_style_map_flow' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch'
map: { a: 1, b: 2 },
style: Psych::Nodes::Mapping::FLOW,
tag: nil
Expand Down
46 changes: 7 additions & 39 deletions test/psych/test_data.rb
Original file line number Diff line number Diff line change
@@ -1,67 +1,35 @@
# frozen_string_literal: true
require_relative 'helper'

class PsychDataWithIvar < Data.define(:foo)
attr_reader :bar
def initialize(**)
@bar = 'hello'
super
end
end unless RUBY_VERSION < "3.2"
PsychData = Data.define(:foo) unless RUBY_VERSION < "3.2"

module Psych
class TestData < TestCase
class SelfReferentialData < Data.define(:foo)
attr_accessor :ref
def initialize(foo:)
@ref = self
super
end
end unless RUBY_VERSION < "3.2"

def setup
omit "Data requires ruby >= 3.2" if RUBY_VERSION < "3.2"
end

# TODO: move to another test?
def test_dump_data
assert_equal <<~eoyml, Psych.dump(PsychDataWithIvar["bar"])
--- !ruby/data-with-ivars:PsychDataWithIvar
members:
foo: bar
ivars:
"@bar": hello
assert_equal <<~eoyml, Psych.dump(PsychData["bar"])
--- !ruby/data:PsychData
foo: bar
eoyml
end

def test_self_referential_data
circular = SelfReferentialData.new("foo")

loaded = Psych.unsafe_load(Psych.dump(circular))
assert_instance_of(SelfReferentialData, loaded.ref)

assert_equal(circular, loaded)
assert_same(loaded, loaded.ref)
end

def test_roundtrip
thing = PsychDataWithIvar.new("bar")
thing = PsychData.new("bar")
data = Psych.unsafe_load(Psych.dump(thing))

assert_equal "hello", data.bar
assert_equal "bar", data.foo
end

def test_load
obj = Psych.unsafe_load(<<~eoyml)
--- !ruby/data-with-ivars:PsychDataWithIvar
members:
foo: bar
ivars:
"@bar": hello
--- !ruby/data:PsychData
foo: bar
eoyml

assert_equal "hello", obj.bar
assert_equal "bar", obj.foo
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/psych/test_date_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_alias_with_time
end

def test_overwritten_to_s
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
s = Psych.dump(Date.new(2023, 9, 2), permitted_classes: [Date])
assert_separately(%W[-rpsych -rdate - #{s}], "#{<<~"begin;"}\n#{<<~'end;'}")
class Date
Expand Down
10 changes: 5 additions & 5 deletions test/psych/test_encoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
end

def test_emit_alias
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

@emitter.start_stream Psych::Parser::UTF8
@emitter.start_document [], [], true
Expand Down Expand Up @@ -153,9 +153,9 @@
@emitter.end_mapping
@emitter.end_document false
@emitter.end_stream
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

@parser.parse @buffer.string

Check failure on line 158 in test/psych/test_encoding.rb

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, jruby-head)

Error

Psych::SyntaxError: (<unknown>): expected URI, but found �(65533) while scanning a tag at line 1 column 8 org/jruby/ext/psych/PsychParser.java:308:in '_native_parse' /home/runner/work/psych/psych/lib/psych/parser.rb:62:in 'parse' /home/runner/work/psych/psych/test/psych/test_encoding.rb:158:in 'test_start_mapping' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch'

Check failure on line 158 in test/psych/test_encoding.rb

View workflow job for this annotation

GitHub Actions / test (macos-latest, jruby-head)

Error

Psych::SyntaxError: (<unknown>): expected URI, but found �(65533) while scanning a tag at line 1 column 8 org/jruby/ext/psych/PsychParser.java:308:in '_native_parse' /Users/runner/work/psych/psych/lib/psych/parser.rb:62:in 'parse' /Users/runner/work/psych/psych/test/psych/test_encoding.rb:158:in 'test_start_mapping' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch'
assert_encodings @utf8, @handler.strings
assert_equal [foo, bar], @handler.strings
end
Expand All @@ -173,9 +173,9 @@
@emitter.end_sequence
@emitter.end_document false
@emitter.end_stream
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

@parser.parse @buffer.string

Check failure on line 178 in test/psych/test_encoding.rb

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, jruby-head)

Error

Psych::SyntaxError: (<unknown>): expected URI, but found �(65533) while scanning a tag at line 1 column 8 org/jruby/ext/psych/PsychParser.java:308:in '_native_parse' /home/runner/work/psych/psych/lib/psych/parser.rb:62:in 'parse' /home/runner/work/psych/psych/test/psych/test_encoding.rb:178:in 'test_start_sequence' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch'

Check failure on line 178 in test/psych/test_encoding.rb

View workflow job for this annotation

GitHub Actions / test (macos-latest, jruby-head)

Error

Psych::SyntaxError: (<unknown>): expected URI, but found �(65533) while scanning a tag at line 1 column 8 org/jruby/ext/psych/PsychParser.java:308:in '_native_parse' /Users/runner/work/psych/psych/lib/psych/parser.rb:62:in 'parse' /Users/runner/work/psych/psych/test/psych/test_encoding.rb:178:in 'test_start_sequence' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch'
assert_encodings @utf8, @handler.strings
assert_equal [foo, bar], @handler.strings
end
Expand All @@ -191,9 +191,9 @@
@emitter.scalar 'foo', nil, nil, true, false, Nodes::Scalar::ANY
@emitter.end_document false
@emitter.end_stream
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

@parser.parse @buffer.string

Check failure on line 196 in test/psych/test_encoding.rb

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, jruby-head)

Error

Psych::SyntaxError: (<unknown>): expected URI, but found 鍵(37749) while scanning a directive at line 2 column 8 org/jruby/ext/psych/PsychParser.java:308:in '_native_parse' /home/runner/work/psych/psych/lib/psych/parser.rb:62:in 'parse' /home/runner/work/psych/psych/test/psych/test_encoding.rb:196:in 'test_doc_tag_encoding' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch'

Check failure on line 196 in test/psych/test_encoding.rb

View workflow job for this annotation

GitHub Actions / test (macos-latest, jruby-head)

Error

Psych::SyntaxError: (<unknown>): expected URI, but found 鍵(37749) while scanning a directive at line 2 column 8 org/jruby/ext/psych/PsychParser.java:308:in '_native_parse' /Users/runner/work/psych/psych/lib/psych/parser.rb:62:in 'parse' /Users/runner/work/psych/psych/test/psych/test_encoding.rb:196:in 'test_doc_tag_encoding' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyArray.java:2093:in 'each' org/jruby/RubyKernel.java:1407:in 'catch' org/jruby/RubyKernel.java:1402:in 'catch'
assert_encodings @utf8, @handler.strings
assert_equal key, @handler.strings[1]
end
Expand Down Expand Up @@ -268,7 +268,7 @@
end

def test_dump_non_ascii_string_to_file
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

Tempfile.create(['utf8', 'yml'], :encoding => 'UTF-8') do |t|
h = {'one' => 'いち'}
Expand Down
5 changes: 0 additions & 5 deletions test/psych/test_object_references.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ def test_struct_has_references
assert_reference_trip Struct.new(:foo).new(1)
end

def test_data_has_references
omit "Data requires ruby >= 3.2" if RUBY_VERSION < "3.2"
assert_reference_trip Data.define(:foo).new(1)
end

def assert_reference_trip obj
yml = Psych.dump([obj, obj])
assert_match(/\*-?\d+/, yml)
Expand Down
8 changes: 4 additions & 4 deletions test/psych/test_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@

def test_line_numbers
assert_equal 0, @parser.mark.line
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

@parser.parse "---\n- hello\n- world"
line_calls = @handler.marks.map(&:line).zip(@handler.calls.map(&:first))
assert_equal [

Check failure on line 92 in test/psych/test_parser.rb

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, jruby-head)

Failure

<[[0, :event_location], [0, :start_stream], [0, :event_location], [0, :start_document], [1, :event_location], [1, :start_sequence], [2, :event_location], [2, :scalar], [3, :event_location], [3, :scalar], [3, :event_location], [3, :end_sequence], [3, :event_location], [3, :end_document], [3, :event_location], [3, :end_stream]]> expected but was <[[0, :event_location], [0, :start_stream], [1, :event_location], [1, :start_document], [1, :event_location], [1, :start_sequence], [2, :event_location], [2, :scalar], [2, :event_location], [2, :scalar], [2, :event_location], [2, :end_sequence], [2, :event_location], [2, :end_document], [2, :event_location], [2, :end_stream]]>. diff: [[0, :event_location], [0, :start_stream], - [0, :event_location], ? ^ + [1, :event_location], ? ^ - [0, :start_document], ? ^ + [1, :start_document], ? ^ [1, :event_location], [1, :start_sequence], [2, :event_location], [2, :scalar], - [3, :event_location], ? ^ + [2, :event_location], ? ^ - [3, :scalar], ? ^ + [2, :scalar], ? ^ - [3, :event_location], ? ^ + [2, :event_location], ? ^ - [3, :end_sequence], ? ^ + [2, :end_sequence], ? ^ - [3, :event_location], ? ^ + [2, :event_location], ? ^ - [3, :end_document], ? ^ + [2, :end_document], ? ^ - [3, :event_location], ? ^ + [2, :event_location], ? ^ - [3, :end_stream]] ? ^ + [2, :end_stream]] ? ^

Check failure on line 92 in test/psych/test_parser.rb

View workflow job for this annotation

GitHub Actions / test (macos-latest, jruby-head)

Failure

<[[0, :event_location], [0, :start_stream], [0, :event_location], [0, :start_document], [1, :event_location], [1, :start_sequence], [2, :event_location], [2, :scalar], [3, :event_location], [3, :scalar], [3, :event_location], [3, :end_sequence], [3, :event_location], [3, :end_document], [3, :event_location], [3, :end_stream]]> expected but was <[[0, :event_location], [0, :start_stream], [1, :event_location], [1, :start_document], [1, :event_location], [1, :start_sequence], [2, :event_location], [2, :scalar], [2, :event_location], [2, :scalar], [2, :event_location], [2, :end_sequence], [2, :event_location], [2, :end_document], [2, :event_location], [2, :end_stream]]>. diff: [[0, :event_location], [0, :start_stream], - [0, :event_location], ? ^ + [1, :event_location], ? ^ - [0, :start_document], ? ^ + [1, :start_document], ? ^ [1, :event_location], [1, :start_sequence], [2, :event_location], [2, :scalar], - [3, :event_location], ? ^ + [2, :event_location], ? ^ - [3, :scalar], ? ^ + [2, :scalar], ? ^ - [3, :event_location], ? ^ + [2, :event_location], ? ^ - [3, :end_sequence], ? ^ + [2, :end_sequence], ? ^ - [3, :event_location], ? ^ + [2, :event_location], ? ^ - [3, :end_document], ? ^ + [2, :end_document], ? ^ - [3, :event_location], ? ^ + [2, :event_location], ? ^ - [3, :end_stream]] ? ^ + [2, :end_stream]] ? ^
[0, :event_location],
[0, :start_stream],
[0, :event_location],
Expand All @@ -112,11 +112,11 @@

def test_column_numbers
assert_equal 0, @parser.mark.column
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

@parser.parse "---\n- hello\n- world"
col_calls = @handler.marks.map(&:column).zip(@handler.calls.map(&:first))
assert_equal [

Check failure on line 119 in test/psych/test_parser.rb

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, jruby-head)

Failure

<[[0, :event_location], [0, :start_stream], [3, :event_location], [3, :start_document], [1, :event_location], [1, :start_sequence], [0, :event_location], [0, :scalar], [0, :event_location], [0, :scalar], [0, :event_location], [0, :end_sequence], [0, :event_location], [0, :end_document], [0, :event_location], [0, :end_stream]]> expected but was <[[0, :event_location], [0, :start_stream], [0, :event_location], [0, :start_document], [2, :event_location], [2, :start_sequence], [2, :event_location], [2, :scalar], [7, :event_location], [7, :scalar], [7, :event_location], [7, :end_sequence], [7, :event_location], [7, :end_document], [7, :event_location], [7, :end_stream]]>. diff: [[0, :event_location], [0, :start_stream], - [3, :event_location], - [3, :start_document], - [1, :event_location], - [1, :start_sequence], [0, :event_location], - [0, :scalar], + [0, :start_document], - [0, :event_location], ? ^ + [2, :event_location], ? ^ - [0, :scalar], + [2, :start_sequence], - [0, :event_location], ? ^ + [2, :event_location], ? ^ - [0, :end_sequence], + [2, :scalar], - [0, :event_location], ? ^ + [7, :event_location], ? ^ - [0, :end_document], + [7, :scalar], - [0, :event_location], ? ^ + [7, :event_location], ? ^ + [7, :end_sequence], + [7, :event_location], + [7, :end_document], + [7, :event_location], - [0, :end_stream]] ? ^ + [7, :end_stream]] ? ^

Check failure on line 119 in test/psych/test_parser.rb

View workflow job for this annotation

GitHub Actions / test (macos-latest, jruby-head)

Failure

<[[0, :event_location], [0, :start_stream], [3, :event_location], [3, :start_document], [1, :event_location], [1, :start_sequence], [0, :event_location], [0, :scalar], [0, :event_location], [0, :scalar], [0, :event_location], [0, :end_sequence], [0, :event_location], [0, :end_document], [0, :event_location], [0, :end_stream]]> expected but was <[[0, :event_location], [0, :start_stream], [0, :event_location], [0, :start_document], [2, :event_location], [2, :start_sequence], [2, :event_location], [2, :scalar], [7, :event_location], [7, :scalar], [7, :event_location], [7, :end_sequence], [7, :event_location], [7, :end_document], [7, :event_location], [7, :end_stream]]>. diff: [[0, :event_location], [0, :start_stream], - [3, :event_location], - [3, :start_document], - [1, :event_location], - [1, :start_sequence], [0, :event_location], - [0, :scalar], + [0, :start_document], - [0, :event_location], ? ^ + [2, :event_location], ? ^ - [0, :scalar], + [2, :start_sequence], - [0, :event_location], ? ^ + [2, :event_location], ? ^ - [0, :end_sequence], + [2, :scalar], - [0, :event_location], ? ^ + [7, :event_location], ? ^ - [0, :end_document], + [7, :scalar], - [0, :event_location], ? ^ + [7, :event_location], ? ^ + [7, :end_sequence], + [7, :event_location], + [7, :end_document], + [7, :event_location], - [0, :end_stream]] ? ^ + [7, :end_stream]] ? ^
[0, :event_location],
[0, :start_stream],
[3, :event_location],
Expand All @@ -139,11 +139,11 @@

def test_index_numbers
assert_equal 0, @parser.mark.index
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

@parser.parse "---\n- hello\n- world"
idx_calls = @handler.marks.map(&:index).zip(@handler.calls.map(&:first))
assert_equal [

Check failure on line 146 in test/psych/test_parser.rb

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, jruby-head)

Failure

<[[0, :event_location], [0, :start_stream], [3, :event_location], [3, :start_document], [5, :event_location], [5, :start_sequence], [12, :event_location], [12, :scalar], [19, :event_location], [19, :scalar], [19, :event_location], [19, :end_sequence], [19, :event_location], [19, :end_document], [19, :event_location], [19, :end_stream]]> expected but was <[[0, :event_location], [0, :start_stream], [0, :event_location], [0, :start_document], [0, :event_location], [0, :start_sequence], [0, :event_location], [0, :scalar], [0, :event_location], [0, :scalar], [0, :event_location], [0, :end_sequence], [0, :event_location], [0, :end_document], [0, :event_location], [0, :end_stream]]>. diff: [[0, :event_location], [0, :start_stream], - [3, :event_location], ? ^ + [0, :event_location], ? ^ - [3, :start_document], ? ^ + [0, :start_document], ? ^ - [5, :event_location], ? ^ + [0, :event_location], ? ^ - [5, :start_sequence], ? ^ + [0, :start_sequence], ? ^ - [12, :event_location], ? ^^ + [0, :event_location], ? ^ - [12, :scalar], ? ^^ + [0, :scalar], ? ^ - [19, :event_location], ? ^^ + [0, :event_location], ? ^ - [19, :scalar], ? ^^ + [0, :scalar], ? ^ - [19, :event_location], ? ^^ + [0, :event_location], ? ^ - [19, :end_sequence], ? ^^ + [0, :end_sequence], ? ^ - [19, :event_location], ? ^^ + [0, :event_location], ? ^ - [19, :end_document], ? ^^ + [0, :end_document], ? ^ - [19, :event_location], ? ^^ + [0, :event_location], ? ^ - [19, :end_stream]] ? ^^ + [0, :end_stream]] ? ^

Check failure on line 146 in test/psych/test_parser.rb

View workflow job for this annotation

GitHub Actions / test (macos-latest, jruby-head)

Failure

<[[0, :event_location], [0, :start_stream], [3, :event_location], [3, :start_document], [5, :event_location], [5, :start_sequence], [12, :event_location], [12, :scalar], [19, :event_location], [19, :scalar], [19, :event_location], [19, :end_sequence], [19, :event_location], [19, :end_document], [19, :event_location], [19, :end_stream]]> expected but was <[[0, :event_location], [0, :start_stream], [0, :event_location], [0, :start_document], [0, :event_location], [0, :start_sequence], [0, :event_location], [0, :scalar], [0, :event_location], [0, :scalar], [0, :event_location], [0, :end_sequence], [0, :event_location], [0, :end_document], [0, :event_location], [0, :end_stream]]>. diff: [[0, :event_location], [0, :start_stream], - [3, :event_location], ? ^ + [0, :event_location], ? ^ - [3, :start_document], ? ^ + [0, :start_document], ? ^ - [5, :event_location], ? ^ + [0, :event_location], ? ^ - [5, :start_sequence], ? ^ + [0, :start_sequence], ? ^ - [12, :event_location], ? ^^ + [0, :event_location], ? ^ - [12, :scalar], ? ^^ + [0, :scalar], ? ^ - [19, :event_location], ? ^^ + [0, :event_location], ? ^ - [19, :scalar], ? ^^ + [0, :scalar], ? ^ - [19, :event_location], ? ^^ + [0, :event_location], ? ^ - [19, :end_sequence], ? ^^ + [0, :end_sequence], ? ^ - [19, :event_location], ? ^^ + [0, :event_location], ? ^ - [19, :end_document], ? ^^ + [0, :end_document], ? ^ - [19, :event_location], ? ^^ + [0, :event_location], ? ^ - [19, :end_stream]] ? ^^ + [0, :end_stream]] ? ^
[0, :event_location],
[0, :start_stream],
[3, :event_location],
Expand Down Expand Up @@ -358,7 +358,7 @@
end

def test_event_location
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

@parser.parse "foo:\n" \
" barbaz: [1, 2]"
Expand All @@ -367,7 +367,7 @@
[event[0], location[1]]
end

assert_equal [

Check failure on line 370 in test/psych/test_parser.rb

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, jruby-head)

Failure

<[[:start_stream, [0, 0, 0, 0]], [:start_document, [0, 0, 0, 0]], [:start_mapping, [0, 0, 0, 0]], [:scalar, [0, 0, 0, 3]], [:start_mapping, [1, 2, 1, 2]], [:scalar, [1, 2, 1, 8]], [:start_sequence, [1, 10, 1, 11]], [:scalar, [1, 11, 1, 12]], [:scalar, [1, 14, 1, 15]], [:end_sequence, [1, 15, 1, 16]], [:end_mapping, [2, 0, 2, 0]], [:end_mapping, [2, 0, 2, 0]], [:end_document, [2, 0, 2, 0]], [:end_stream, [2, 0, 2, 0]]]> expected but was <[[:start_stream, [0, 0, 0, 0]], [:start_document, [0, 0, 0, 0]], [:start_mapping, [0, 0, 0, 0]], [:scalar, [0, 0, 0, 3]], [:start_mapping, [1, 2, 1, 2]], [:scalar, [1, 2, 1, 8]], [:start_sequence, [1, 10, 1, 11]], [:scalar, [1, 11, 1, 12]], [:scalar, [1, 14, 1, 15]], [:end_sequence, [1, 15, 1, 16]], [:end_mapping, [1, 16, 1, 16]], [:end_mapping, [1, 16, 1, 16]], [:end_document, [1, 16, 1, 16]], [:end_stream, [1, 16, 1, 16]]]>. diff: [[:start_stream, [0, 0, 0, 0]], [:start_document, [0, 0, 0, 0]], [:start_mapping, [0, 0, 0, 0]], [:scalar, [0, 0, 0, 3]], [:start_mapping, [1, 2, 1, 2]], [:scalar, [1, 2, 1, 8]], [:start_sequence, [1, 10, 1, 11]], [:scalar, [1, 11, 1, 12]], [:scalar, [1, 14, 1, 15]], [:end_sequence, [1, 15, 1, 16]], - [:end_mapping, [2, 0, 2, 0]], ? ^ ^ ^ ^ + [:end_mapping, [1, 16, 1, 16]], ? ^ ^^ ^ ^^ - [:end_mapping, [2, 0, 2, 0]], ? ^ ^ ^ ^ + [:end_mapping, [1, 16, 1, 16]], ? ^ ^^ ^ ^^ - [:end_document, [2, 0, 2, 0]], ? ^ ^ ^ ^ + [:end_document, [1, 16, 1, 16]], ? ^ ^^ ^ ^^ - [:end_stream, [2, 0, 2, 0]]] ? ^ ^ ^ ^ + [:end_stream, [1, 16, 1, 16]]] ? ^ ^^ ^ ^^

Check failure on line 370 in test/psych/test_parser.rb

View workflow job for this annotation

GitHub Actions / test (macos-latest, jruby-head)

Failure

<[[:start_stream, [0, 0, 0, 0]], [:start_document, [0, 0, 0, 0]], [:start_mapping, [0, 0, 0, 0]], [:scalar, [0, 0, 0, 3]], [:start_mapping, [1, 2, 1, 2]], [:scalar, [1, 2, 1, 8]], [:start_sequence, [1, 10, 1, 11]], [:scalar, [1, 11, 1, 12]], [:scalar, [1, 14, 1, 15]], [:end_sequence, [1, 15, 1, 16]], [:end_mapping, [2, 0, 2, 0]], [:end_mapping, [2, 0, 2, 0]], [:end_document, [2, 0, 2, 0]], [:end_stream, [2, 0, 2, 0]]]> expected but was <[[:start_stream, [0, 0, 0, 0]], [:start_document, [0, 0, 0, 0]], [:start_mapping, [0, 0, 0, 0]], [:scalar, [0, 0, 0, 3]], [:start_mapping, [1, 2, 1, 2]], [:scalar, [1, 2, 1, 8]], [:start_sequence, [1, 10, 1, 11]], [:scalar, [1, 11, 1, 12]], [:scalar, [1, 14, 1, 15]], [:end_sequence, [1, 15, 1, 16]], [:end_mapping, [1, 16, 1, 16]], [:end_mapping, [1, 16, 1, 16]], [:end_document, [1, 16, 1, 16]], [:end_stream, [1, 16, 1, 16]]]>. diff: [[:start_stream, [0, 0, 0, 0]], [:start_document, [0, 0, 0, 0]], [:start_mapping, [0, 0, 0, 0]], [:scalar, [0, 0, 0, 3]], [:start_mapping, [1, 2, 1, 2]], [:scalar, [1, 2, 1, 8]], [:start_sequence, [1, 10, 1, 11]], [:scalar, [1, 11, 1, 12]], [:scalar, [1, 14, 1, 15]], [:end_sequence, [1, 15, 1, 16]], - [:end_mapping, [2, 0, 2, 0]], ? ^ ^ ^ ^ + [:end_mapping, [1, 16, 1, 16]], ? ^ ^^ ^ ^^ - [:end_mapping, [2, 0, 2, 0]], ? ^ ^ ^ ^ + [:end_mapping, [1, 16, 1, 16]], ? ^ ^^ ^ ^^ - [:end_document, [2, 0, 2, 0]], ? ^ ^ ^ ^ + [:end_document, [1, 16, 1, 16]], ? ^ ^^ ^ ^^ - [:end_stream, [2, 0, 2, 0]]] ? ^ ^ ^ ^ + [:end_stream, [1, 16, 1, 16]]] ? ^ ^^ ^ ^^
[:start_stream, [0, 0, 0, 0]],
[:start_document, [0, 0, 0, 0]],
[:start_mapping, [0, 0, 0, 0]],
Expand Down
22 changes: 0 additions & 22 deletions test/psych/test_safe_load.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,28 +124,6 @@ def test_data_depends_on_sym
end
end

def test_anon_data
omit "Data requires ruby >= 3.2" if RUBY_VERSION < "3.2"
assert Psych.safe_load(<<-eoyml, permitted_classes: [Data, Symbol])
--- !ruby/data
foo: bar
eoyml

assert_raise(Psych::DisallowedClass) do
Psych.safe_load(<<-eoyml, permitted_classes: [Data])
--- !ruby/data
foo: bar
eoyml
end

assert_raise(Psych::DisallowedClass) do
Psych.safe_load(<<-eoyml, permitted_classes: [Symbol])
--- !ruby/data
foo: bar
eoyml
end
end

def test_safe_load_default_fallback
assert_nil Psych.safe_load("")
end
Expand Down
3 changes: 1 addition & 2 deletions test/psych/test_serialize_subclasses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ def test_struct_subclass

class DataSubclass < Data.define(:foo)
def initialize(foo:)
@bar = "hello #{foo}"
super(foo: foo)
end

def == other
super(other) && @bar == other.instance_eval{ @bar }
super(other)
end
end unless RUBY_VERSION < "3.2"

Expand Down
2 changes: 1 addition & 1 deletion test/psych/test_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_doublequotes_when_there_is_a_single
end

def test_single_quote_when_matching_date
pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/
# pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/

lib = File.expand_path("../../../lib", __FILE__)
assert_separately(["-I", lib, "-r", "psych"], __FILE__, __LINE__ + 1, <<~'RUBY')
Expand Down
14 changes: 0 additions & 14 deletions test/psych/visitors/test_yaml_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,6 @@ def test_data
assert_cycle D.new('bar')
end

def test_data_anon
omit "Data requires ruby >= 3.2" if RUBY_VERSION < "3.2"
d = Data.define(:foo).new('bar')
obj = Psych.unsafe_load(Psych.dump(d))
assert_equal d.foo, obj.foo
end

def test_data_override_method
omit "Data requires ruby >= 3.2" if RUBY_VERSION < "3.2"
d = Data.define(:method).new('override')
obj = Psych.unsafe_load(Psych.dump(d))
assert_equal d.method, obj.method
end

def test_exception
ex = Exception.new 'foo'
loaded = Psych.unsafe_load(Psych.dump(ex))
Expand Down
Loading