psych 2.1.0-java → 2.1.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +14 -0
  3. data/Gemfile +3 -0
  4. data/Mavenfile +7 -0
  5. data/bin/console +7 -0
  6. data/bin/setup +6 -0
  7. data/ext/java/PsychEmitter.java +345 -0
  8. data/ext/java/PsychLibrary.java +93 -0
  9. data/ext/java/PsychParser.java +399 -0
  10. data/ext/java/PsychToRuby.java +79 -0
  11. data/ext/java/PsychYamlTree.java +55 -0
  12. data/ext/psych/.gitignore +11 -0
  13. data/lib/psych.rb +2 -2
  14. data/lib/psych/visitors/to_ruby.rb +2 -2
  15. data/psych.gemspec +39 -0
  16. metadata +19 -53
  17. data/test/psych/handlers/test_recorder.rb +0 -26
  18. data/test/psych/helper.rb +0 -122
  19. data/test/psych/json/test_stream.rb +0 -110
  20. data/test/psych/nodes/test_enumerable.rb +0 -44
  21. data/test/psych/test_alias_and_anchor.rb +0 -97
  22. data/test/psych/test_array.rb +0 -58
  23. data/test/psych/test_boolean.rb +0 -37
  24. data/test/psych/test_class.rb +0 -37
  25. data/test/psych/test_coder.rb +0 -207
  26. data/test/psych/test_date_time.rb +0 -39
  27. data/test/psych/test_deprecated.rb +0 -215
  28. data/test/psych/test_document.rb +0 -47
  29. data/test/psych/test_emitter.rb +0 -112
  30. data/test/psych/test_encoding.rb +0 -269
  31. data/test/psych/test_exception.rb +0 -158
  32. data/test/psych/test_hash.rb +0 -95
  33. data/test/psych/test_json_tree.rb +0 -66
  34. data/test/psych/test_merge_keys.rb +0 -181
  35. data/test/psych/test_nil.rb +0 -19
  36. data/test/psych/test_null.rb +0 -20
  37. data/test/psych/test_numeric.rb +0 -46
  38. data/test/psych/test_object.rb +0 -45
  39. data/test/psych/test_object_references.rb +0 -72
  40. data/test/psych/test_omap.rb +0 -76
  41. data/test/psych/test_parser.rb +0 -340
  42. data/test/psych/test_psych.rb +0 -184
  43. data/test/psych/test_safe_load.rb +0 -98
  44. data/test/psych/test_scalar.rb +0 -12
  45. data/test/psych/test_scalar_scanner.rb +0 -111
  46. data/test/psych/test_serialize_subclasses.rb +0 -39
  47. data/test/psych/test_set.rb +0 -50
  48. data/test/psych/test_stream.rb +0 -94
  49. data/test/psych/test_string.rb +0 -231
  50. data/test/psych/test_struct.rb +0 -50
  51. data/test/psych/test_symbol.rb +0 -26
  52. data/test/psych/test_tainted.rb +0 -131
  53. data/test/psych/test_to_yaml_properties.rb +0 -64
  54. data/test/psych/test_tree_builder.rb +0 -80
  55. data/test/psych/test_yaml.rb +0 -1293
  56. data/test/psych/test_yamldbm.rb +0 -193
  57. data/test/psych/test_yamlstore.rb +0 -86
  58. data/test/psych/visitors/test_depth_first.rb +0 -50
  59. data/test/psych/visitors/test_emitter.rb +0 -145
  60. data/test/psych/visitors/test_to_ruby.rb +0 -332
  61. data/test/psych/visitors/test_yaml_tree.rb +0 -180
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: false
2
- require_relative 'helper'
3
- require 'date'
4
-
5
- module Psych
6
- class TestDateTime < TestCase
7
- def test_negative_year
8
- time = Time.utc -1, 12, 16
9
- assert_cycle time
10
- end
11
-
12
- def test_new_datetime
13
- assert_cycle DateTime.new
14
- end
15
-
16
- def test_invalid_date
17
- assert_cycle "2013-10-31T10:40:07-000000000000033"
18
- end
19
-
20
- def test_string_tag
21
- dt = DateTime.now
22
- yaml = Psych.dump dt
23
- assert_match(/DateTime/, yaml)
24
- end
25
-
26
- def test_round_trip
27
- dt = DateTime.now
28
- assert_cycle dt
29
- end
30
-
31
- def test_alias_with_time
32
- t = Time.now
33
- h = {:a => t, :b => t}
34
- yaml = Psych.dump h
35
- assert_match('&', yaml)
36
- assert_match('*', yaml)
37
- end
38
- end
39
- end
@@ -1,215 +0,0 @@
1
- # frozen_string_literal: false
2
- require_relative 'helper'
3
-
4
- module Psych
5
- class TestDeprecated < TestCase
6
- def teardown
7
- $VERBOSE = @orig_verbose
8
- Psych.domain_types.clear
9
- end
10
-
11
- class QuickEmitter
12
- attr_reader :name
13
- attr_reader :value
14
-
15
- def initialize
16
- @name = 'hello!!'
17
- @value = 'Friday!'
18
- end
19
-
20
- def to_yaml opts = {}
21
- Psych.quick_emit object_id, opts do |out|
22
- out.map taguri, to_yaml_style do |map|
23
- map.add 'name', @name
24
- map.add 'value', nil
25
- end
26
- end
27
- end
28
- end
29
-
30
- def setup
31
- @qe = QuickEmitter.new
32
- @orig_verbose, $VERBOSE = $VERBOSE, false
33
- end
34
-
35
- def test_quick_emit
36
- qe2 = Psych.load @qe.to_yaml
37
- assert_equal @qe.name, qe2.name
38
- assert_instance_of QuickEmitter, qe2
39
- assert_nil qe2.value
40
- end
41
-
42
- def test_recursive_quick_emit
43
- hash = { :qe => @qe }
44
- hash2 = Psych.load Psych.dump hash
45
- qe = hash2[:qe]
46
-
47
- assert_equal @qe.name, qe.name
48
- assert_instance_of QuickEmitter, qe
49
- assert_nil qe.value
50
- end
51
-
52
- class QuickEmitterEncodeWith
53
- attr_reader :name
54
- attr_reader :value
55
-
56
- def initialize
57
- @name = 'hello!!'
58
- @value = 'Friday!'
59
- end
60
-
61
- def encode_with coder
62
- coder.map do |map|
63
- map.add 'name', @name
64
- map.add 'value', nil
65
- end
66
- end
67
-
68
- def to_yaml opts = {}
69
- raise
70
- end
71
- end
72
-
73
- ###
74
- # An object that defines both to_yaml and encode_with should only call
75
- # encode_with.
76
- def test_recursive_quick_emit_encode_with
77
- qeew = QuickEmitterEncodeWith.new
78
- hash = { :qe => qeew }
79
- hash2 = Psych.load Psych.dump hash
80
- qe = hash2[:qe]
81
-
82
- assert_equal qeew.name, qe.name
83
- assert_instance_of QuickEmitterEncodeWith, qe
84
- assert_nil qe.value
85
- end
86
-
87
- class YamlInit
88
- attr_reader :name
89
- attr_reader :value
90
-
91
- def initialize
92
- @name = 'hello!!'
93
- @value = 'Friday!'
94
- end
95
-
96
- def yaml_initialize tag, vals
97
- vals.each { |ivar, val| instance_variable_set "@#{ivar}", 'TGIF!' }
98
- end
99
- end
100
-
101
- def test_yaml_initialize
102
- hash = { :yi => YamlInit.new }
103
- hash2 = Psych.load Psych.dump hash
104
- yi = hash2[:yi]
105
-
106
- assert_equal 'TGIF!', yi.name
107
- assert_equal 'TGIF!', yi.value
108
- assert_instance_of YamlInit, yi
109
- end
110
-
111
- class YamlInitAndInitWith
112
- attr_reader :name
113
- attr_reader :value
114
-
115
- def initialize
116
- @name = 'shaners'
117
- @value = 'Friday!'
118
- end
119
-
120
- def init_with coder
121
- coder.map.each { |ivar, val| instance_variable_set "@#{ivar}", 'TGIF!' }
122
- end
123
-
124
- def yaml_initialize tag, vals
125
- raise
126
- end
127
- end
128
-
129
- ###
130
- # An object that implements both yaml_initialize and init_with should not
131
- # receive the yaml_initialize call.
132
- def test_yaml_initialize_and_init_with
133
- hash = { :yi => YamlInitAndInitWith.new }
134
- hash2 = Psych.load Psych.dump hash
135
- yi = hash2[:yi]
136
-
137
- assert_equal 'TGIF!', yi.name
138
- assert_equal 'TGIF!', yi.value
139
- assert_instance_of YamlInitAndInitWith, yi
140
- end
141
-
142
- def test_coder_scalar
143
- coder = Psych::Coder.new 'foo'
144
- coder.scalar('tag', 'some string', :plain)
145
- assert_equal 'tag', coder.tag
146
- assert_equal 'some string', coder.scalar
147
- assert_equal :scalar, coder.type
148
- end
149
-
150
- class YamlAs
151
- TestCase.suppress_warning do
152
- psych_yaml_as 'helloworld' # this should be yaml_as but to avoid syck
153
- end
154
- end
155
-
156
- def test_yaml_as
157
- assert_match(/helloworld/, Psych.dump(YamlAs.new))
158
- end
159
-
160
- def test_ruby_type
161
- types = []
162
- appender = lambda { |*args| types << args }
163
-
164
- Psych.add_ruby_type('foo', &appender)
165
- Psych.load <<-eoyml
166
- - !ruby.yaml.org,2002/foo bar
167
- eoyml
168
-
169
- assert_equal [["tag:ruby.yaml.org,2002:foo", "bar"]], types
170
- end
171
-
172
- def test_detect_implicit
173
- assert_equal '', Psych.detect_implicit(nil)
174
- assert_equal '', Psych.detect_implicit(Object.new)
175
- assert_equal '', Psych.detect_implicit(1.2)
176
- assert_equal 'null', Psych.detect_implicit('')
177
- assert_equal 'string', Psych.detect_implicit('foo')
178
- end
179
-
180
- def test_private_type
181
- types = []
182
- Psych.add_private_type('foo') { |*args| types << args }
183
- Psych.load <<-eoyml
184
- - !x-private:foo bar
185
- eoyml
186
-
187
- assert_equal [["x-private:foo", "bar"]], types
188
- end
189
-
190
- def test_tagurize
191
- assert_nil Psych.tagurize nil
192
- assert_equal Psych, Psych.tagurize(Psych)
193
- assert_equal 'tag:yaml.org,2002:foo', Psych.tagurize('foo')
194
- end
195
-
196
- def test_read_type_class
197
- things = Psych.read_type_class 'tag:yaml.org,2002:int:Psych::TestDeprecated::QuickEmitter', Object
198
- assert_equal 'int', things.first
199
- assert_equal Psych::TestDeprecated::QuickEmitter, things.last
200
- end
201
-
202
- def test_read_type_class_no_class
203
- things = Psych.read_type_class 'tag:yaml.org,2002:int', Object
204
- assert_equal 'int', things.first
205
- assert_equal Object, things.last
206
- end
207
-
208
- def test_object_maker
209
- thing = Psych.object_maker(Object, { 'a' => 'b', 'c' => 'd' })
210
- assert_instance_of(Object, thing)
211
- assert_equal 'b', thing.instance_variable_get(:@a)
212
- assert_equal 'd', thing.instance_variable_get(:@c)
213
- end
214
- end
215
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: false
2
- require_relative 'helper'
3
-
4
- module Psych
5
- class TestDocument < TestCase
6
- def setup
7
- super
8
- @stream = Psych.parse_stream(<<-eoyml)
9
- %YAML 1.1
10
- %TAG ! tag:tenderlovemaking.com,2009:
11
- --- !fun
12
- eoyml
13
- @doc = @stream.children.first
14
- end
15
-
16
- def test_parse_tag
17
- assert_equal([['!', 'tag:tenderlovemaking.com,2009:']],
18
- @doc.tag_directives)
19
- end
20
-
21
- def test_emit_tag
22
- assert_match('%TAG ! tag:tenderlovemaking.com,2009:', @stream.yaml)
23
- end
24
-
25
- def test_emit_multitag
26
- @doc.tag_directives << ['!!', 'foo.com,2009:']
27
- yaml = @stream.yaml
28
- assert_match('%TAG ! tag:tenderlovemaking.com,2009:', yaml)
29
- assert_match('%TAG !! foo.com,2009:', yaml)
30
- end
31
-
32
- def test_emit_bad_tag
33
- assert_raises(RuntimeError) do
34
- @doc.tag_directives = [['!']]
35
- @stream.yaml
36
- end
37
- end
38
-
39
- def test_parse_version
40
- assert_equal([1,1], @doc.version)
41
- end
42
-
43
- def test_emit_version
44
- assert_match('%YAML 1.1', @stream.yaml)
45
- end
46
- end
47
- end
@@ -1,112 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # frozen_string_literal: false
3
-
4
- require_relative 'helper'
5
-
6
- module Psych
7
- class TestEmitter < TestCase
8
- def setup
9
- super
10
- @out = StringIO.new('')
11
- @emitter = Psych::Emitter.new @out
12
- end
13
-
14
- def test_line_width
15
- @emitter.line_width = 10
16
- assert_equal 10, @emitter.line_width
17
- end
18
-
19
- def test_set_canonical
20
- @emitter.canonical = true
21
- assert_equal true, @emitter.canonical
22
-
23
- @emitter.canonical = false
24
- assert_equal false, @emitter.canonical
25
- end
26
-
27
- def test_indentation_set
28
- assert_equal 2, @emitter.indentation
29
- @emitter.indentation = 5
30
- assert_equal 5, @emitter.indentation
31
- end
32
-
33
- def test_emit_utf_8
34
- @emitter.start_stream Psych::Nodes::Stream::UTF8
35
- @emitter.start_document [], [], false
36
- @emitter.scalar '日本語', nil, nil, false, true, 1
37
- @emitter.end_document true
38
- @emitter.end_stream
39
- assert_match('日本語', @out.string)
40
- end
41
-
42
- def test_start_stream_arg_error
43
- assert_raises(TypeError) do
44
- @emitter.start_stream 'asdfasdf'
45
- end
46
- end
47
-
48
- def test_start_doc_arg_error
49
- @emitter.start_stream Psych::Nodes::Stream::UTF8
50
-
51
- [
52
- [nil, [], false],
53
- [[nil, nil], [], false],
54
- [[], 'foo', false],
55
- [[], ['foo'], false],
56
- [[], [nil,nil], false],
57
- [[1,1], [[nil, "tag:TALOS"]], 0],
58
- ].each do |args|
59
- assert_raises(TypeError) do
60
- @emitter.start_document(*args)
61
- end
62
- end
63
- end
64
-
65
- def test_scalar_arg_error
66
- @emitter.start_stream Psych::Nodes::Stream::UTF8
67
- @emitter.start_document [], [], false
68
-
69
- [
70
- [:foo, nil, nil, false, true, 1],
71
- ['foo', Object.new, nil, false, true, 1],
72
- ['foo', nil, Object.new, false, true, 1],
73
- ['foo', nil, nil, false, true, :foo],
74
- [nil, nil, nil, false, true, 1],
75
- ].each do |args|
76
- assert_raises(TypeError) do
77
- @emitter.scalar(*args)
78
- end
79
- end
80
- end
81
-
82
- def test_start_sequence_arg_error
83
- @emitter.start_stream Psych::Nodes::Stream::UTF8
84
- @emitter.start_document [], [], false
85
-
86
- assert_raises(TypeError) do
87
- @emitter.start_sequence(nil, Object.new, true, 1)
88
- end
89
-
90
- assert_raises(TypeError) do
91
- @emitter.start_sequence(nil, nil, true, :foo)
92
- end
93
- end
94
-
95
- def test_resizing_tags
96
- @emitter.start_stream Psych::Nodes::Stream::UTF8
97
-
98
- tags = []
99
- version = [1,1]
100
- obj = Object.new
101
- obj.instance_variable_set(:@tags, tags)
102
- def obj.to_str
103
- (1..10).map{|x| @tags.push(["AAAA","BBBB"])}
104
- return "x"
105
- end
106
-
107
- tags.push([obj, "tag:TALOS"])
108
- @emitter.start_document(version, tags, 0)
109
- assert(true)
110
- end
111
- end
112
- end
@@ -1,269 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # frozen_string_literal: false
3
-
4
- require_relative 'helper'
5
-
6
- module Psych
7
- class TestEncoding < TestCase
8
- class EncodingCatcher < Handler
9
- attr_reader :strings
10
- def initialize
11
- @strings = []
12
- end
13
-
14
- (Handler.instance_methods(true) -
15
- Object.instance_methods).each do |m|
16
- class_eval %{
17
- def #{m} *args
18
- @strings += args.flatten.find_all { |a|
19
- String === a
20
- }
21
- end
22
- }
23
- end
24
- end
25
-
26
- def setup
27
- super
28
- @buffer = StringIO.new
29
- @handler = EncodingCatcher.new
30
- @parser = Psych::Parser.new @handler
31
- @utf8 = Encoding.find('UTF-8')
32
- @emitter = Psych::Emitter.new @buffer
33
- end
34
-
35
- def test_dump_load_encoding_object
36
- assert_cycle Encoding::US_ASCII
37
- assert_cycle Encoding::UTF_8
38
- end
39
-
40
- def test_transcode_shiftjis
41
- str = "こんにちは!"
42
- loaded = Psych.load("--- こんにちは!".encode('SHIFT_JIS'))
43
- assert_equal str, loaded
44
- end
45
-
46
- def test_transcode_utf16le
47
- str = "こんにちは!"
48
- loaded = Psych.load("--- こんにちは!".encode('UTF-16LE'))
49
- assert_equal str, loaded
50
- end
51
-
52
- def test_transcode_utf16be
53
- str = "こんにちは!"
54
- loaded = Psych.load("--- こんにちは!".encode('UTF-16BE'))
55
- assert_equal str, loaded
56
- end
57
-
58
- def test_io_shiftjis
59
- Tempfile.create(['shiftjis', 'yml'], :encoding => 'SHIFT_JIS') {|t|
60
- t.write '--- こんにちは!'
61
- t.close
62
-
63
- # If the external encoding isn't utf8, utf16le, or utf16be, we cannot
64
- # process the file.
65
- File.open(t.path, 'r', :encoding => 'SHIFT_JIS') do |f|
66
- assert_raises Psych::SyntaxError do
67
- Psych.load(f)
68
- end
69
- end
70
- }
71
- end
72
-
73
- def test_io_utf16le
74
- Tempfile.create(['utf16le', 'yml']) {|t|
75
- t.binmode
76
- t.write '--- こんにちは!'.encode('UTF-16LE')
77
- t.close
78
-
79
- File.open(t.path, 'rb', :encoding => 'UTF-16LE') do |f|
80
- assert_equal "こんにちは!", Psych.load(f)
81
- end
82
- }
83
- end
84
-
85
- def test_io_utf16be
86
- Tempfile.create(['utf16be', 'yml']) {|t|
87
- t.binmode
88
- t.write '--- こんにちは!'.encode('UTF-16BE')
89
- t.close
90
-
91
- File.open(t.path, 'rb', :encoding => 'UTF-16BE') do |f|
92
- assert_equal "こんにちは!", Psych.load(f)
93
- end
94
- }
95
- end
96
-
97
- def test_io_utf8
98
- Tempfile.create(['utf8', 'yml']) {|t|
99
- t.binmode
100
- t.write '--- こんにちは!'.encode('UTF-8')
101
- t.close
102
-
103
- File.open(t.path, 'rb', :encoding => 'UTF-8') do |f|
104
- assert_equal "こんにちは!", Psych.load(f)
105
- end
106
- }
107
- end
108
-
109
- def test_emit_alias
110
- @emitter.start_stream Psych::Parser::UTF8
111
- @emitter.start_document [], [], true
112
- e = assert_raises(RuntimeError) do
113
- @emitter.alias 'ドラえもん'.encode('EUC-JP')
114
- end
115
- assert_match(/alias value/, e.message)
116
- end
117
-
118
- def test_to_yaml_is_valid
119
- with_default_external(Encoding::US_ASCII) do
120
- with_default_internal(nil) do
121
- s = "こんにちは!"
122
- # If no encoding is specified, use UTF-8
123
- assert_equal Encoding::UTF_8, Psych.dump(s).encoding
124
- assert_equal s, Psych.load(Psych.dump(s))
125
- end
126
- end
127
- end
128
-
129
- def test_start_mapping
130
- foo = 'foo'
131
- bar = 'バー'
132
-
133
- @emitter.start_stream Psych::Parser::UTF8
134
- @emitter.start_document [], [], true
135
- @emitter.start_mapping(
136
- foo.encode('Shift_JIS'),
137
- bar.encode('UTF-16LE'),
138
- false, Nodes::Sequence::ANY)
139
- @emitter.end_mapping
140
- @emitter.end_document false
141
- @emitter.end_stream
142
-
143
- @parser.parse @buffer.string
144
- assert_encodings @utf8, @handler.strings
145
- assert_equal [foo, bar], @handler.strings
146
- end
147
-
148
- def test_start_sequence
149
- foo = 'foo'
150
- bar = 'バー'
151
-
152
- @emitter.start_stream Psych::Parser::UTF8
153
- @emitter.start_document [], [], true
154
- @emitter.start_sequence(
155
- foo.encode('Shift_JIS'),
156
- bar.encode('UTF-16LE'),
157
- false, Nodes::Sequence::ANY)
158
- @emitter.end_sequence
159
- @emitter.end_document false
160
- @emitter.end_stream
161
-
162
- @parser.parse @buffer.string
163
- assert_encodings @utf8, @handler.strings
164
- assert_equal [foo, bar], @handler.strings
165
- end
166
-
167
- def test_doc_tag_encoding
168
- key = '鍵'
169
- @emitter.start_stream Psych::Parser::UTF8
170
- @emitter.start_document(
171
- [1, 1],
172
- [['!'.encode('EUC-JP'), key.encode('EUC-JP')]],
173
- true
174
- )
175
- @emitter.scalar 'foo', nil, nil, true, false, Nodes::Scalar::ANY
176
- @emitter.end_document false
177
- @emitter.end_stream
178
-
179
- @parser.parse @buffer.string
180
- assert_encodings @utf8, @handler.strings
181
- assert_equal key, @handler.strings[1]
182
- end
183
-
184
- def test_emitter_encoding
185
- str = "壁に耳あり、障子に目あり"
186
- thing = Psych.load Psych.dump str.encode('EUC-JP')
187
- assert_equal str, thing
188
- end
189
-
190
- def test_default_internal
191
- with_default_internal(Encoding::EUC_JP) do
192
- str = "壁に耳あり、障子に目あり"
193
- assert_equal @utf8, str.encoding
194
-
195
- @parser.parse str
196
- assert_encodings Encoding::EUC_JP, @handler.strings
197
- assert_equal str, @handler.strings.first.encode('UTF-8')
198
- end
199
- end
200
-
201
- def test_scalar
202
- @parser.parse("--- a")
203
- assert_encodings @utf8, @handler.strings
204
- end
205
-
206
- def test_alias
207
- @parser.parse(<<-eoyml)
208
- %YAML 1.1
209
- ---
210
- !!seq [
211
- !!str "Without properties",
212
- &A !!str "Anchored",
213
- !!str "Tagged",
214
- *A,
215
- !!str "",
216
- ]
217
- eoyml
218
- assert_encodings @utf8, @handler.strings
219
- end
220
-
221
- def test_list_anchor
222
- list = %w{ a b }
223
- list << list
224
- @parser.parse(Psych.dump(list))
225
- assert_encodings @utf8, @handler.strings
226
- end
227
-
228
- def test_map_anchor
229
- h = {}
230
- h['a'] = h
231
- @parser.parse(Psych.dump(h))
232
- assert_encodings @utf8, @handler.strings
233
- end
234
-
235
- def test_map_tag
236
- @parser.parse(<<-eoyml)
237
- %YAML 1.1
238
- ---
239
- !!map { a : b }
240
- eoyml
241
- assert_encodings @utf8, @handler.strings
242
- end
243
-
244
- def test_doc_tag
245
- @parser.parse(<<-eoyml)
246
- %YAML 1.1
247
- %TAG ! tag:tenderlovemaking.com,2009:
248
- --- !fun
249
- eoyml
250
- assert_encodings @utf8, @handler.strings
251
- end
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
-
262
- private
263
- def assert_encodings encoding, strings
264
- strings.each do |str|
265
- assert_equal encoding, str.encoding, str
266
- end
267
- end
268
- end
269
- end