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

ruby-changes:70253

From: Nobuyoshi <ko1@a...>
Date: Thu, 16 Dec 2021 15:48:23 +0900 (JST)
Subject: [ruby-changes:70253] 69a7eaae38 (master): Use `to_s` and `puts` in tests

https://git.ruby-lang.org/ruby.git/commit/?id=69a7eaae38

From 69a7eaae389b49eb2a99c1c44c11b3d5004d186f Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 16 Dec 2021 15:07:23 +0900
Subject: Use `to_s` and `puts` in tests

`to_s` has the explict specification while `inspect` is often
vague.
---
 spec/ruby/core/kernel/srand_spec.rb |  2 +-
 test/ruby/test_literal.rb           |  2 +-
 test/ruby/test_process.rb           | 24 ++++++++++++------------
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/spec/ruby/core/kernel/srand_spec.rb b/spec/ruby/core/kernel/srand_spec.rb
index 6774d192847..90c1d09b821 100644
--- a/spec/ruby/core/kernel/srand_spec.rb
+++ b/spec/ruby/core/kernel/srand_spec.rb
@@ -12,7 +12,7 @@ describe "Kernel.srand" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/srand_spec.rb#L12
   end
 
   it "returns the previous seed value on the first call" do
-    ruby_exe('p srand(10)', options: '--disable-gems').chomp.should =~ /\A\d+\z/
+    ruby_exe('print srand(10)', options: '--disable-gems').should =~ /\A\d+\z/
   end
 
   it "seeds the RNG correctly and repeatably" do
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
index 8c3256c0346..99dd3a0c56a 100644
--- a/test/ruby/test_literal.rb
+++ b/test/ruby/test_literal.rb
@@ -26,7 +26,7 @@ class TestRubyLiteral < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_literal.rb#L26
     assert_equal '5', 0b101.inspect
     assert_instance_of Integer, 0b101
     assert_raise(SyntaxError) { eval("0b") }
-    assert_equal '123456789012345678901234567890', 123456789012345678901234567890.inspect
+    assert_equal '123456789012345678901234567890', 123456789012345678901234567890.to_s
     assert_instance_of Integer, 123456789012345678901234567890
     assert_instance_of Float, 1.3
     assert_equal '2', eval("0x00+2").inspect
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index bd2413b74cb..91d554ea32b 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -208,39 +208,39 @@ class TestProcess < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L208
 
     n = max
     IO.popen([RUBY, "-e",
-             "p Process.getrlimit(:CORE)", :rlimit_core=>n]) {|io|
-      assert_equal("[#{n}, #{n}]\n", io.read)
+             "puts Process.getrlimit(:CORE)", :rlimit_core=>n]) {|io|
+      assert_equal("#{n}\n#{n}\n", io.read)
     }
 
     n = 0
     IO.popen([RUBY, "-e",
-             "p Process.getrlimit(:CORE)", :rlimit_core=>n]) {|io|
-      assert_equal("[#{n}, #{n}]\n", io.read)
+             "puts Process.getrlimit(:CORE)", :rlimit_core=>n]) {|io|
+      assert_equal("#{n}\n#{n}\n", io.read)
     }
 
     n = max
     IO.popen([RUBY, "-e",
-             "p Process.getrlimit(:CORE)", :rlimit_core=>[n]]) {|io|
-      assert_equal("[#{n}, #{n}]", io.read.chomp)
+             "puts Process.getrlimit(:CORE)", :rlimit_core=>[n]]) {|io|
+      assert_equal("#{n}\n#{n}\n", io.read)
     }
 
     m, n = 0, max
     IO.popen([RUBY, "-e",
-             "p Process.getrlimit(:CORE)", :rlimit_core=>[m,n]]) {|io|
-      assert_equal("[#{m}, #{n}]", io.read.chomp)
+             "puts Process.getrlimit(:CORE)", :rlimit_core=>[m,n]]) {|io|
+      assert_equal("#{m}\n#{n}\n", io.read)
     }
 
     m, n = 0, 0
     IO.popen([RUBY, "-e",
-             "p Process.getrlimit(:CORE)", :rlimit_core=>[m,n]]) {|io|
-      assert_equal("[#{m}, #{n}]", io.read.chomp)
+             "puts Process.getrlimit(:CORE)", :rlimit_core=>[m,n]]) {|io|
+      assert_equal("#{m}\n#{n}\n", io.read)
     }
 
     n = max
     IO.popen([RUBY, "-e",
-      "p Process.getrlimit(:CORE), Process.getrlimit(:CPU)",
+      "puts Process.getrlimit(:CORE), Process.getrlimit(:CPU)",
       :rlimit_core=>n, :rlimit_cpu=>3600]) {|io|
-      assert_equal("[#{n}, #{n}]\n[3600, 3600]", io.read.chomp)
+      assert_equal("#{n}\n#{n}\n""3600\n3600\n", io.read)
     }
 
     assert_raise(ArgumentError) do
-- 
cgit v1.2.1


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

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