summaryrefslogtreecommitdiff
path: root/test/psych
diff options
context:
space:
mode:
Diffstat (limited to 'test/psych')
-rw-r--r--test/psych/helper.rb2
-rw-r--r--test/psych/test_psych.rb12
-rw-r--r--test/psych/test_yamldbm.rb1
-rw-r--r--test/psych/visitors/test_to_ruby.rb16
4 files changed, 19 insertions, 12 deletions
diff --git a/test/psych/helper.rb b/test/psych/helper.rb
index f28ac0f965..3bbb459320 100644
--- a/test/psych/helper.rb
+++ b/test/psych/helper.rb
@@ -91,7 +91,7 @@ module Psych
end
end
-# backport so that tests will run on 1.9 and 2.0.0
+# backport so that tests will run on 2.0.0
unless Tempfile.respond_to? :create
def Tempfile.create(basename, *rest)
tmpfile = nil
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb
index 8054bd6234..05a93438bc 100644
--- a/test/psych/test_psych.rb
+++ b/test/psych/test_psych.rb
@@ -8,7 +8,17 @@ class TestPsych < Psych::TestCase
Psych.domain_types.clear
end
- def test_line_width
+ def test_line_width_invalid
+ assert_raises(ArgumentError) { Psych.dump('x', { :line_width => -2 }) }
+ end
+
+ def test_line_width_no_limit
+ data = { 'a' => 'a b' * 50}
+ expected = "---\na: #{'a b' * 50}\n"
+ assert_equal(expected, Psych.dump(data, { :line_width => -1 }))
+ end
+
+ def test_line_width_limit
yml = Psych.dump('123456 7', { :line_width => 5 })
assert_match(/^\s*7/, yml)
end
diff --git a/test/psych/test_yamldbm.rb b/test/psych/test_yamldbm.rb
index 785365841e..62c88b753e 100644
--- a/test/psych/test_yamldbm.rb
+++ b/test/psych/test_yamldbm.rb
@@ -77,7 +77,6 @@ module Psych
# end
def test_key
- skip 'only on ruby 2.0.0' if RUBY_VERSION < '2.0.0'
@yamldbm['a'] = 'b'
@yamldbm['c'] = 'd'
assert_equal 'a', @yamldbm.key('b')
diff --git a/test/psych/visitors/test_to_ruby.rb b/test/psych/visitors/test_to_ruby.rb
index 5c6ba2b397..19e5365244 100644
--- a/test/psych/visitors/test_to_ruby.rb
+++ b/test/psych/visitors/test_to_ruby.rb
@@ -166,16 +166,14 @@ description:
assert_equal Complex(1,2), mapping.to_ruby
end
- if RUBY_VERSION >= '1.9'
- def test_complex_string
- node = Nodes::Scalar.new '3+4i', nil, "!ruby/object:Complex"
- assert_equal Complex(3, 4), node.to_ruby
- end
+ def test_complex_string
+ node = Nodes::Scalar.new '3+4i', nil, "!ruby/object:Complex"
+ assert_equal Complex(3, 4), node.to_ruby
+ end
- def test_rational_string
- node = Nodes::Scalar.new '1/2', nil, "!ruby/object:Rational"
- assert_equal Rational(1, 2), node.to_ruby
- end
+ def test_rational_string
+ node = Nodes::Scalar.new '1/2', nil, "!ruby/object:Rational"
+ assert_equal Rational(1, 2), node.to_ruby
end
def test_range_string