psych 2.0.13 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +9 -4
  3. data/Manifest.txt +2 -0
  4. data/Rakefile +55 -6
  5. data/ext/psych/extconf.rb +1 -0
  6. data/ext/psych/psych_emitter.c +25 -11
  7. data/ext/psych/psych_parser.c +2 -2
  8. data/ext/psych/yaml/loader.c +2 -2
  9. data/ext/psych/yaml/scanner.c +18 -18
  10. data/lib/psych/class_loader.rb +1 -0
  11. data/lib/psych/coder.rb +1 -0
  12. data/lib/psych/core_ext.rb +1 -0
  13. data/lib/psych/deprecated.rb +1 -0
  14. data/lib/psych/exception.rb +1 -0
  15. data/lib/psych/handler.rb +1 -0
  16. data/lib/psych/handlers/document_stream.rb +1 -0
  17. data/lib/psych/handlers/recorder.rb +1 -0
  18. data/lib/psych/json/ruby_events.rb +1 -0
  19. data/lib/psych/json/stream.rb +1 -0
  20. data/lib/psych/json/tree_builder.rb +1 -0
  21. data/lib/psych/json/yaml_events.rb +1 -0
  22. data/lib/psych/nodes/alias.rb +1 -0
  23. data/lib/psych/nodes/document.rb +1 -0
  24. data/lib/psych/nodes/mapping.rb +1 -0
  25. data/lib/psych/nodes/node.rb +1 -0
  26. data/lib/psych/nodes/scalar.rb +1 -0
  27. data/lib/psych/nodes/sequence.rb +1 -0
  28. data/lib/psych/nodes/stream.rb +1 -0
  29. data/lib/psych/nodes.rb +1 -0
  30. data/lib/psych/omap.rb +1 -0
  31. data/lib/psych/parser.rb +1 -0
  32. data/lib/psych/scalar_scanner.rb +1 -0
  33. data/lib/psych/set.rb +1 -0
  34. data/lib/psych/stream.rb +1 -0
  35. data/lib/psych/streaming.rb +1 -0
  36. data/lib/psych/syntax_error.rb +1 -0
  37. data/lib/psych/tree_builder.rb +1 -0
  38. data/lib/psych/versions.rb +4 -0
  39. data/lib/psych/visitors/depth_first.rb +1 -0
  40. data/lib/psych/visitors/emitter.rb +1 -0
  41. data/lib/psych/visitors/json_tree.rb +1 -0
  42. data/lib/psych/visitors/to_ruby.rb +5 -3
  43. data/lib/psych/visitors/visitor.rb +1 -0
  44. data/lib/psych/visitors/yaml_tree.rb +17 -24
  45. data/lib/psych/visitors.rb +1 -0
  46. data/lib/psych/y.rb +1 -0
  47. data/lib/psych.rb +21 -9
  48. data/lib/psych_jars.rb +6 -0
  49. data/test/psych/handlers/test_recorder.rb +1 -0
  50. data/test/psych/helper.rb +3 -1
  51. data/test/psych/json/test_stream.rb +1 -0
  52. data/test/psych/nodes/test_enumerable.rb +1 -0
  53. data/test/psych/test_alias_and_anchor.rb +1 -0
  54. data/test/psych/test_array.rb +1 -0
  55. data/test/psych/test_boolean.rb +1 -0
  56. data/test/psych/test_class.rb +1 -0
  57. data/test/psych/test_coder.rb +1 -0
  58. data/test/psych/test_date_time.rb +1 -0
  59. data/test/psych/test_deprecated.rb +1 -0
  60. data/test/psych/test_document.rb +1 -0
  61. data/test/psych/test_emitter.rb +18 -0
  62. data/test/psych/test_encoding.rb +10 -0
  63. data/test/psych/test_exception.rb +1 -0
  64. data/test/psych/test_hash.rb +1 -0
  65. data/test/psych/test_json_tree.rb +1 -0
  66. data/test/psych/test_merge_keys.rb +1 -0
  67. data/test/psych/test_nil.rb +1 -0
  68. data/test/psych/test_null.rb +1 -0
  69. data/test/psych/test_numeric.rb +1 -0
  70. data/test/psych/test_object.rb +1 -0
  71. data/test/psych/test_object_references.rb +1 -0
  72. data/test/psych/test_omap.rb +1 -0
  73. data/test/psych/test_parser.rb +1 -0
  74. data/test/psych/test_psych.rb +17 -1
  75. data/test/psych/test_safe_load.rb +1 -0
  76. data/test/psych/test_scalar.rb +1 -0
  77. data/test/psych/test_scalar_scanner.rb +1 -0
  78. data/test/psych/test_serialize_subclasses.rb +1 -0
  79. data/test/psych/test_set.rb +1 -0
  80. data/test/psych/test_stream.rb +1 -0
  81. data/test/psych/test_string.rb +1 -0
  82. data/test/psych/test_struct.rb +1 -0
  83. data/test/psych/test_symbol.rb +1 -0
  84. data/test/psych/test_tainted.rb +1 -0
  85. data/test/psych/test_to_yaml_properties.rb +1 -0
  86. data/test/psych/test_tree_builder.rb +1 -0
  87. data/test/psych/test_yaml.rb +1 -0
  88. data/test/psych/test_yamldbm.rb +1 -1
  89. data/test/psych/test_yamlstore.rb +1 -0
  90. data/test/psych/visitors/test_depth_first.rb +1 -0
  91. data/test/psych/visitors/test_emitter.rb +1 -0
  92. data/test/psych/visitors/test_to_ruby.rb +15 -9
  93. data/test/psych/visitors/test_yaml_tree.rb +7 -0
  94. metadata +10 -55
  95. data/.gemtest +0 -0
  96. data/test/psych/test_marshalable.rb +0 -54
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require 'psych/tree_builder'
2
3
  require 'psych/scalar_scanner'
3
4
  require 'psych/class_loader'
@@ -70,6 +71,14 @@ module Psych
70
71
  @ss = ss
71
72
  @options = options
72
73
  @line_width = options[:line_width]
74
+ if @line_width && @line_width < 0
75
+ if @line_width == -1
76
+ # Treat -1 as unlimited line-width, same as libyaml does.
77
+ @line_width = nil
78
+ else
79
+ fail(ArgumentError, "Invalid line_width #{@line_width}, must be non-negative or -1 for unlimited.")
80
+ end
81
+ end
73
82
  @coders = []
74
83
 
75
84
  @dispatch_cache = Hash.new do |h,klass|
@@ -156,7 +165,7 @@ module Psych
156
165
  end
157
166
 
158
167
  def visit_Psych_Omap o
159
- seq = @emitter.start_sequence(nil, '!omap', false, Nodes::Sequence::BLOCK)
168
+ seq = @emitter.start_sequence(nil, 'tag:yaml.org,2002:omap', false, Nodes::Sequence::BLOCK)
160
169
  register(o, seq)
161
170
 
162
171
  o.each { |k,v| visit_Hash k => v }
@@ -305,7 +314,7 @@ module Psych
305
314
  tag = nil
306
315
 
307
316
  if binary?(o)
308
- o = [o].pack('m').chomp
317
+ o = [o].pack('m0')
309
318
  tag = '!binary' # FIXME: change to below when syck is removed
310
319
  #tag = 'tag:yaml.org,2002:binary'
311
320
  style = Nodes::Scalar::LITERAL
@@ -322,7 +331,7 @@ module Psych
322
331
  style = Nodes::Scalar::FOLDED
323
332
  elsif o =~ /^[^[:word:]][^"]*$/
324
333
  style = Nodes::Scalar::DOUBLE_QUOTED
325
- elsif not String === @ss.tokenize(o)
334
+ elsif not String === @ss.tokenize(o) or /\A0[0-7]*[89]/ =~ o
326
335
  style = Nodes::Scalar::SINGLE_QUOTED
327
336
  end
328
337
 
@@ -510,27 +519,11 @@ module Psych
510
519
  def dump_list o
511
520
  end
512
521
 
513
- # '%:z' was no defined until 1.9.3
514
- if RUBY_VERSION < '1.9.3'
515
- def format_time time
516
- formatted = time.strftime("%Y-%m-%d %H:%M:%S.%9N")
517
-
518
- if time.utc?
519
- formatted += " Z"
520
- else
521
- zone = time.strftime('%z')
522
- formatted += " #{zone[0,3]}:#{zone[3,5]}"
523
- end
524
-
525
- formatted
526
- end
527
- else
528
- def format_time time
529
- if time.utc?
530
- time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
531
- else
532
- time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
533
- end
522
+ def format_time time
523
+ if time.utc?
524
+ time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
525
+ else
526
+ time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
534
527
  end
535
528
  end
536
529
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require 'psych/visitors/visitor'
2
3
  require 'psych/visitors/to_ruby'
3
4
  require 'psych/visitors/emitter'
data/lib/psych/y.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  module Kernel
2
3
  ###
3
4
  # An alias for Psych.dump_stream meant to be used with IRB.
data/lib/psych.rb CHANGED
@@ -1,4 +1,11 @@
1
- require 'psych.so'
1
+ # frozen_string_literal: false
2
+ case RUBY_ENGINE
3
+ when 'jruby'
4
+ require 'psych_jars'
5
+ org.jruby.ext.psych.PsychLibrary.new.load(JRuby.runtime, false)
6
+ else
7
+ require 'psych.so'
8
+ end
2
9
  require 'psych/nodes'
3
10
  require 'psych/streaming'
4
11
  require 'psych/visitors'
@@ -217,11 +224,13 @@ require 'psych/class_loader'
217
224
 
218
225
  module Psych
219
226
  # The version is Psych you're using
220
- VERSION = '2.0.13'
227
+ VERSION = '2.1.0'
221
228
 
222
229
  # The version of libyaml Psych is using
223
230
  LIBYAML_VERSION = Psych.libyaml_version.join '.'
224
231
 
232
+ FALLBACK = Struct.new :to_ruby # :nodoc:
233
+
225
234
  ###
226
235
  # Load +yaml+ in to a Ruby data structure. If multiple documents are
227
236
  # provided, the object contained in the first document will be returned.
@@ -241,8 +250,8 @@ module Psych
241
250
  # ex.file # => 'file.txt'
242
251
  # ex.message # => "(file.txt): found character that cannot start any token"
243
252
  # end
244
- def self.load yaml, filename = nil
245
- result = parse(yaml, filename)
253
+ def self.load yaml, filename = nil, fallback = false
254
+ result = parse(yaml, filename, fallback)
246
255
  result ? result.to_ruby : result
247
256
  end
248
257
 
@@ -314,11 +323,11 @@ module Psych
314
323
  # end
315
324
  #
316
325
  # See Psych::Nodes for more information about YAML AST.
317
- def self.parse yaml, filename = nil
326
+ def self.parse yaml, filename = nil, fallback = false
318
327
  parse_stream(yaml, filename) do |node|
319
328
  return node
320
329
  end
321
- false
330
+ fallback
322
331
  end
323
332
 
324
333
  ###
@@ -459,9 +468,12 @@ module Psych
459
468
 
460
469
  ###
461
470
  # Load the document contained in +filename+. Returns the yaml contained in
462
- # +filename+ as a Ruby object
463
- def self.load_file filename
464
- File.open(filename, 'r:bom|utf-8') { |f| self.load f, filename }
471
+ # +filename+ as a Ruby object, or if the file is empty, it returns
472
+ # the specified default return value, which defaults to an empty Hash
473
+ def self.load_file filename, fallback = false
474
+ File.open(filename, 'r:bom|utf-8') { |f|
475
+ self.load f, filename, FALLBACK.new(fallback)
476
+ }
465
477
  end
466
478
 
467
479
  # :stopdoc:
data/lib/psych_jars.rb ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: false
2
+ require 'psych/versions'
3
+ require 'psych.jar'
4
+
5
+ require 'jar-dependencies'
6
+ require_jar('org.yaml', 'snakeyaml', Psych::DEFAULT_SNAKEYAML_VERSION)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require 'psych/helper'
2
3
  require 'psych/handlers/recorder'
3
4
 
data/test/psych/helper.rb CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: false
1
2
  require 'minitest/autorun'
2
3
  require 'stringio'
3
4
  require 'tempfile'
4
5
  require 'date'
6
+
5
7
  require 'psych'
6
8
 
7
9
  module Psych
@@ -90,7 +92,7 @@ module Psych
90
92
  end
91
93
  end
92
94
 
93
- # backport so that tests will run on 1.9 and 2.0.0
95
+ # backport so that tests will run on 2.0.0
94
96
  unless Tempfile.respond_to? :create
95
97
  def Tempfile.create(basename, *rest)
96
98
  tmpfile = nil
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require 'psych/helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require 'psych/helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  class ObjectWithInstanceVariables
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
  require 'date'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: false
2
3
 
3
4
  require_relative 'helper'
4
5
 
@@ -89,5 +90,22 @@ module Psych
89
90
  @emitter.start_sequence(nil, nil, true, :foo)
90
91
  end
91
92
  end
93
+
94
+ def test_resizing_tags
95
+ @emitter.start_stream Psych::Nodes::Stream::UTF8
96
+
97
+ tags = []
98
+ version = [1,1]
99
+ obj = Object.new
100
+ obj.instance_variable_set(:@tags, tags)
101
+ def obj.to_str
102
+ (1..10).map{|x| @tags.push(["AAAA","BBBB"])}
103
+ return "x"
104
+ end
105
+
106
+ tags.push([obj, "tag:TALOS"])
107
+ @emitter.start_document(version, tags, 0)
108
+ assert(true)
109
+ end
92
110
  end
93
111
  end
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: false
2
3
 
3
4
  require_relative 'helper'
4
5
 
@@ -249,6 +250,15 @@ module Psych
249
250
  assert_encodings @utf8, @handler.strings
250
251
  end
251
252
 
253
+ def test_dump_non_ascii_string_to_file
254
+ Tempfile.create(['utf8', 'yml'], :encoding => 'UTF-8') do |t|
255
+ h = {'one' => 'いち'}
256
+ Psych.dump(h, t)
257
+ t.close
258
+ assert_equal h, Psych.load_file(t.path)
259
+ end
260
+ end
261
+
252
262
  private
253
263
  def assert_encodings encoding, strings
254
264
  strings.each do |str|
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
  require 'bigdecimal'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: false
2
3
 
3
4
  require_relative 'helper'
4
5
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  require 'stringio'
@@ -8,7 +9,17 @@ class TestPsych < Psych::TestCase
8
9
  Psych.domain_types.clear
9
10
  end
10
11
 
11
- def test_line_width
12
+ def test_line_width_invalid
13
+ assert_raises(ArgumentError) { Psych.dump('x', { :line_width => -2 }) }
14
+ end
15
+
16
+ def test_line_width_no_limit
17
+ data = { 'a' => 'a b' * 50}
18
+ expected = "---\na: #{'a b' * 50}\n"
19
+ assert_equal(expected, Psych.dump(data, { :line_width => -1 }))
20
+ end
21
+
22
+ def test_line_width_limit
12
23
  yml = Psych.dump('123456 7', { :line_width => 5 })
13
24
  assert_match(/^\s*7/, yml)
14
25
  end
@@ -133,6 +144,11 @@ class TestPsych < Psych::TestCase
133
144
  }
134
145
  end
135
146
 
147
+ def test_load_file_with_fallback
148
+ t = Tempfile.create(['empty', 'yml'])
149
+ assert_equal Hash.new, Psych.load_file(t.path, Hash.new)
150
+ end
151
+
136
152
  def test_parse_file
137
153
  Tempfile.create(['yikes', 'yml']) {|t|
138
154
  t.binmode
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require 'psych/helper'
2
3
 
3
4
  module Psych
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: false
2
3
 
3
4
  require_relative 'helper'
4
5
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
  require 'date'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,4 +1,5 @@
1
1
  # encoding: UTF-8
2
+ # frozen_string_literal: false
2
3
  require_relative 'helper'
3
4
 
4
5
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  class PsychStructWithIvar < Struct.new(:foo)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
 
3
4
  module Psych
@@ -1,4 +1,5 @@
1
1
  # -*- coding: us-ascii; mode: ruby; ruby-indent-level: 4; tab-width: 4 -*-
2
+ # frozen_string_literal: false
2
3
  # vim:sw=4:ts=4
3
4
  # $Id$
4
5
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
  require 'tmpdir'
3
4
 
@@ -77,7 +78,6 @@ module Psych
77
78
  # end
78
79
 
79
80
  def test_key
80
- skip 'only on ruby 2.0.0' if RUBY_VERSION < '2.0.0'
81
81
  @yamldbm['a'] = 'b'
82
82
  @yamldbm['c'] = 'd'
83
83
  assert_equal 'a', @yamldbm.key('b')
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require_relative 'helper'
2
3
  require 'yaml/store'
3
4
  require 'tmpdir'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require 'psych/helper'
2
3
 
3
4
  module Psych
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require 'psych/helper'
2
3
 
3
4
  module Psych
@@ -1,4 +1,5 @@
1
1
  # coding: US-ASCII
2
+ # frozen_string_literal: false
2
3
  require 'psych/helper'
3
4
 
4
5
  module Psych
@@ -166,16 +167,14 @@ description:
166
167
  assert_equal Complex(1,2), mapping.to_ruby
167
168
  end
168
169
 
169
- if RUBY_VERSION >= '1.9'
170
- def test_complex_string
171
- node = Nodes::Scalar.new '3+4i', nil, "!ruby/object:Complex"
172
- assert_equal Complex(3, 4), node.to_ruby
173
- end
170
+ def test_complex_string
171
+ node = Nodes::Scalar.new '3+4i', nil, "!ruby/object:Complex"
172
+ assert_equal Complex(3, 4), node.to_ruby
173
+ end
174
174
 
175
- def test_rational_string
176
- node = Nodes::Scalar.new '1/2', nil, "!ruby/object:Rational"
177
- assert_equal Rational(1, 2), node.to_ruby
178
- end
175
+ def test_rational_string
176
+ node = Nodes::Scalar.new '1/2', nil, "!ruby/object:Rational"
177
+ assert_equal Rational(1, 2), node.to_ruby
179
178
  end
180
179
 
181
180
  def test_range_string
@@ -321,6 +320,13 @@ description:
321
320
  assert_equal %w{ foo foo }, list
322
321
  assert_equal list[0].object_id, list[1].object_id
323
322
  end
323
+
324
+ def test_mapping_with_str_tag
325
+ mapping = Nodes::Mapping.new(nil, '!strawberry')
326
+ mapping.children << Nodes::Scalar.new('foo')
327
+ mapping.children << Nodes::Scalar.new('bar')
328
+ assert_equal({'foo' => 'bar'}, mapping.to_ruby)
329
+ end
324
330
  end
325
331
  end
326
332
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: false
1
2
  require 'psych/helper'
2
3
 
3
4
  module Psych
@@ -155,6 +156,12 @@ module Psych
155
156
  assert_equal(-1, Psych.load(Psych.dump(-1 / 0.0)).infinite?)
156
157
  end
157
158
 
159
+ def test_string
160
+ assert_match(/'017'/, Psych.dump({'a' => '017'}))
161
+ assert_match(/'019'/, Psych.dump({'a' => '019'}))
162
+ assert_match(/'01818'/, Psych.dump({'a' => '01818'}))
163
+ end
164
+
158
165
  # http://yaml.org/type/null.html
159
166
  def test_nil
160
167
  assert_cycle nil