Permalink
Browse files

pulling in changes from ruby core

  • Loading branch information...
1 parent 11fc866 commit 8dfd1b10016855187ade94f36d592b0319e2b226 @tenderlove tenderlove committed Mar 30, 2011
Showing with 68 additions and 52 deletions.
  1. +2 −2 ext/psych/parser.c
  2. +22 −12 lib/psych/visitors/yaml_tree.rb
  3. +1 −1 test/psych/json/test_stream.rb
  4. +1 −1 test/psych/nodes/test_enumerable.rb
  5. +1 −1 test/psych/test_alias_and_anchor.rb
  6. +1 −1 test/psych/test_array.rb
  7. +1 −1 test/psych/test_boolean.rb
  8. +1 −1 test/psych/test_class.rb
  9. +1 −1 test/psych/test_coder.rb
  10. +1 −1 test/psych/test_date_time.rb
  11. +1 −1 test/psych/test_deprecated.rb
  12. +1 −1 test/psych/test_document.rb
  13. +1 −1 test/psych/test_emitter.rb
  14. +1 −1 test/psych/test_encoding.rb
  15. +1 −1 test/psych/test_engine_manager.rb
  16. +1 −1 test/psych/test_exception.rb
  17. +1 −1 test/psych/test_hash.rb
  18. +1 −1 test/psych/test_json_tree.rb
  19. +1 −1 test/psych/test_merge_keys.rb
  20. +1 −1 test/psych/test_nil.rb
  21. +1 −1 test/psych/test_null.rb
  22. +1 −1 test/psych/test_object.rb
  23. +1 −1 test/psych/test_omap.rb
  24. +1 −1 test/psych/test_parser.rb
  25. +1 −1 test/psych/test_psych.rb
  26. +1 −1 test/psych/test_scalar.rb
  27. +1 −1 test/psych/test_scalar_scanner.rb
  28. +1 −1 test/psych/test_serialize_subclasses.rb
  29. +1 −1 test/psych/test_set.rb
  30. +1 −1 test/psych/test_stream.rb
  31. +1 −1 test/psych/test_string.rb
  32. +1 −1 test/psych/test_struct.rb
  33. +1 −1 test/psych/test_symbol.rb
  34. +1 −1 test/psych/test_to_yaml_properties.rb
  35. +1 −1 test/psych/test_tree_builder.rb
  36. +1 −1 test/psych/test_yaml.rb
  37. +1 −1 test/psych/visitors/test_depth_first.rb
  38. +1 −1 test/psych/visitors/test_emitter.rb
  39. +1 −1 test/psych/visitors/test_to_ruby.rb
  40. +7 −1 test/psych/visitors/test_yaml_tree.rb
View
@@ -19,9 +19,9 @@ static ID id_end_mapping;
#define PSYCH_TRANSCODE(_str, _yaml_enc, _internal_enc) \
do { \
- rb_enc_associate_index(_str, _yaml_enc); \
+ rb_enc_associate_index((_str), (_yaml_enc)); \
if(_internal_enc) \
- _str = rb_str_export_to_enc(_str, _internal_enc); \
+ (_str) = rb_str_export_to_enc((_str), (_internal_enc)); \
} while (0)
static int io_reader(void * data, unsigned char *buf, size_t size, size_t *read)
@@ -79,15 +79,20 @@ def accept target
end
if target.respond_to?(:to_yaml)
- loc = target.method(:to_yaml).source_location.first
- if loc !~ /(syck\/rubytypes.rb|psych\/core_ext.rb)/
- unless target.respond_to?(:encode_with)
- if $VERBOSE
- warn "implementing to_yaml is deprecated, please implement \"encode_with\""
+ begin
+ loc = target.method(:to_yaml).source_location.first
+ if loc !~ /(syck\/rubytypes.rb|psych\/core_ext.rb)/
+ unless target.respond_to?(:encode_with)
+ if $VERBOSE
+ warn "implementing to_yaml is deprecated, please implement \"encode_with\""
+ end
+
+ target.to_yaml(:nodump => true)
end
-
- target.to_yaml(:nodump => true)
end
+ rescue
+ # public_method or source_location might be overridden,
+ # and it's OK to skip it since it's only to emit a warning
end
end
@@ -300,12 +305,17 @@ def format_time time
# FIXME: remove this method once "to_yaml_properties" is removed
def find_ivars target
- loc = target.method(:to_yaml_properties).source_location.first
- unless loc.start_with?(Psych::DEPRECATED) || loc.end_with?('rubytypes.rb')
- if $VERBOSE
- warn "#{loc}: to_yaml_properties is deprecated, please implement \"encode_with(coder)\""
+ begin
+ loc = target.method(:to_yaml_properties).source_location.first
+ unless loc.start_with?(Psych::DEPRECATED) || loc.end_with?('rubytypes.rb')
+ if $VERBOSE
+ warn "#{loc}: to_yaml_properties is deprecated, please implement \"encode_with(coder)\""
+ end
+ return target.to_yaml_properties
end
- return target.to_yaml_properties
+ rescue
+ # public_method or source_location might be overridden,
+ # and it's OK to skip it since it's only to emit a warning.
end
target.instance_variables
@@ -1,4 +1,4 @@
-require_relative '../helper'
+require 'psych/helper'
module Psych
module JSON
@@ -1,4 +1,4 @@
-require_relative '../helper'
+require 'psych/helper'
module Psych
module Nodes
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestAliasAndAnchor < TestCase
View
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestArray < TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
###
View
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestClass < TestCase
View
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestCoder < TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
require 'date'
module Psych
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestDeprecated < TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestDocument < TestCase
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestEmitter < TestCase
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestEncoding < TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
require 'yaml'
module Psych
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestException < TestCase
View
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestHash < TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestJSONTree < TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestMergeKeys < TestCase
View
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestNil < TestCase
View
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
###
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class Tagged
View
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestOmap < TestCase
@@ -1,6 +1,6 @@
# coding: utf-8
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestParser < TestCase
View
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
require 'stringio'
require 'tempfile'
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestScalar < TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestScalarScanner < TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestSerializeSubclasses < TestCase
View
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestSet < TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestStream < TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestString < TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
class PsychStructWithIvar < Struct.new(:foo)
attr_reader :bar
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestSymbol < TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestToYamlProperties < MiniTest::Unit::TestCase
@@ -1,4 +1,4 @@
-require_relative 'helper'
+require 'psych/helper'
module Psych
class TestTreeBuilder < TestCase
View
@@ -2,7 +2,7 @@
# vim:sw=4:ts=4
# $Id$
#
-require_relative 'helper'
+require 'psych/helper'
# [ruby-core:01946]
module Psych_Tests
@@ -1,4 +1,4 @@
-require_relative '../helper'
+require 'psych/helper'
module Psych
module Visitors
@@ -1,4 +1,4 @@
-require_relative '../helper'
+require 'psych/helper'
module Psych
module Visitors
@@ -1,4 +1,4 @@
-require_relative '../helper'
+require 'psych/helper'
module Psych
module Visitors
@@ -1,4 +1,4 @@
-require_relative '../helper'
+require 'psych/helper'
module Psych
module Visitors
@@ -38,6 +38,12 @@ def test_struct_anon
assert_equal s.foo, obj.foo
end
+ def test_override_method
+ s = Struct.new(:method).new('override')
+ obj = Psych.load(Psych.dump(s))
+ assert_equal s.method, obj.method
+ end
+
def test_exception
ex = Exception.new 'foo'
loaded = Psych.load(Psych.dump(ex))

0 comments on commit 8dfd1b1

Please sign in to comment.