[前][次][番号順一覧][スレッド一覧]

ruby-changes:46159

From: nobu <ko1@a...>
Date: Fri, 7 Apr 2017 22:26:18 +0900 (JST)
Subject: [ruby-changes:46159] nobu:r58272 (trunk): use dedicated assertions

nobu	2017-04-07 22:26:12 +0900 (Fri, 07 Apr 2017)

  New Revision: 58272

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58272

  Log:
    use dedicated assertions

  Modified files:
    trunk/test/drb/drbtest.rb
    trunk/test/drb/test_acl.rb
    trunk/test/drb/test_drb.rb
Index: test/drb/test_acl.rb
===================================================================
--- test/drb/test_acl.rb	(revision 58271)
+++ test/drb/test_acl.rb	(revision 58272)
@@ -48,58 +48,58 @@ class ACLEntryTest < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/drb/test_acl.rb#L48
     a = ACL::ACLEntry.new("*")
     b = ACL::ACLEntry.new("all")
     @hostlist.each do |h|
-      assert(a.match(h))
-      assert(b.match(h))
+      assert_operator(a, :match, h)
+      assert_operator(b, :match, h)
     end
   end
 
   def test_ip_v6
     a = ACL::ACLEntry.new('::ffff:192.0.0.0/104')
-    assert(! a.match(@hosts['localhost']))
-    assert(a.match(@hosts['yum']))
-    assert(a.match(@hosts['ipv6']))
-    assert(! a.match(@hosts['too']))
+    assert_not_operator(a, :match, @hosts['localhost'])
+    assert_operator(a, :match, @hosts['yum'])
+    assert_operator(a, :match, @hosts['ipv6'])
+    assert_not_operator(a, :match, @hosts['too'])
   end
 
   def test_ip
     a = ACL::ACLEntry.new('192.0.0.0/8')
-    assert(! a.match(@hosts['localhost']))
-    assert(a.match(@hosts['yum']))
+    assert_not_operator(a, :match, @hosts['localhost'])
+    assert_operator(a, :match, @hosts['yum'])
 
     a = ACL::ACLEntry.new('192.168.0.1/255.255.0.255')
-    assert(! a.match(@hosts['localhost']))
-    assert(! a.match(@hosts['yum']))
-    assert(a.match(@hosts['x68k']))
+    assert_not_operator(a, :match, @hosts['localhost'])
+    assert_not_operator(a, :match, @hosts['yum'])
+    assert_operator(a, :match, @hosts['x68k'])
 
     a = ACL::ACLEntry.new('192.168.1.0/24')
-    assert(! a.match(@hosts['localhost']))
-    assert(a.match(@hosts['yum']))
-    assert(a.match(@hosts['x68k']))
+    assert_not_operator(a, :match, @hosts['localhost'])
+    assert_operator(a, :match, @hosts['yum'])
+    assert_operator(a, :match, @hosts['x68k'])
 
     a = ACL::ACLEntry.new('92.0.0.0/8')
-    assert(! a.match(@hosts['localhost']))
-    assert(! a.match(@hosts['yum']))
-    assert(! a.match(@hosts['x68k']))
+    assert_not_operator(a, :match, @hosts['localhost'])
+    assert_not_operator(a, :match, @hosts['yum'])
+    assert_not_operator(a, :match, @hosts['x68k'])
 
     a = ACL::ACLEntry.new('127.0.0.1/255.0.0.255')
-    assert(a.match(@hosts['localhost']))
-    assert(! a.match(@hosts['yum']))
-    assert(! a.match(@hosts['x68k']))
+    assert_operator(a, :match, @hosts['localhost'])
+    assert_not_operator(a, :match, @hosts['yum'])
+    assert_not_operator(a, :match, @hosts['x68k'])
   end
 
   def test_name
     a = ACL::ACLEntry.new('*.jp')
-    assert(! a.match(@hosts['localhost']))
-    assert(a.match(@hosts['yum']))
+    assert_not_operator(a, :match, @hosts['localhost'])
+    assert_operator(a, :match, @hosts['yum'])
 
     a = ACL::ACLEntry.new('yum.*.jp')
-    assert(a.match(@hosts['yum']))
-    assert(! a.match(@hosts['lc630']))
+    assert_operator(a, :match, @hosts['yum'])
+    assert_not_operator(a, :match, @hosts['lc630'])
 
     a = ACL::ACLEntry.new('*.macos.or.jp')
-    assert(a.match(@hosts['yum']))
-    assert(a.match(@hosts['lc630']))
-    assert(! a.match(@hosts['lib30']))
+    assert_operator(a, :match, @hosts['yum'])
+    assert_operator(a, :match, @hosts['lc630'])
+    assert_not_operator(a, :match, @hosts['lib30'])
   end
 end
 
@@ -124,29 +124,29 @@ class ACLListTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/drb/test_acl.rb#L124
   def test_all_1
     a = build(%w(all))
     @hostlist.each do |h|
-      assert(a.match(h))
+      assert_operator(a, :match, h)
     end
   end
 
   def test_all_2
     a = build(%w(localhost 127.0.0.0/8 yum.* *))
     @hostlist.each do |h|
-      assert(a.match(h))
+      assert_operator(a, :match, h)
     end
   end
 
   def test_1
     a = build(%w(192.0.0.1/255.0.0.255 yum.*.jp))
-    assert(a.match(@hosts['yum']))
-    assert(a.match(@hosts['x68k']))
-    assert(! a.match(@hosts['lc630']))
+    assert_operator(a, :match, @hosts['yum'])
+    assert_operator(a, :match, @hosts['x68k'])
+    assert_not_operator(a, :match, @hosts['lc630'])
   end
 
   def test_2
     a = build(%w(*.linux.or.jp))
-    assert(!a.match(@hosts['yum']))
-    assert(a.match(@hosts['x68k']))
-    assert(!a.match(@hosts['lc630']))
+    assert_not_operator(a, :match, @hosts['yum'])
+    assert_operator(a, :match, @hosts['x68k'])
+    assert_not_operator(a, :match, @hosts['lc630'])
   end
 end
 
@@ -161,14 +161,14 @@ class ACLTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/drb/test_acl.rb#L161
   def test_0
     a = ACL.new
     @hostlist.each do |h|
-      assert(a.allow_addr?(h))
+      assert_operator(a, :allow_addr?, h)
     end
   end
 
   def test_not_0
     a = ACL.new([], ACL::ALLOW_DENY)
     @hostlist.each do |h|
-      assert(! a.allow_addr?(h))
+      assert_not_operator(a, :allow_addr?, h)
     end
   end
 
@@ -178,9 +178,9 @@ class ACLTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/drb/test_acl.rb#L178
               allow x68k.*)
 
     a = ACL.new(data)
-    assert(a.allow_addr?(@hosts['x68k']))
-    assert(a.allow_addr?(@hosts['localhost']))
-    assert(! a.allow_addr?(@hosts['lc630']))
+    assert_operator(a, :allow_addr?, @hosts['x68k'])
+    assert_operator(a, :allow_addr?, @hosts['localhost'])
+    assert_not_operator(a, :allow_addr?, @hosts['lc630'])
   end
 
   def test_not_1
@@ -189,9 +189,9 @@ class ACLTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/drb/test_acl.rb#L189
               allow x68k.*)
 
     a = ACL.new(data, ACL::ALLOW_DENY)
-    assert(!a.allow_addr?(@hosts['x68k']))
-    assert(a.allow_addr?(@hosts['localhost']))
-    assert(! a.allow_addr?(@hosts['lc630']))
+    assert_not_operator(a, :allow_addr?, @hosts['x68k'])
+    assert_operator(a, :allow_addr?, @hosts['localhost'])
+    assert_not_operator(a, :allow_addr?, @hosts['lc630'])
   end
 end
 
Index: test/drb/test_drb.rb
===================================================================
--- test/drb/test_drb.rb	(revision 58271)
+++ test/drb/test_drb.rb	(revision 58272)
@@ -121,10 +121,10 @@ class TestDRbYield < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/drb/test_drb.rb#L121
 
   def test_06_taint
     x = proc {}
-    assert(! x.tainted?)
+    assert_not_predicate(x, :tainted?)
     @there.echo_yield(x) {|o|
       assert_equal(x, o)
-      assert(! x.tainted?)
+      assert_not_predicate(x, :tainted?)
     }
   end
 end
@@ -393,7 +393,7 @@ class TestBug4409 < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/drb/test_drb.rb#L393
 
   def test_bug4409
     foo = @there.foo
-    assert(@there.foo?(foo))
+    assert_operator(@there, :foo?, foo)
   end
 end
 
Index: test/drb/drbtest.rb
===================================================================
--- test/drb/drbtest.rb	(revision 58271)
+++ test/drb/drbtest.rb	(revision 58272)
@@ -124,10 +124,10 @@ module DRbCore https://github.com/ruby/ruby/blob/trunk/test/drb/drbtest.rb#L124
     ary = @there.to_a
     assert_kind_of(DRb::DRbObject, ary)
 
-    assert(@there.respond_to?(:to_a, true))
-    assert(@there.respond_to?(:eval, true))
-    assert(! @there.respond_to?(:eval, false))
-    assert(! @there.respond_to?(:eval))
+    assert_respond_to(@there, [:to_a, true])
+    assert_respond_to(@there, [:eval, true])
+    assert_not_respond_to(@there, [:eval, false])
+    assert_not_respond_to(@there, :eval)
   end
 
   def test_01_02_loop
@@ -171,20 +171,19 @@ module DRbCore https://github.com/ruby/ruby/blob/trunk/test/drb/drbtest.rb#L171
 
   def test_04
     assert_respond_to(@there, 'sum')
-    assert(!(@there.respond_to? "foobar"))
+    assert_not_respond_to(@there, "foobar")
   end
 
   def test_05_eq
     a = @there.to_a[0]
     b = @there.to_a[0]
-    assert(a.object_id != b.object_id)
-    assert(a == b)
+    assert_not_same(a, b)
     assert_equal(a, b)
-    assert(a == @there)
+    assert_equal(a, @there)
     assert_equal(a.hash, b.hash)
     assert_equal(a.hash, @there.hash)
-    assert(a.eql?(b))
-    assert(a.eql?(@there))
+    assert_operator(a, :eql?, b)
+    assert_operator(a, :eql?, @there)
   end
 
   def test_06_timeout

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]