summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSHIBATA Hiroshi <hsbt@ruby-lang.org>2017-03-03 16:02:13 +0900
committerGitHub <noreply@github.com>2017-03-03 16:02:13 +0900
commit2f35f93c3574560dbbe50bd02c5fa3b7670f49fa (patch)
tree000c3900c1b11bc005095485b6b78d7679bb55e5
parente6a533eed532bbf9bf3fc01cf5fef216dd9114b6 (diff)
parentdd3f53f60dbcacda7e47e420374a9e7761a9dbb2 (diff)
downloadpsych-2f35f93c3574560dbbe50bd02c5fa3b7670f49fa.tar.gz
Merge pull request #310 from ruby/cleanup-warnings
Cleanup warnings
-rw-r--r--test/psych/helper.rb12
-rw-r--r--test/psych/test_array.rb4
-rw-r--r--test/psych/test_date_time.rb2
-rw-r--r--test/psych/test_scalar_scanner.rb6
-rw-r--r--test/psych/test_string.rb18
-rw-r--r--test/psych/visitors/test_yaml_tree.rb8
6 files changed, 28 insertions, 22 deletions
diff --git a/test/psych/helper.rb b/test/psych/helper.rb
index 498cdf8..0474cf1 100644
--- a/test/psych/helper.rb
+++ b/test/psych/helper.rb
@@ -70,9 +70,15 @@ module Psych
def assert_cycle( obj )
v = Visitors::YAMLTree.create
v << obj
- assert_equal(obj, Psych.load(v.tree.yaml))
- assert_equal( obj, Psych::load(Psych.dump(obj)))
- assert_equal( obj, Psych::load( obj.psych_to_yaml ) )
+ if obj.nil?
+ assert_nil Psych.load(v.tree.yaml)
+ assert_nil Psych::load(Psych.dump(obj))
+ assert_nil Psych::load(obj.psych_to_yaml)
+ else
+ assert_equal(obj, Psych.load(v.tree.yaml))
+ assert_equal(obj, Psych::load(Psych.dump(obj)))
+ assert_equal(obj, Psych::load(obj.psych_to_yaml))
+ end
end
#
diff --git a/test/psych/test_array.rb b/test/psych/test_array.rb
index f1e71fb..6306a04 100644
--- a/test/psych/test_array.rb
+++ b/test/psych/test_array.rb
@@ -16,7 +16,7 @@ module Psych
end
def test_another_subclass_with_attributes
- y = Y.new.tap {|y| y.val = 1}
+ y = Y.new.tap {|o| o.val = 1}
y << "foo" << "bar"
y = Psych.load Psych.dump y
@@ -36,7 +36,7 @@ module Psych
end
def test_subclass_with_attributes
- y = Psych.load Psych.dump Y.new.tap {|y| y.val = 1}
+ y = Psych.load Psych.dump Y.new.tap {|o| o.val = 1}
assert_equal Y, y.class
assert_equal 1, y.val
end
diff --git a/test/psych/test_date_time.rb b/test/psych/test_date_time.rb
index 433fbf3..443669d 100644
--- a/test/psych/test_date_time.rb
+++ b/test/psych/test_date_time.rb
@@ -5,7 +5,7 @@ require 'date'
module Psych
class TestDateTime < TestCase
def test_negative_year
- time = Time.utc -1, 12, 16
+ time = Time.utc(-1, 12, 16)
assert_cycle time
end
diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb
index 2599989..9b6d8c1 100644
--- a/test/psych/test_scalar_scanner.rb
+++ b/test/psych/test_scalar_scanner.rb
@@ -79,9 +79,9 @@ module Psych
end
def test_scan_null
- assert_equal nil, ss.tokenize('null')
- assert_equal nil, ss.tokenize('~')
- assert_equal nil, ss.tokenize('')
+ assert_nil ss.tokenize('null')
+ assert_nil ss.tokenize('~')
+ assert_nil ss.tokenize('')
end
def test_scan_symbol
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb
index 25c6353..4aa6016 100644
--- a/test/psych/test_string.rb
+++ b/test/psych/test_string.rb
@@ -33,28 +33,28 @@ module Psych
def test_doublequotes_when_there_is_a_single
str = "@123'abc"
yaml = Psych.dump str
- assert_match /---\s*"/, yaml
+ assert_match(/---\s*"/, yaml)
assert_equal str, Psych.load(yaml)
end
def test_plain_when_shorten_than_line_width_and_no_final_line_break
str = "Lorem ipsum"
yaml = Psych.dump str, line_width: 12
- assert_match /---\s*[^>|]+\n/, yaml
+ assert_match(/---\s*[^>|]+\n/, yaml)
assert_equal str, Psych.load(yaml)
end
def test_plain_when_shorten_than_line_width_and_with_final_line_break
str = "Lorem ipsum\n"
yaml = Psych.dump str, line_width: 12
- assert_match /---\s*[^>|]+\n/, yaml
+ assert_match(/---\s*[^>|]+\n/, yaml)
assert_equal str, Psych.load(yaml)
end
def test_folded_when_longer_than_line_width_and_with_final_line_break
str = "Lorem ipsum dolor sit\n"
yaml = Psych.dump str, line_width: 12
- assert_match /---\s*>\n(.*\n){2}\Z/, yaml
+ assert_match(/---\s*>\n(.*\n){2}\Z/, yaml)
assert_equal str, Psych.load(yaml)
end
@@ -62,7 +62,7 @@ module Psych
def test_folded_strip_when_longer_than_line_width_and_no_newlines
str = "Lorem ipsum dolor sit amet, consectetur"
yaml = Psych.dump str, line_width: 12
- assert_match /---\s*>-\n(.*\n){3}\Z/, yaml
+ assert_match(/---\s*>-\n(.*\n){3}\Z/, yaml)
assert_equal str, Psych.load(yaml)
end
@@ -72,7 +72,7 @@ module Psych
"Lorem ipsum\nZolor\n",
].each do |str|
yaml = Psych.dump str, line_width: 12
- assert_match /---\s*\|\n(.*\n){2}\Z/, yaml
+ assert_match(/---\s*\|\n(.*\n){2}\Z/, yaml)
assert_equal str, Psych.load(yaml)
end
end
@@ -84,7 +84,7 @@ module Psych
"Lorem ipsum\nZolor",
].each do |str|
yaml = Psych.dump str, line_width: 12
- assert_match /---\s*\|-\n(.*\n){2}\Z/, yaml
+ assert_match(/---\s*\|-\n(.*\n){2}\Z/, yaml)
assert_equal str, Psych.load(yaml)
end
end
@@ -129,7 +129,7 @@ string: &70121654388580 !ruby/string
end
def test_another_subclass_with_attributes
- y = Psych.load Psych.dump Y.new("foo").tap {|y| y.val = 1}
+ y = Psych.load Psych.dump Y.new("foo").tap {|o| o.val = 1}
assert_equal "foo", y
assert_equal Y, y.class
assert_equal 1, y.val
@@ -154,7 +154,7 @@ string: &70121654388580 !ruby/string
end
def test_subclass_with_attributes
- y = Psych.load Psych.dump Y.new.tap {|y| y.val = 1}
+ y = Psych.load Psych.dump Y.new.tap {|o| o.val = 1}
assert_equal Y, y.class
assert_equal 1, y.val
end
diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb
index 5755f58..ea38f6d 100644
--- a/test/psych/visitors/test_yaml_tree.rb
+++ b/test/psych/visitors/test_yaml_tree.rb
@@ -165,10 +165,10 @@ module Psych
# http://yaml.org/type/null.html
def test_nil
assert_cycle nil
- assert_equal nil, Psych.load('null')
- assert_equal nil, Psych.load('Null')
- assert_equal nil, Psych.load('NULL')
- assert_equal nil, Psych.load('~')
+ assert_nil Psych.load('null')
+ assert_nil Psych.load('Null')
+ assert_nil Psych.load('NULL')
+ assert_nil Psych.load('~')
assert_equal({'foo' => nil}, Psych.load('foo: '))
assert_cycle 'null'