Skip to content
Browse files

moving tests under the psych directory

  • Loading branch information...
1 parent 50dd727 commit 2195fb15a7b6c4f3ea17885b184f386e6cc82787 @tenderlove committed Mar 26, 2010
View
1 Rakefile
@@ -7,6 +7,7 @@ gem 'rake-compiler', '>= 0.4.1'
require "rake/extensiontask"
Hoe.plugin :debugging, :doofus, :git
+Hoe::RUBY_FLAGS << " -I. "
Hoe.spec 'psych' do
developer 'Aaron Patterson', 'aaronp@rubyforge.org'
View
3 test/helper.rb
@@ -1,3 +0,0 @@
-require 'test/unit'
-require 'psych'
-require 'psych/yaml'
View
11 test/yaml/test_array.rb → test/psych/test_array.rb
@@ -1,22 +1,23 @@
-require 'helper'
+require 'minitest/autorun'
+require 'psych'
-module YAML
+module Psych
class TestArray < MiniTest::Unit::TestCase
def setup
@list = [{ :a => 'b' }, 'foo']
end
def test_self_referential
@list << @list
- assert_equal @list, YAML.load(@list.to_yaml)
+ assert_equal @list, Psych.load(@list.to_yaml)
end
def test_to_yaml
- assert_equal @list, YAML.load(@list.to_yaml)
+ assert_equal @list, Psych.load(@list.to_yaml)
end
def test_dump
- assert_equal @list, YAML.load(YAML.dump(@list))
+ assert_equal @list, Psych.load(Psych.dump(@list))
end
end
end
View
17 test/yaml/test_boolean.rb → test/psych/test_boolean.rb
@@ -1,36 +1,37 @@
-require 'helper'
+require 'minitest/autorun'
+require 'psych'
-module YAML
+module Psych
###
# Test booleans from YAML spec:
# http://yaml.org/type/bool.html
class TestBoolean < MiniTest::Unit::TestCase
%w{ yes Yes YES true True TRUE on On ON }.each do |truth|
define_method(:"test_#{truth}") do
- assert_equal true, YAML.load("--- #{truth}")
+ assert_equal true, Psych.load("--- #{truth}")
end
end
%w{ no No NO false False FALSE off Off OFF }.each do |truth|
define_method(:"test_#{truth}") do
- assert_equal false, YAML.load("--- #{truth}")
+ assert_equal false, Psych.load("--- #{truth}")
end
end
###
# YAML spec says "y" and "Y" may be used as true, but Syck treats them
# as literal strings
def test_y
- assert_equal "y", YAML.load("--- y")
- assert_equal "Y", YAML.load("--- Y")
+ assert_equal "y", Psych.load("--- y")
+ assert_equal "Y", Psych.load("--- Y")
end
###
# YAML spec says "n" and "N" may be used as false, but Syck treats them
# as literal strings
def test_n
- assert_equal "n", YAML.load("--- n")
- assert_equal "N", YAML.load("--- N")
+ assert_equal "n", Psych.load("--- n")
+ assert_equal "N", Psych.load("--- N")
end
end
end
View
7 test/yaml/test_class.rb → test/psych/test_class.rb
@@ -1,6 +1,7 @@
-require 'helper'
+require 'minitest/autorun'
+require 'psych'
-module YAML
+module Psych
class TestClass < MiniTest::Unit::TestCase
def test_to_yaml
assert_raises(::TypeError) do
@@ -10,7 +11,7 @@ def test_to_yaml
def test_dump
assert_raises(::TypeError) do
- YAML.dump TestClass
+ Psych.dump TestClass
end
end
end
View
11 test/yaml/test_exception.rb → test/psych/test_exception.rb
@@ -1,6 +1,7 @@
-require 'helper'
+require 'minitest/autorun'
+require 'psych'
-module YAML
+module Psych
class TestException < MiniTest::Unit::TestCase
class Wups < Exception
attr_reader :foo, :bar
@@ -16,14 +17,14 @@ def setup
end
def test_to_yaml
- w = YAML.load(@wups.to_yaml)
+ w = Psych.load(@wups.to_yaml)
assert_equal @wups, w
assert_equal 1, w.foo
assert_equal 2, w.bar
end
def test_dump
- w = YAML.load(@wups.to_yaml)
+ w = Psych.load(@wups.to_yaml)
assert_equal @wups, w
assert_equal 1, w.foo
assert_equal 2, w.bar
@@ -36,7 +37,7 @@ def to_yaml_properties
end
end
- w = YAML.load(YAML.dump(@wups))
+ w = Psych.load(Psych.dump(@wups))
assert_equal @wups, w
assert_equal 1, w.foo
assert_nil w.bar
View
13 test/yaml/test_hash.rb → test/psych/test_hash.rb
@@ -1,26 +1,27 @@
-require 'helper'
+require 'minitest/autorun'
+require 'psych'
-module YAML
+module Psych
class TestHash < MiniTest::Unit::TestCase
def setup
@hash = { :a => 'b' }
end
def test_self_referential
@hash['self'] = @hash
- assert_equal @hash, YAML.load(YAML.dump(@hash))
+ assert_equal @hash, Psych.load(Psych.dump(@hash))
end
def test_to_yaml
- assert_equal @hash, YAML.load(@hash.to_yaml)
+ assert_equal @hash, Psych.load(@hash.to_yaml)
end
def test_dump
- assert_equal @hash, YAML.load(YAML.dump(@hash))
+ assert_equal @hash, Psych.load(Psych.dump(@hash))
end
def test_ref_append
- hash = YAML.load(<<-eoyml)
+ hash = Psych.load(<<-eoyml)
---
foo: &foo
hello: world
View
7 test/yaml/test_null.rb → test/psych/test_null.rb
@@ -1,12 +1,13 @@
-require 'helper'
+require 'minitest/autorun'
+require 'psych'
-module YAML
+module Psych
###
# Test null from YAML spec:
# http://yaml.org/type/null.html
class TestNull < MiniTest::Unit::TestCase
def test_null_list
- assert_equal [nil] * 5, YAML.load(<<-eoyml)
+ assert_equal [nil] * 5, Psych.load(<<-eoyml)
---
- ~
- null
View
5 test/yaml/test_object.rb → test/psych/test_object.rb
@@ -1,6 +1,7 @@
-require 'helper'
+require 'minitest/autorun'
+require 'psych'
-module YAML
+module Psych
class Tagged
yaml_tag '!foo'
View
25 test/yaml/test_omap.rb → test/psych/test_omap.rb
@@ -1,37 +1,38 @@
-require 'helper'
+require 'minitest/autorun'
+require 'psych'
-module YAML
+module Psych
class TestOmap < MiniTest::Unit::TestCase
def test_self_referential
- map = YAML::Omap.new
+ map = Psych::Omap.new
map['foo'] = 'bar'
map['self'] = map
- assert_equal(map, YAML.load(YAML.dump(map)))
+ assert_equal(map, Psych.load(Psych.dump(map)))
end
def test_keys
- map = YAML::Omap.new
+ map = Psych::Omap.new
map['foo'] = 'bar'
assert_equal 'bar', map['foo']
end
def test_order
- map = YAML::Omap.new
+ map = Psych::Omap.new
map['a'] = 'b'
map['b'] = 'c'
assert_equal [%w{a b}, %w{b c}], map.to_a
end
def test_square
list = [["a", "b"], ["b", "c"]]
- map = YAML::Omap[*list.flatten]
+ map = Psych::Omap[*list.flatten]
assert_equal list, map.to_a
assert_equal 'b', map['a']
assert_equal 'c', map['b']
end
def test_to_yaml
- map = YAML::Omap['a', 'b', 'c', 'd']
+ map = Psych::Omap['a', 'b', 'c', 'd']
yaml = map.to_yaml
assert_match('!omap', yaml)
assert_match('- a: b', yaml)
@@ -40,16 +41,16 @@ def test_to_yaml
def test_round_trip
list = [["a", "b"], ["b", "c"]]
- map = YAML::Omap[*list.flatten]
- loaded = YAML.load(YAML.dump(map))
+ map = Psych::Omap[*list.flatten]
+ loaded = Psych.load(Psych.dump(map))
assert_equal map, loaded
assert_equal list, loaded.to_a
end
def test_load
list = [["a", "b"], ["c", "d"]]
- map = YAML.load(<<-eoyml)
+ map = Psych.load(<<-eoyml)
--- !omap
- a: b
- c: d
@@ -60,7 +61,7 @@ def test_load
# NOTE: This test will not work with Syck
def test_load_shorthand
list = [["a", "b"], ["c", "d"]]
- map = YAML.load(<<-eoyml)
+ map = Psych.load(<<-eoyml)
--- !!omap
- a: b
- c: d
View
19 test/yaml/test_set.rb → test/psych/test_set.rb
@@ -1,9 +1,10 @@
-require 'helper'
+require 'minitest/autorun'
+require 'psych'
-module YAML
+module Psych
class TestSet < MiniTest::Unit::TestCase
def setup
- @set = YAML::Set.new
+ @set = Psych::Set.new
@set['foo'] = 'bar'
@set['bar'] = 'baz'
end
@@ -13,13 +14,13 @@ def test_to_yaml
end
def test_roundtrip
- assert_equal(@set, YAML.load(YAML.dump(@set)))
+ assert_equal(@set, Psych.load(Psych.dump(@set)))
end
###
# FIXME: Syck should also support !!set as shorthand
def test_load_from_yaml
- loaded = YAML.load(<<-eoyml)
+ loaded = Psych.load(<<-eoyml)
--- !set
foo: bar
bar: baz
@@ -28,21 +29,21 @@ def test_load_from_yaml
end
def test_loaded_class
- assert_instance_of(YAML::Set, YAML.load(YAML.dump(@set)))
+ assert_instance_of(Psych::Set, Psych.load(Psych.dump(@set)))
end
def test_set_shorthand
- loaded = YAML.load(<<-eoyml)
+ loaded = Psych.load(<<-eoyml)
--- !!set
foo: bar
bar: baz
eoyml
- assert_instance_of(YAML::Set, loaded)
+ assert_instance_of(Psych::Set, loaded)
end
def test_set_self_reference
@set['self'] = @set
- assert_equal(@set, YAML.load(YAML.dump(@set)))
+ assert_equal(@set, Psych.load(Psych.dump(@set)))
end
end
end
View
19 test/yaml/test_string.rb → test/psych/test_string.rb
@@ -1,34 +1,35 @@
-require 'helper'
+require 'minitest/autorun'
+require 'psych'
-module YAML
+module Psych
class TestString < MiniTest::Unit::TestCase
def test_binary_string_null
string = "\x00"
- yml = YAML.dump string
+ yml = Psych.dump string
assert_match(/binary/, yml)
- assert_equal string, YAML.load(yml)
+ assert_equal string, Psych.load(yml)
end
def test_binary_string
string = binary_string
- yml = YAML.dump string
+ yml = Psych.dump string
assert_match(/binary/, yml)
- assert_equal string, YAML.load(yml)
+ assert_equal string, Psych.load(yml)
end
def test_non_binary_string
string = binary_string(0.29)
- yml = YAML.dump string
+ yml = Psych.dump string
refute_match(/binary/, yml)
- assert_equal string, YAML.load(yml)
+ assert_equal string, Psych.load(yml)
end
def test_string_with_ivars
food = "is delicious"
ivar = "on rock and roll"
food.instance_variable_set(:@we_built_this_city, ivar)
- str = YAML.load YAML.dump food
+ str = Psych.load Psych.dump food
assert_equal ivar, food.instance_variable_get(:@we_built_this_city)
end
View
27 test/psych/test_struct.rb
@@ -1,6 +1,14 @@
require 'minitest/autorun'
require 'psych'
+class StructWithIvar < Struct.new(:foo)
+ attr_reader :bar
+ def initialize *args
+ super
+ @bar = 'hello'
+ end
+end
+
module Psych
class TestStruct < MiniTest::Unit::TestCase
class StructSubclass < Struct.new(:foo)
@@ -21,5 +29,24 @@ def test_self_referential_struct
# in ruby.
# assert_equal(ss, loaded)
end
+
+ def test_roundtrip
+ thing = StructWithIvar.new('bar')
+ struct = Psych.load(Psych.dump(thing))
+
+ assert_equal 'hello', struct.bar
+ assert_equal 'bar', struct.foo
+ end
+
+ def test_load
+ obj = Psych.load(<<-eoyml)
+--- !ruby/struct:StructWithIvar
+:foo: bar
+:@bar: hello
+ eoyml
+
+ assert_equal 'hello', obj.bar
+ assert_equal 'bar', obj.foo
+ end
end
end
View
22 test/psych/test_symbol.rb
@@ -0,0 +1,22 @@
+require 'minitest/autorun'
+require 'psych'
+
+module Psych
+ class TestSymbol < MiniTest::Unit::TestCase
+ def test_to_yaml
+ assert_equal :a, Psych.load(:a.to_yaml)
+ end
+
+ def test_dump
+ assert_equal :a, Psych.load(Psych.dump(:a))
+ end
+
+ def test_stringy
+ assert_equal :"1", Psych.load(Psych.dump(:"1"))
+ end
+
+ def test_load_quoted
+ assert_equal :"1", Psych.load("--- :'1'\n")
+ end
+ end
+end
View
126 test/yaml/test_yaml.rb → test/psych/test_yaml.rb
@@ -2,25 +2,25 @@
# vim:sw=4:ts=4
# $Id$
#
-require 'test/unit'
+require 'minitest/autorun'
require 'psych'
# [ruby-core:01946]
-module YAML_Tests
+module Psych_Tests
StructTest = Struct::new( :c )
end
-class YAML_Unit_Tests < Test::Unit::TestCase
+class Psych_Unit_Tests < MiniTest::Unit::TestCase
#
- # Convert between YAML and the object to verify correct parsing and
+ # Convert between Psych and the object to verify correct parsing and
# emitting
#
def assert_to_yaml( obj, yaml )
- assert_equal( obj, YAML::load( yaml ) )
- assert_equal( obj, YAML::parse( yaml ).transform )
- assert_equal( obj, YAML::load( obj.to_yaml ) )
- assert_equal( obj, YAML::parse( obj.to_yaml ).transform )
- assert_equal( obj, YAML::load(
+ assert_equal( obj, Psych::load( yaml ) )
+ assert_equal( obj, Psych::parse( yaml ).transform )
+ assert_equal( obj, Psych::load( obj.to_yaml ) )
+ assert_equal( obj, Psych::parse( obj.to_yaml ).transform )
+ assert_equal( obj, Psych::load(
obj.to_yaml( :UseVersion => true, :UseHeader => true, :SortKeys => true )
) )
end
@@ -29,16 +29,16 @@ def assert_to_yaml( obj, yaml )
# Test parser only
#
def assert_parse_only( obj, yaml )
- assert_equal( obj, YAML::load( yaml ) )
- assert_equal( obj, YAML::parse( yaml ).transform )
+ assert_equal( obj, Psych::load( yaml ) )
+ assert_equal( obj, Psych::parse( yaml ).transform )
end
def assert_cycle( obj )
- assert_equal( obj, YAML::load( obj.to_yaml ) )
+ assert_equal( obj, Psych::load( obj.to_yaml ) )
end
#def assert_path_segments( path, segments )
- # YAML::YPath.each_path( path ) { |choice|
+ # Psych::YPath.each_path( path ) { |choice|
# assert_equal( choice.segments, segments.shift )
# }
# assert_equal( segments.length, 0, "Some segments leftover: #{ segments.inspect }" )
@@ -60,7 +60,7 @@ def mktime( year, mon, day, hour, min, sec, usec, zone = "Z" )
end
#
- # Tests modified from 00basic.t in YAML.pm
+ # Tests modified from 00basic.t in Psych.pm
#
def test_basic_map
# Simple map
@@ -80,13 +80,13 @@ def test_basic_strings
assert_cycle(":")
assert_parse_only(
{ 1 => 'simple string', 2 => 42, 3 => '1 Single Quoted String',
- 4 => 'YAML\'s Double "Quoted" String', 5 => "A block\n with several\n lines.\n",
+ 4 => 'Psych\'s Double "Quoted" String', 5 => "A block\n with several\n lines.\n",
6 => "A \"chomped\" block", 7 => "A folded\n string\n", 8 => ": started string" },
<<EOY
1: simple string
2: 42
3: '1 Single Quoted String'
-4: "YAML's Double \\\"Quoted\\\" String"
+4: "Psych's Double \\\"Quoted\\\" String"
5: |
A block
with several
@@ -470,7 +470,7 @@ def test_spec_type_float
fixed: 1,230.15
negative infinity: -.inf
EOY
- nan = YAML::load( <<EOY )
+ nan = Psych::load( <<EOY )
not a number: .NaN
EOY
assert( nan['not a number'].nan? )
@@ -536,7 +536,7 @@ def test_spec_complex_invoice
def test_spec_log_file
doc_ct = 0
- YAML::load_documents( <<EOY
+ Psych::load_documents( <<EOY
---
Time: 2001-11-23 15:01:42 -05:00
User: ed
@@ -585,19 +585,19 @@ def test_spec_log_file
end
def test_spec_root_fold
- y = YAML::load( <<EOY
+ y = Psych::load( <<EOY
---
-This YAML stream contains a single text value.
+This Psych stream contains a single text value.
The next stream is a log file - a sequence of
log entries. Adding an entry to the log is a
simple matter of appending it at the end.
EOY
)
- assert_equal( y, "This YAML stream contains a single text value. The next stream is a log file - a sequence of log entries. Adding an entry to the log is a simple matter of appending it at the end." )
+ assert_equal( y, "This Psych stream contains a single text value. The next stream is a log file - a sequence of log entries. Adding an entry to the log is a simple matter of appending it at the end." )
end
def test_spec_root_mapping
- y = YAML::load( <<EOY
+ y = Psych::load( <<EOY
# This stream is an example of a top-level mapping.
invoice : 34843
date : 2001-01-23
@@ -609,7 +609,7 @@ def test_spec_root_mapping
def test_spec_oneline_docs
doc_ct = 0
- YAML::load_documents( <<EOY
+ Psych::load_documents( <<EOY
# The following is a sequence of three documents.
# The first contains an empty mapping, the second
# an empty sequence, and the last an empty string.
@@ -641,8 +641,8 @@ def test_spec_domain_prefix
raise ArgumentError, "Not a Hash in domain.tld,2002/invoice: " + val.inspect
end
}
- YAML.add_domain_type( "domain.tld,2002", 'invoice', &customer_proc )
- YAML.add_domain_type( "domain.tld,2002", 'customer', &customer_proc )
+ Psych.add_domain_type( "domain.tld,2002", 'invoice', &customer_proc )
+ Psych.add_domain_type( "domain.tld,2002", 'customer', &customer_proc )
assert_parse_only( { "invoice"=> { "customers"=> [ { "given"=>"Chris", "type"=>"domain customer", "family"=>"Dumars" } ], "type"=>"domain invoice" } }, <<EOY
# 'http://domain.tld,2002/invoice' is some type family.
invoice: !domain.tld,2002/invoice
@@ -687,32 +687,6 @@ def test_spec_force_implicit
)
end
- def test_spec_private_types
- doc_ct = 0
- YAML::parse_documents( <<EOY
-# Private types are per-document.
----
-pool: !!ball
- number: 8
- color: black
----
-bearing: !!ball
- material: steel
-EOY
- ) { |doc|
- case doc_ct
- when 0
- assert_equal( doc['pool'].type_id, 'x-private:ball' )
- assert_equal( doc['pool'].transform.value, { 'number' => 8, 'color' => 'black' } )
- when 1
- assert_equal( doc['bearing'].type_id, 'x-private:ball' )
- assert_equal( doc['bearing'].transform.value, { 'material' => 'steel' } )
- end
- doc_ct += 1
- }
- assert_equal( doc_ct, 2 )
- end
-
###
# Commenting out this test. This line:
#
@@ -723,18 +697,18 @@ def test_spec_private_types
# http://yaml.org/spec/1.1/#id896876
#
# def test_spec_url_escaping
-# YAML.add_domain_type( "domain.tld,2002", "type0" ) { |type, val|
+# Psych.add_domain_type( "domain.tld,2002", "type0" ) { |type, val|
# "ONE: #{val}"
# }
-# YAML.add_domain_type( "domain.tld,2002", "type%30" ) { |type, val|
+# Psych.add_domain_type( "domain.tld,2002", "type%30" ) { |type, val|
# "TWO: #{val}"
# }
# assert_parse_only(
# { 'same' => [ 'ONE: value', 'ONE: value' ], 'different' => [ 'TWO: value' ] }, <<EOY
#same:
# - !domain.tld,2002/type\\x30 value
# - !domain.tld,2002/type0 value
-#different: # As far as the YAML parser is concerned
+#different: # As far as the Psych parser is concerned
# - !domain.tld,2002/type%30 value
#EOY
# )
@@ -755,7 +729,7 @@ def test_spec_override_anchor
end
def test_spec_explicit_families
- YAML.add_domain_type( "somewhere.com,2002", 'type' ) { |type, val|
+ Psych.add_domain_type( "somewhere.com,2002", 'type' ) { |type, val|
"SOMEWHERE: #{val}"
}
assert_parse_only(
@@ -776,7 +750,7 @@ def test_spec_explicit_families
def test_spec_application_family
# Testing the clarkevans.com graphs
- YAML.add_domain_type( "clarkevans.com,2002", 'graph/shape' ) { |type, val|
+ Psych.add_domain_type( "clarkevans.com,2002", 'graph/shape' ) { |type, val|
if Array === val
val << "Shape Container"
val
@@ -793,10 +767,10 @@ def test_spec_application_family
raise ArgumentError, "Invalid graph of type #{val.class}: " + val.inspect
end
}
- YAML.add_domain_type( "clarkevans.com,2002", 'graph/circle', &one_shape_proc )
- YAML.add_domain_type( "clarkevans.com,2002", 'graph/line', &one_shape_proc )
- YAML.add_domain_type( "clarkevans.com,2002", 'graph/text', &one_shape_proc )
- # MODIFIED to remove invalid YAML
+ Psych.add_domain_type( "clarkevans.com,2002", 'graph/circle', &one_shape_proc )
+ Psych.add_domain_type( "clarkevans.com,2002", 'graph/line', &one_shape_proc )
+ Psych.add_domain_type( "clarkevans.com,2002", 'graph/text', &one_shape_proc )
+ # MODIFIED to remove invalid Psych
assert_parse_only(
[[{"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
- !clarkevans.com,2002/graph/shape
@@ -1110,8 +1084,8 @@ def test_ruby_struct
EOY
)
- assert_to_yaml( YAML_Tests::StructTest.new( 123 ), <<EOY )
---- !ruby/struct:YAML_Tests::StructTest
+ assert_to_yaml( Psych_Tests::StructTest.new( 123 ), <<EOY )
+--- !ruby/struct:Psych_Tests::StructTest
c: 123
EOY
@@ -1124,9 +1098,9 @@ def test_ruby_rational
denominator: 2
EOY
- # Read YAML dumped by the ruby 1.8.3.
+ # Read Psych dumped by the ruby 1.8.3.
assert_to_yaml( Rational(1, 2), "!ruby/object:Rational 1/2\n" )
- assert_raise( ArgumentError ) { YAML.load("!ruby/object:Rational INVALID/RATIONAL\n") }
+ assert_raises( ArgumentError ) { Psych.load("!ruby/object:Rational INVALID/RATIONAL\n") }
end
def test_ruby_complex
@@ -1136,9 +1110,9 @@ def test_ruby_complex
real: 3
EOY
- # Read YAML dumped by the ruby 1.8.3.
+ # Read Psych dumped by the ruby 1.8.3.
assert_to_yaml( Complex(3, 4), "!ruby/object:Complex 3+4i\n" )
- assert_raise( ArgumentError ) { YAML.load("!ruby/object:Complex INVALID+COMPLEXi\n") }
+ assert_raises( ArgumentError ) { Psych.load("!ruby/object:Complex INVALID+COMPLEXi\n") }
end
def test_emitting_indicators
@@ -1149,10 +1123,10 @@ def test_emitting_indicators
end
##
- ## Test the YAML::Stream class -- INACTIVE at the moment
+ ## Test the Psych::Stream class -- INACTIVE at the moment
##
#def test_document
- # y = YAML::Stream.new( :Indent => 2, :UseVersion => 0 )
+ # y = Psych::Stream.new( :Indent => 2, :UseVersion => 0 )
# y.add(
# { 'hi' => 'hello', 'map' =>
# { 'good' => 'two' },
@@ -1211,7 +1185,7 @@ def test_akira
# Stress test [ruby-core:1071]
# a = []; 1000.times { a << {"a"=>"b", "c"=>"d"} }
- # YAML::load( a.to_yaml )
+ # Psych::load( a.to_yaml )
end
@@ -1258,7 +1232,7 @@ def test_range_cycle
def test_circular_references
a = []; a[0] = a; a[1] = a
inspect_str = "[[...], [...]]"
- assert_equal( inspect_str, YAML::load( a.to_yaml ).inspect )
+ assert_equal( inspect_str, Psych::load( a.to_yaml ).inspect )
end
#
@@ -1295,14 +1269,14 @@ def test_empty_map_key
#
# empty seq as key
#
- o = YAML.load({[]=>""}.to_yaml)
+ o = Psych.load({[]=>""}.to_yaml)
assert_equal(Hash, o.class)
assert_equal([[]], o.keys)
#
# empty map as key
#
- o = YAML.load({{}=>""}.to_yaml)
+ o = Psych.load({{}=>""}.to_yaml)
assert_equal(Hash, o.class)
assert_equal([{}], o.keys)
end
@@ -1311,23 +1285,23 @@ def test_empty_map_key
# contributed by riley lynch [ruby-Bugs-8548]
#
def test_object_id_collision
- omap = YAML::Omap.new
+ omap = Psych::Omap.new
1000.times { |i| omap["key_#{i}"] = { "value" => i } }
raise "id collision in ordered map" if omap.to_yaml =~ /id\d+/
end
def test_date_out_of_range
- assert_nothing_raised{YAML::load('1900-01-01T00:00:00+00:00')}
+ Psych::load('1900-01-01T00:00:00+00:00')
end
def test_normal_exit
- YAML.load("2000-01-01 00:00:00.#{"0"*1000} +00:00\n")
+ Psych.load("2000-01-01 00:00:00.#{"0"*1000} +00:00\n")
# '[ruby-core:13735]'
end
end
#if $0 == __FILE__
-# suite = Test::Unit::TestSuite.new('YAML')
+# suite = Test::Unit::TestSuite.new('Psych')
# ObjectSpace.each_object(Class) do |klass|
# suite << klass.suite if (Test::Unit::TestCase > klass)
# end
View
32 test/yaml/test_struct.rb
@@ -1,32 +0,0 @@
-require 'helper'
-
-class StructWithIvar < Struct.new(:foo)
- attr_reader :bar
- def initialize *args
- super
- @bar = 'hello'
- end
-end
-
-module YAML
- class TestStruct < MiniTest::Unit::TestCase
- def test_roundtrip
- thing = StructWithIvar.new('bar')
- struct = YAML.load(YAML.dump(thing))
-
- assert_equal 'hello', struct.bar
- assert_equal 'bar', struct.foo
- end
-
- def test_load
- obj = YAML.load(<<-eoyml)
---- !ruby/struct:StructWithIvar
-:foo: bar
-:@bar: hello
- eoyml
-
- assert_equal 'hello', obj.bar
- assert_equal 'bar', obj.foo
- end
- end
-end
View
21 test/yaml/test_symbol.rb
@@ -1,21 +0,0 @@
-require 'helper'
-
-module YAML
- class TestSymbol < MiniTest::Unit::TestCase
- def test_to_yaml
- assert_equal :a, YAML.load(:a.to_yaml)
- end
-
- def test_dump
- assert_equal :a, YAML.load(YAML.dump(:a))
- end
-
- def test_stringy
- assert_equal :"1", YAML.load(YAML.dump(:"1"))
- end
-
- def test_load_quoted
- assert_equal :"1", YAML.load("--- :'1'\n")
- end
- end
-end

0 comments on commit 2195fb1

Please sign in to comment.
Something went wrong with that request. Please try again.