mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
parent
ae299cc9cd
commit
451e1dcf31
1 changed files with 11 additions and 0 deletions
|
@ -89,6 +89,7 @@ class TestPsych < Psych::TestCase
|
|||
things = [22, "foo \n", {}]
|
||||
stream = Psych.dump_stream(*things)
|
||||
assert_equal things, Psych.load_stream(stream)
|
||||
assert_equal things, Psych.safe_load_stream(stream)
|
||||
end
|
||||
|
||||
def test_dump_file
|
||||
|
@ -119,6 +120,8 @@ class TestPsych < Psych::TestCase
|
|||
def test_load_stream
|
||||
docs = Psych.load_stream("--- foo\n...\n--- bar\n...")
|
||||
assert_equal %w{ foo bar }, docs
|
||||
safe_docs = Psych.safe_load_stream("--- foo\n...\n--- bar\n...")
|
||||
assert_equal %w{ foo bar }, safe_docs
|
||||
end
|
||||
|
||||
def test_load_stream_freeze
|
||||
|
@ -138,10 +141,18 @@ class TestPsych < Psych::TestCase
|
|||
assert_equal [], Psych.load_stream("")
|
||||
end
|
||||
|
||||
def test_safe_load_stream_default_fallback
|
||||
assert_equal [], Psych.safe_load_stream("")
|
||||
end
|
||||
|
||||
def test_load_stream_raises_on_bad_input
|
||||
assert_raise(Psych::SyntaxError) { Psych.load_stream("--- `") }
|
||||
end
|
||||
|
||||
def test_safe_load_stream_raises_on_bad_input
|
||||
assert_raise(Psych::SyntaxError) { Psych.safe_load_stream("--- `") }
|
||||
end
|
||||
|
||||
def test_parse_stream
|
||||
docs = Psych.parse_stream("--- foo\n...\n--- bar\n...")
|
||||
assert_equal(%w[foo bar], docs.children.map(&:transform))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue