Skip to content

Commit 3f5e520

Browse files
committed
Fixing compatibility with libyaml 0.2.5
The main issue is that commas aren't allowed in local tags. libyaml was updated to follow the spec, and our tests were out of date. See: yaml/libyaml#196
1 parent d2deaa9 commit 3f5e520

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

test/psych/test_nil.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ module Psych
55
class TestNil < TestCase
66
def test_nil
77
yml = Psych.dump nil
8-
assert_match(/--- \n(?:\.\.\.\n)?/, yml)
8+
assert_match(/---[ ]?\n(?:\.\.\.\n)?/, yml)
99
assert_nil Psych.load(yml)
1010
end
1111

1212
def test_array_nil
1313
yml = Psych.dump [nil]
14-
assert_equal "---\n- \n", yml
14+
assert_match(/---\n-[ ]?\n/, yml)
1515
assert_equal [nil], Psych.load(yml)
1616
end
1717

test/psych/test_psych.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,17 @@ def test_add_builtin_type
178178

179179
def test_domain_types
180180
got = nil
181-
Psych.add_domain_type 'foo.bar,2002', 'foo' do |type, val|
181+
Psych.add_domain_type 'foo.bar/2002', 'foo' do |type, val|
182182
got = val
183183
end
184184

185-
Psych.load('--- !foo.bar,2002/foo hello')
185+
Psych.load('--- !foo.bar/2002:foo hello')
186186
assert_equal 'hello', got
187187

188-
Psych.load("--- !foo.bar,2002/foo\n- hello\n- world")
188+
Psych.load("--- !foo.bar/2002:foo\n- hello\n- world")
189189
assert_equal %w{ hello world }, got
190190

191-
Psych.load("--- !foo.bar,2002/foo\nhello: world")
191+
Psych.load("--- !foo.bar/2002:foo\nhello: world")
192192
assert_equal({ 'hello' => 'world' }, got)
193193
end
194194

@@ -311,16 +311,13 @@ def test_callbacks
311311
types = []
312312
appender = lambda { |*args| types << args }
313313

314-
Psych.add_builtin_type('foo', &appender)
315-
Psych.add_domain_type('example.com,2002', 'foo', &appender)
314+
Psych.add_domain_type('example.com:2002', 'foo', &appender)
316315
Psych.load <<-eoyml
317-
- !tag:yaml.org,2002:foo bar
318-
- !tag:example.com,2002:foo bar
316+
- !tag:example.com:2002:foo bar
319317
eoyml
320318

321319
assert_equal [
322-
["tag:yaml.org,2002:foo", "bar"],
323-
["tag:example.com,2002:foo", "bar"]
320+
["tag:example.com:2002:foo", "bar"]
324321
], types
325322
end
326323

test/psych/test_yaml.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -617,11 +617,11 @@ def test_spec_domain_prefix
617617
raise ArgumentError, "Not a Hash in domain.tld,2002/invoice: " + val.inspect
618618
end
619619
}
620-
Psych.add_domain_type( "domain.tld,2002", 'invoice', &customer_proc )
621-
Psych.add_domain_type( "domain.tld,2002", 'customer', &customer_proc )
620+
Psych.add_domain_type( "domain.tld/2002", 'invoice', &customer_proc )
621+
Psych.add_domain_type( "domain.tld/2002", 'customer', &customer_proc )
622622
assert_parse_only( { "invoice"=> { "customers"=> [ { "given"=>"Chris", "type"=>"domain customer", "family"=>"Dumars" } ], "type"=>"domain invoice" } }, <<EOY
623623
# 'http://domain.tld,2002/invoice' is some type family.
624-
invoice: !domain.tld,2002/invoice
624+
invoice: !domain.tld/2002:invoice
625625
# 'seq' is shorthand for 'http://yaml.org/seq'.
626626
# This does not effect '^customer' below
627627
# because it is does not specify a prefix.
@@ -705,7 +705,7 @@ def test_spec_override_anchor
705705
end
706706

707707
def test_spec_explicit_families
708-
Psych.add_domain_type( "somewhere.com,2002", 'type' ) { |type, val|
708+
Psych.add_domain_type( "somewhere.com/2002", 'type' ) { |type, val|
709709
"SOMEWHERE: #{val}"
710710
}
711711
assert_parse_only(
@@ -717,7 +717,7 @@ def test_spec_explicit_families
717717
Pz7Y6OjuDg4J+fn5OTk6enp
718718
56enmleECcgggoBADs=
719719
720-
hmm: !somewhere.com,2002/type |
720+
hmm: !somewhere.com/2002:type |
721721
family above is short for
722722
http://somewhere.com/type
723723
EOY
@@ -726,7 +726,7 @@ def test_spec_explicit_families
726726

727727
def test_spec_application_family
728728
# Testing the clarkevans.com graphs
729-
Psych.add_domain_type( "clarkevans.com,2002", 'graph/shape' ) { |type, val|
729+
Psych.add_domain_type( "clarkevans.com/2002", 'graph/shape' ) { |type, val|
730730
if Array === val
731731
val << "Shape Container"
732732
val
@@ -743,13 +743,13 @@ def test_spec_application_family
743743
raise ArgumentError, "Invalid graph of type #{val.class}: " + val.inspect
744744
end
745745
}
746-
Psych.add_domain_type( "clarkevans.com,2002", 'graph/circle', &one_shape_proc )
747-
Psych.add_domain_type( "clarkevans.com,2002", 'graph/line', &one_shape_proc )
748-
Psych.add_domain_type( "clarkevans.com,2002", 'graph/text', &one_shape_proc )
746+
Psych.add_domain_type( "clarkevans.com/2002", 'graph/circle', &one_shape_proc )
747+
Psych.add_domain_type( "clarkevans.com/2002", 'graph/line', &one_shape_proc )
748+
Psych.add_domain_type( "clarkevans.com/2002", 'graph/text', &one_shape_proc )
749749
# MODIFIED to remove invalid Psych
750750
assert_parse_only(
751751
[[{"radius"=>7, "center"=>{"x"=>73, "y"=>129}, "TYPE"=>"Shape: graph/circle"}, {"finish"=>{"x"=>89, "y"=>102}, "TYPE"=>"Shape: graph/line", "start"=>{"x"=>73, "y"=>129}}, {"TYPE"=>"Shape: graph/text", "value"=>"Pretty vector drawing.", "start"=>{"x"=>73, "y"=>129}, "color"=>16772795}, "Shape Container"]], <<EOY
752-
- !clarkevans.com,2002/graph/shape
752+
- !clarkevans.com/2002:graph/shape
753753
- !/graph/circle
754754
center: &ORIGIN {x: 73, y: 129}
755755
radius: 7
@@ -771,8 +771,8 @@ def test_spec_float_explicit
771771
# have the same type and value.
772772
- 10.0
773773
- !float 10
774-
- !yaml.org,2002/float '10'
775-
- !yaml.org,2002/float "\\
774+
- !yaml.org/2002/float '10'
775+
- !yaml.org/2002/float "\\
776776
1\\
777777
0"
778778
EOY

0 commit comments

Comments
 (0)