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

ruby-changes:47744

From: ko1 <ko1@a...>
Date: Wed, 13 Sep 2017 08:15:41 +0900 (JST)
Subject: [ruby-changes:47744] ko1:r59861 (trunk): Use mutable strings for mutation tests.

ko1	2017-09-13 08:15:34 +0900 (Wed, 13 Sep 2017)

  New Revision: 59861

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

  Log:
    Use mutable strings for mutation tests.
    
    * test/fiddle/test_func.rb (test_string): this test break String buffer
      by `strcpy` ("000" -> "123"). However, the string literal "000" with
      `frozen_string_literal: true` returns a string object from frozen
      string pool. So that after this test "000" from fstring pool becomes
      "123" (modified string). 'test/date/' uses "000" (as fstring) and tests
      are fails (we could check with `make test-all TESTS='fiddle date'`).
    
    * test/fiddle/test_function.rb: ditto.
    
    * test/fiddle/test_import.rb: ditto.

  Modified files:
    trunk/test/fiddle/test_func.rb
    trunk/test/fiddle/test_function.rb
    trunk/test/fiddle/test_import.rb
Index: test/fiddle/test_function.rb
===================================================================
--- test/fiddle/test_function.rb	(revision 59860)
+++ test/fiddle/test_function.rb	(revision 59861)
@@ -60,13 +60,13 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_function.rb#L60
       func = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
 
       assert_nil Fiddle.last_error
-      func.call("000", "123")
+      func.call(+"000", "123")
       refute_nil Fiddle.last_error
     end
 
     def test_strcpy
       f = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
-      buff = "000"
+      buff = +"000"
       str = f.call(buff, "123")
       assert_equal("123", buff)
       assert_equal("123", str.to_s)
Index: test/fiddle/test_import.rb
===================================================================
--- test/fiddle/test_import.rb	(revision 59860)
+++ test/fiddle/test_import.rb	(revision 59861)
@@ -128,7 +128,7 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_import.rb#L128
     end
 
     def test_strcpy()
-      buff = "000"
+      buff = +"000"
       str = LIBC.strcpy(buff, "123")
       assert_equal("123", buff)
       assert_equal("123", str.to_s)
Index: test/fiddle/test_func.rb
===================================================================
--- test/fiddle/test_func.rb	(revision 59860)
+++ test/fiddle/test_func.rb	(revision 59861)
@@ -38,7 +38,7 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_func.rb#L38
     def test_string
       stress, GC.stress = GC.stress, true
       f = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
-      buff = "000"
+      buff = +"000"
       str = f.call(buff, "123")
       assert_equal("123", buff)
       assert_equal("123", str.to_s)

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

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