summaryrefslogtreecommitdiff
path: root/test/psych/test_deprecated.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-05 13:16:32 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-05 13:16:32 +0000
commit6d77e28763ed17f75edf3b4072701b4dbd7644bb (patch)
treee56f68d61222a1cf4bfc6a63aa640c6546a41b91 /test/psych/test_deprecated.rb
parent4389ba641f89fe9d4e5c575442968d385c4183e8 (diff)
Import psych-3.0.0.beta1 from ruby/psych.
* Removed deprecated code. * Removed code related syck gem. * Fixed typos. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych/test_deprecated.rb')
-rw-r--r--test/psych/test_deprecated.rb126
1 files changed, 1 insertions, 125 deletions
diff --git a/test/psych/test_deprecated.rb b/test/psych/test_deprecated.rb
index a806f6b972..eab230231d 100644
--- a/test/psych/test_deprecated.rb
+++ b/test/psych/test_deprecated.rb
@@ -8,47 +8,12 @@ module Psych
Psych.domain_types.clear
end
- class QuickEmitter
- attr_reader :name
- attr_reader :value
-
- def initialize
- @name = 'hello!!'
- @value = 'Friday!'
- end
-
- def to_yaml opts = {}
- Psych.quick_emit object_id, opts do |out|
- out.map taguri, to_yaml_style do |map|
- map.add 'name', @name
- map.add 'value', nil
- end
- end
- end
- end
+ class QuickEmitter; end
def setup
- @qe = QuickEmitter.new
@orig_verbose, $VERBOSE = $VERBOSE, false
end
- def test_quick_emit
- qe2 = Psych.load @qe.to_yaml
- assert_equal @qe.name, qe2.name
- assert_instance_of QuickEmitter, qe2
- assert_nil qe2.value
- end
-
- def test_recursive_quick_emit
- hash = { :qe => @qe }
- hash2 = Psych.load Psych.dump hash
- qe = hash2[:qe]
-
- assert_equal @qe.name, qe.name
- assert_instance_of QuickEmitter, qe
- assert_nil qe.value
- end
-
class QuickEmitterEncodeWith
attr_reader :name
attr_reader :value
@@ -84,30 +49,6 @@ module Psych
assert_nil qe.value
end
- class YamlInit
- attr_reader :name
- attr_reader :value
-
- def initialize
- @name = 'hello!!'
- @value = 'Friday!'
- end
-
- def yaml_initialize tag, vals
- vals.each { |ivar, val| instance_variable_set "@#{ivar}", 'TGIF!' }
- end
- end
-
- def test_yaml_initialize
- hash = { :yi => YamlInit.new }
- hash2 = Psych.load Psych.dump hash
- yi = hash2[:yi]
-
- assert_equal 'TGIF!', yi.name
- assert_equal 'TGIF!', yi.value
- assert_instance_of YamlInit, yi
- end
-
class YamlInitAndInitWith
attr_reader :name
attr_reader :value
@@ -146,70 +87,5 @@ module Psych
assert_equal 'some string', coder.scalar
assert_equal :scalar, coder.type
end
-
- class YamlAs
- TestCase.suppress_warning do
- psych_yaml_as 'helloworld' # this should be yaml_as but to avoid syck
- end
- end
-
- def test_yaml_as
- assert_match(/helloworld/, Psych.dump(YamlAs.new))
- end
-
- def test_ruby_type
- types = []
- appender = lambda { |*args| types << args }
-
- Psych.add_ruby_type('foo', &appender)
- Psych.load <<-eoyml
-- !ruby.yaml.org,2002/foo bar
- eoyml
-
- assert_equal [["tag:ruby.yaml.org,2002:foo", "bar"]], types
- end
-
- def test_detect_implicit
- assert_equal '', Psych.detect_implicit(nil)
- assert_equal '', Psych.detect_implicit(Object.new)
- assert_equal '', Psych.detect_implicit(1.2)
- assert_equal 'null', Psych.detect_implicit('')
- assert_equal 'string', Psych.detect_implicit('foo')
- end
-
- def test_private_type
- types = []
- Psych.add_private_type('foo') { |*args| types << args }
- Psych.load <<-eoyml
-- !x-private:foo bar
- eoyml
-
- assert_equal [["x-private:foo", "bar"]], types
- end
-
- def test_tagurize
- assert_nil Psych.tagurize nil
- assert_equal Psych, Psych.tagurize(Psych)
- assert_equal 'tag:yaml.org,2002:foo', Psych.tagurize('foo')
- end
-
- def test_read_type_class
- things = Psych.read_type_class 'tag:yaml.org,2002:int:Psych::TestDeprecated::QuickEmitter', Object
- assert_equal 'int', things.first
- assert_equal Psych::TestDeprecated::QuickEmitter, things.last
- end
-
- def test_read_type_class_no_class
- things = Psych.read_type_class 'tag:yaml.org,2002:int', Object
- assert_equal 'int', things.first
- assert_equal Object, things.last
- end
-
- def test_object_maker
- thing = Psych.object_maker(Object, { 'a' => 'b', 'c' => 'd' })
- assert_instance_of(Object, thing)
- assert_equal 'b', thing.instance_variable_get(:@a)
- assert_equal 'd', thing.instance_variable_get(:@c)
- end
end
end